Solved

PHP

Posted on 2003-12-08
8
211 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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 …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

746 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

11 Experts available now in Live!

Get 1:1 Help Now