Jump to content

Recommended Posts

Hi all

I am in the process of creating a PHP / mySQL based survey. It consists of 4 pages each with a form that sends information to a mySQL database. The first record adds perfectly and the next 3 pages add into the same record as they should using the update function. But when the survey is filled in from the start again, the second page results are added to all of the records in the database not just the last inserted one. Here's the code:

 

@$pfw_strQuery = "UPDATE `29052009` SET `page2`='$page2_info'";

 

Can anyone help?

 

Thanks

Pete

 

 

Hi there

 

I've tried this:

 

@$pfw_strQuery = "UPDATE `29052009` SET `page2`='$page2_info' WHERE `id` = LAST_INSERT_ID()";

 

But no data is sent into the database, is the syntax incorrect? My database does have an 'id' field which is auto increment and the primary key.

 

Thanks

Why do you have an @ before a variable? They suppress errors.

 

You are running the query after aren't you? If so, after the mysql_query function add:

 

or trigger_error('Query failed: ' . mysql_error($db), E_USER_ERROR);

 

So it would look something like:

 

$var = mysql_query(...) or trigger_error('Query failed: ' . mysql_error($db), E_USER_ERROR);

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.