Jump to content

Trouble Upadating a MySQL row.


horseatingweeds

Recommended Posts

I can't figure out what I'm doing wrong. Does anyone see what I'm doing wrong with this update inquiry? All of the code works elsewhere except the update inquiry, I think that's where the problem is.

 

$username = 'testname3';
$title = strip_tags($_POST['title_u']);
$email = strip_tags($_POST['email_u']);
$phone = strip_tags($_POST['phone_u']);
$state = strip_tags($_POST['state_u']);
$availability = strip_tags($_POST['availability_u']);
$description = strip_tags($_POST['description_u']);

$linkID = @mysql_connect('localhost', 'root', 'pasyes')
or die('Could not connect');

@mysql_select_db('breederlist') or die ('Could not get DB');
$query = "UPDATE listing SET title='$title', email='$email',
phone='$phone', state='$state', availability='$availability', description='$description'
WHERE rowID='$username'";

$result = mysql_query($query);

if ($result) echo $username . " updated.";
else echo "Trouble updating";

Link to comment
https://forums.phpfreaks.com/topic/65140-trouble-upadating-a-mysql-row/
Share on other sites

It echos my error message 'trouble updating.' The database connection works. If I replace the update query with another query, like this one:

 

$query = "INSERT INTO listing SET username='$username', title='$title', email='$email',
phone='$phone', state='$state', availability='$availability', description='$description'";

 

It works fine.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.