Jump to content

stuck on php update for mysql


thereaper87

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/212486-stuck-on-php-update-for-mysql/
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.