Bradley99 Posted February 7, 2011 Share Posted February 7, 2011 Here's the error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/stayway1/public_html/www.one-mafia.com/eng/inboxread.php on line 99 Here's lines 90-110: (99 in bold) if (strip_tags($_POST['Accept_OC'])){ $oc_id=strip_tags($_POST['oc_id']); if (strip_tags($_POST['place']) == "we"){ $use="we_inv"; $a="we"; $query= "SELECT * FROM oc WHERE we_inv='$username' AND id='$oc_id'"; }elseif (strip_tags($_POST['place']) == "ee"){ $use="ee_inv"; $a="ee"; $query= "SELECT * FROM oc WHERE ee_inv='$username' AND id='$oc_id'"; }elseif (strip_tags($_POST['place']) == "driver"){ $use="driver_inv"; $a="driver"; $query= "SELECT * FROM oc WHERE driver_inv='$username' AND id='$oc_id'"; } $round=mysql_query($query); [b]$check=mysql_num_rows($round);[/b] if ($check != "0"){ echo "You are now in that OC"; mysql_query("UPDATE `oc` SET `$a`='$username' WHERE `id`='$oc_id'"); mysql_query("UPDATE `users` SET `oc`='1' WHERE `username`='$username'"); } } if (strip_tags($_POST['Yes_street'])){ $race_id=strip_tags($_POST['race_id']); if ($fetch->street != "0"){ echo "Your in a race."; }elseif ($fetch->street == "0"){ if ($fetch->last_race >= time()){ echo "You cant do anouther race yet."; }elseif ($fetch->last_race < time()){ Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 This is the 'real' error Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #5' at line 1 Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 8, 2011 Share Posted February 8, 2011 First, you don't have a default condition, so if none of the if/elseif conditions evaluate to true, the variables won't have values. But anyhow, to help diagnose your problem, add some reporting to the query for debugging. The second error you posted doesn't appear related . . . $round=mysql_query($query) or die( "<br>Query string: $query<br>Failed with error: " . mysql_error() ); Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 First, you don't have a default condition, so if none of the if/elseif conditions evaluate to true, the variables won't have values. But anyhow, to help diagnose your problem, add some reporting to the query for debugging. The second error you posted doesn't appear related . . . $round=mysql_query($query) or die( "<br>Query string: $query<br>Failed with error: " . mysql_error() ); Thanks, Here's the error i get... Query string: Resource id #5 Failed with error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #5' at line 1 Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 8, 2011 Share Posted February 8, 2011 Here's what I believe it comes down to: if none of the if/elseif conditions evaluate to true, the variables won't have new values assigned. If that's the case, and you previously executed a query with $query = mysql_query("SELECT whatever . . .), then $query will still hold that result resource instead of the query string it should hold at that point. To test that, make this change: }elseif (strip_tags($_POST['place']) == "driver"){ $use="driver_inv"; $a="driver"; $query= "SELECT * FROM oc WHERE driver_inv='$username' AND id='$oc_id'"; } else { // < --- ADD THIS die( "NO CONDITIONS MATCHED."); <--- ADD THIS } <--- ADD THIS $round=mysql_query($query); $check=mysql_num_rows($round); Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 Yeah i got 'NO CONDITIONS MATCHED' What does that mean for the code? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 8, 2011 Share Posted February 8, 2011 Well, it means that $_POST['accept_OC'] is unset/empty and/or $_POST['place'] isn't 'we', 'ee', or 'driver'. Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 Ok, Here's the script from where the invite is sent... (well that part of the script...) if (strip_tags($_POST['inv_button'])){ $inv_username=strip_tags($_POST['inv_username']); $com=mysql_num_rows(mysql_query("SELECT * FROM oc WHERE leader='$inv_username' OR we='$inv_username' OR ee='$inv_username' OR driver='$inv_username'")); $lee=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$inv_username'")); if ($lee->last_oc > time()){ echo "This is user is not ready to do an oc!"; }elseif ($lee->last_oc <= time()){ if ($com != "0"){ echo "This person is in an oc!"; }elseif ($com == "0"){ if (strtolower($username) == strtolower($inv_username)){ echo "You cannot invite your self"; }elseif(strtolower($username) != strtolower($inv_username)){ if (strip_tags($_POST['inv']) == "inv_we"){ $inv_username=strip_tags($_POST['inv_username']); $check = mysql_num_rows(mysql_query("SELECT * FROM users WHERE username='$inv_username'")); if ($check == "0"){ echo "No such user."; }elseif ($check != "0"){ if ($oc->we != "0"){ echo "You need to kick the Weapons expert before you invite someone else."; }elseif ($oc->we == "0"){ $invite_text="<form name=invite_to_oc method=post action=?accept=oc&oc_id=$oc->id> <div align=center>You have been invited to join $username s Getaway in $lead->location, please choose one of the following options:<br> <input name=Decline class=button type=submit id=Decline value=Decline> | <input name=Accept_OC type=submit class=button id=Accept value=Accept> </div> </form>"; mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` ) VALUES ( '', '$inv_username', '$inv_username', '$invite_text', '$date', '0' )"); echo "Weapons expert invited"; mysql_query("UPDATE oc SET we_inv='$inv_username' WHERE id='$oc->id'"); Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 Still can't fix Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 8, 2011 Share Posted February 8, 2011 At the top of the script that is doing the processing, add this right after the opening <?php tag so you can see exactly what is being sent to the script. echo '<pre>$_POST array is: '; print_r($_POST); echo '</pre><pre>$_GET array is: '; print_r($_GET); echo '</pre>'; Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 Do you mean on the Inbox page? Or the last code i posted which actually send's the mail? Here's what i got on the Inbox page with it... $_POST array is: Array ( ) $_GET array is: Array ( [id] => 34 ) Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/stayway1/public_html/www.one-mafia.com/eng/inboxread.php:2) in /home/stayway1/public_html/www.one-mafia.com/eng/inboxread.php on line 7 Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 And here's what happened when i hit Accept.... $_POST array is: Array ( [Accept_OC] => Accept ) $_GET array is: Array ( [accept] => oc [oc_id] => 1 ) Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 8, 2011 Share Posted February 8, 2011 Looks like the $_POST['place'] element is missing altogether. Looking at your form, it doesn't exist as an input. At this point, that seems to be the major malfunction. Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 Hmmm, The Place == the position the person would be i.e the Driver, Weapons Expert etc like so... if (strip_tags($_POST['place']) == "we"){ Can't figure it atall! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 8, 2011 Share Posted February 8, 2011 If there isn't a field named 'place' within the <form></form> tags, the value won't be present in the $_POST array. Quote Link to comment Share on other sites More sharing options...
Bradley99 Posted February 8, 2011 Author Share Posted February 8, 2011 Yeah, I just changed the Place to Accept_OC and doesn't work get NO CONDITIONS MATCHED... Quote Link to comment 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.