Jump to content

Database Won't Update


refiking

Recommended Posts

When I run this, I don't get any errors and the db is not updated.  What do I need to change?

 

$sql2= mysql_query("UPDATE gridgamers SET pass = '$password' WHERE user = '$username'")or die(mysql_error()); 
$sql3= mysql_query("UPDATE gridgamers SET pc = 'yes' WHERE user = '$username'")or die(mysql_error()); 

Link to comment
https://forums.phpfreaks.com/topic/97275-database-wont-update/
Share on other sites

You're not running the queries, you're just storing them in variables. An example of running them would be:

$sql2= mysql_query("UPDATE gridgamers SET pass = '$password' WHERE user = '$username'")or die(mysql_error()); 
$sql3= mysql_query("UPDATE gridgamers SET pc = 'yes' WHERE user = '$username'")or die(mysql_error()); 

if ($sql2)
{
echo "query ran sucessfully";
}

 

Link to comment
https://forums.phpfreaks.com/topic/97275-database-wont-update/#findComment-497782
Share on other sites

actually they are running the query and returning the query resource to a variable ($sql2, $sql3)

they are not updating because there must be no rows where user = $username

 

Its better to write your query like

<?php
$q = "UPDATE `gridgamers` SET pass = '".$password."' WHERE user = '".$username."'";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
#if it fails no error try
echo $q;
?>

take th echo $q to phpmyadmin and see what u get

Link to comment
https://forums.phpfreaks.com/topic/97275-database-wont-update/#findComment-497787
Share on other sites

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.