0

Like this:

$result = mysql_query ("UPDATE StudentInfo SET StudentNumber= '$StudentNumber', FirstName='$FirstName', LastName='$LastName', EmailAddr='$EmailAddr', PhoneNumber='$PhoneNumber' WHERE recordID ='$RecordID'");

or is this better

$query_str = "UPDATE StudentInfo SET StudentNumber= $StudentNumber, FirstName=$FirstName, LastName=$LastName, EmailAddr=$EmailAddr, PhoneNumber=$PhoneNumber WHERE recordID=$RecordID";

$result = mysql_query($query_str);
if (!$result) {
    die('Invalid query: ' . mysql_error());

with the single quotes added

Edited by pritaeas: Added code tags

0

Ok,

I think this is best

$result = "UPDATE StudentInfo SET StudentNumber= '$StudentNumber', FirstName='$FirstName', LastName='$LastName', EmailAddr='$EmailAddr', PhoneNumber='$PhoneNumber' WHERE recordID ='$RecordID'" or die(mysql_error());
$query=mysql_query($result);

However it runs as if it has updated however the data does not change?!?!

Any ideas?

1

You really need to be less sloppy, the code should be:

$query = "UPDATE StudentInfo SET StudentNumber= '$StudentNumber', FirstName='$FirstName', LastName='$LastName', EmailAddr='$EmailAddr', PhoneNumber='$PhoneNumber' WHERE recordID ='$RecordID'";
$result = mysql_query($query) or die(mysql_error());
Votes + Comments
brought a smile to my face
0

When i run that i get

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'recordID'] ?>'' at line 1

1

Try this, and show the output.

$query = "UPDATE StudentInfo SET StudentNumber= '$StudentNumber', FirstName='$FirstName', LastName='$LastName', EmailAddr='$EmailAddr', PhoneNumber='$PhoneNumber' WHERE recordID ='$RecordID'";
$result = mysql_query($query) or die(mysql_error() . '<br/>' . $query);
Votes + Comments
Thanks for your help
0

I get the follwing:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'recordID'] ?>'' at line 1

UPDATE StudentInfo SET StudentNumber= 'M00259315', FirstName='Jay', LastName='Green ', EmailAddr='jg@mdx.ac.uk', PhoneNumber='02086649985 ' WHERE recordID =''

Edited by pritaeas: Added code tags

0

As you can see, the record ID is empty, so probably not passed correctly by your form. Check that your form is created correctly.

0

I have this to pass the recordID variable to updateRecord.php

<input name="recordID" type="hidden" id="recordID" value="<?=$row['recordID'] ?>" />

Suntax look ok?

Edited by pritaeas: Code tags, please try to do this yourself or risk infraction.

0

Check your output. If the ID isn't there, it's wrong. I prefer long tags:

<input name="recordID" type="hidden" id="recordID" value="<?php echo $row['recordID']; ?>" />
0

ITS WORKING!!!!

im not quite sure what i did but it is working.

Thanks so much. Is ther a thank button or anything?

0

You can mark the thread solved (recommended), you can upvote a reply, or you can upvote with a comment (adds reputation).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.