Jump to content

Recommended Posts

Hi

 

I am having trouble trying to update a number of columns.

 

I originally used the script to update just 2 columns using the following code, which works fine:

 

$query = "UPDATE members SET available = $available, required = $required WHERE email=$email";

 

I then decided that more columns needed to be included and changed the coded to:

 

$query = "UPDATE members SET available = $available, required = $required, datesav = $datesav prevexperience = $prevexperience, datesneed = $datesneed, experienceneed = $experienceneed WHERE email=$email";

 

but it doesnt work - I use an IF statement if(!$result) and get my custom error message.

 

Full coded listed below:

 

            $avail = $_POST['available'];
$req = $_POST['required'];
$datesav = $_POST['Dates_Av'];
$prevexperience = $_POST['Prev_Experience'];
$datesneed = $_POST['Dates_Needed'];
$experienceneed = $_POST['Experience_Needed'];

    //(Check that variables contain values, which they do)
echo $datesav;
echo $prevexperience;
echo $datesneed;
echo $experienceneed;

include ('connect.php');

$query = "UPDATE members SET available = $available, required = $required, datesav = $datesav prevexperience = $prevexperience, datesneed = $datesneed, experienceneed = $experienceneed WHERE email=$email";

$result = mysql_query($query, $dbh);

if(!$result)
{
echo'<p style="margin-top: 0; margin-bottom: 0"> </p>';
echo'<p style="margin-top: 0; margin-bottom: 0"> </p>';
echo '<center><p><b><font face="arial" size="2" color="#ff0000">Status could not be changed.</b></font></p>';
exit;
}

else
{
echo'<p style="margin-top: 0; margin-bottom: 0"> </p>';
echo'<p style="margin-top: 0; margin-bottom: 0"> </p>';
echo '<center><p><b><font face="arial" size="2" color="#ff0000">Update Successful.</b></font></p>';
}

 

Any suggestions welcome

 

Many thanks

you forgot a comma,

 

this

$query = "UPDATE members SET available = $available, required = $required, datesav = $datesav prevexperience = $prevexperience, datesneed = $datesneed, experienceneed = $experienceneed WHERE email=$email";

 

should be

$query = "UPDATE members SET available = $available, required = $required, datesav = $datesav, prevexperience = $prevexperience, datesneed = $datesneed, experienceneed = $experienceneed WHERE email=$email";

 

also are all of your columns intergers ?

still no joy.  this is what the query looks like now:

 

$query = "UPDATE members SET available = $available, required = $required, datesav = '$datesav', prevexperience = '$prevexperience', datesneed = '$datesneed', experienceneed = '$experienceneed' WHERE email='$email'";

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.