Jump to content

cannot insert data in mysql table


nevsi79

Recommended Posts

Hi guys,

 

I'm a student and very new to PHP, hence you might find my question stupid, but I cannot see the problem.

 

My query is as follows:

 

$add_claim_details_sql = "INSERT INTO claim_details (ins_ref_no) VALUES ('$your_ref_no')";

 

when I echo it, I get:

 

INSERT INTO claim_details (ins_ref_no) VALUES ('1')

 

//1 is what I've put in the form

 

so far so good, but when I go to mysql table and check if 1 exists under the ins_ref_no, there's nothing there, there's no entry in the table at all, even no id. I've set my id as primary key, auto_increment???

 

Earlier I was inserting the following:

 

$add_claim_details_sql = "INSERT INTO claim_details (date_added, date_modified, ins_ref_no) VALUES (now(), now(), '$your_ref_no')";

 

and when I looked in my claim_details mysql table, the date_added and the date_modified columns were filled with the appropriate date, time

 

really puzzled ???

 

can anyone help please? :'(

 

 

 

 

Link to comment
Share on other sites

There are several things that could go wrong.

 

I would start by editing that line of code to look like this:

 

$sql_query = mysql_query("INSERT INTO claim_details (ins_ref_no) VALUES ('$your_ref_no')") or die(mysql_error());

 

This will print out some error information provided by mysql. See what that tells you. If you get something like "no table exists" or something of the sort, then try putting tick marks (`table_name`) around the table name.

Link to comment
Share on other sites

There are several things that could go wrong.

 

I would start by editing that line of code to look like this:

 

$sql_query = mysql_query("INSERT INTO claim_details (ins_ref_no) VALUES ('$your_ref_no')") or die(mysql_error());

 

This will print out some error information provided by mysql. See what that tells you. If you get something like "no table exists" or something of the sort, then try putting tick marks (`table_name`) around the table name.

 

Dear turtleman8605, dear eddierosenthal,

 

You are so right, I  changed it and it works, MANY THANKS :)

 

I'm so happy because I just registered in this forum and now I see I can actually get help from clever people like you!

 

Otherwise I felt so helpless

 

Thank you!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.