Solved

PHP

Posted on 2003-12-08
8
217 Views
Last Modified: 2006-11-17
I thought the problem was solved but it's not.
When I run the below.  I get no errors at all.  But nothing is being inserted in the Database.
I just get 'Not Inserting'.
Somebody please help.

$s_name = $_post['s_name'];
$description = $_post['description'];

$username = "dca";
$password = "abv132";
$database = "spa";

$dbcnx = @mysql_connect('localhost',$username,$password);
//@mysql_select_db($database) or die( "Unable to select database");

if (!$dbcnx) {
      echo('unable to connect');
      echo(mysql_error());
      exit();
      }

$sql = "INSERT INTO serer(s_Name, Desc) VALUES('$s_name', '$desc')";

if (@mysql_query($sql)){
echo('Connected');
}else
{
echo('Not Inserting');
}
0
Comment
Question by:Isaac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9900659
syntex error again.
$sql = "INSERT INTO serer(s_Name, Desc) VALUES('$s_name', '$desc')";
to
$sql = "INSERT INTO server(s_Name, Desc) VALUES('$s_name', '$desc')";
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9900680
also u do not have name $desc, it is $description. on the same line.
0
 
LVL 13

Accepted Solution

by:
lozloz earned 500 total points
ID: 9900683
if in future you want to debug more easily, change:

@mysql_query($sql) to mysql_query($sql) or die(mysql_error())

loz
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:Isaac
ID: 9900685
Could you please point it out.  I don't see it.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9900686
so the new line will be,
$sql = "INSERT INTO server(s_Name, Desc) VALUES('$s_name', '$description')";
0
 
LVL 5

Author Comment

by:Isaac
ID: 9900709
Thanks lozloz!!
When I added that debug line, I found out what the problem was.
I had an important line in my code commented.

//@mysql_select_db($database) or die( "Unable to select database");

-TheInnovator-
0
 
LVL 5

Author Comment

by:Isaac
ID: 9900716
I have to wait to give you your points.
When I try to Accept your answer.  i get an 'Internal Database Error'.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9900721
But still u have these error which i pointed out.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question