thereaper87 Posted September 4, 2010 Share Posted September 4, 2010 Hello there, here is my page I'm having problem with.. <?php session_start(); require_once 'database.php'; include("header.php"); $username="***"; $password = "****"; $hostname = "localhost"; $database = "***"; $id = $_GET['id']; // Connect to MySQL... $conn = mysql_connect($hostname, $username, $password) or die("Connecting to MySQL failed"); mysql_select_db($database, $conn) or die("Selecting MySQL database failed"); // Run our query, see if session username exists in session field... $sql="select username,gang,gangid from user where username='{$_SESSION['user']}' limit 1"; $result=mysql_query($sql,$conn); // Parse our results into $data (as an associative array)... $data=mysql_fetch_assoc($result); $gangsql="select id,to,gang,gangid from ganginv where id='$id' limit 1"; $gangresult=mysql_query($gangsql,$conn); // Parse our results into $data (as an associative array)... $data2=mysql_fetch_assoc($gangresult); // This is line 24 if ( $data['username'] == $data2['to'] ){ $gang = $data2['gang']; $gangid = $data2['gangid']; $insertelse="UPDATE user SET gang='$gang', gangid='$gangid' WHERE username='{$_SESSION['user']}'"; $insertresultelse=mysql_query($insertelse); }else{ echo "This invite was not for you."; } ?> What this does is it performs to queries to two different tables. Then it matches the usernames ( to make sure it's the same) and then update the table "user" to the column "gang" and "gangid". Here is the error it gives me: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home2/******/ganginv.php on line 24 This invite was not for you. Line 24 is marked. I appreciate all the help/info you have to offer! Quote Link to comment https://forums.phpfreaks.com/topic/212486-stuck-on-php-update-for-mysql/ Share on other sites More sharing options...
Pikachu2000 Posted September 4, 2010 Share Posted September 4, 2010 to is a MySQL reserved word. Enclose it in backticks and you should be good to go. Quote Link to comment https://forums.phpfreaks.com/topic/212486-stuck-on-php-update-for-mysql/#findComment-1107075 Share on other sites More sharing options...
thereaper87 Posted September 4, 2010 Author Share Posted September 4, 2010 oh wow, I didn't even realize that, thanks a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/212486-stuck-on-php-update-for-mysql/#findComment-1107079 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.