Solved

PHP

Posted on 2003-12-08
8
212 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
  • 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
 
LVL 5

Author Comment

by:Isaac
ID: 9900685
Could you please point it out.  I don't see it.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now