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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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