Solved

PHP

Posted on 2003-12-08
8
213 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

832 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