Eggzorcist Posted August 19, 2009 Share Posted August 19, 2009 It seems like my sql command isn't correct as it's not obtaining the correct information. As it always outputs the else command when it should show the if statement. $_GET['ID'] = $eid; $_SESSION['USER'] = $euser; $query = mysql_query("SELECT * FROM events WHERE id = '{$eid}' and user = '{$euser}'"); if (mysql_num_rows($query) >= 1){ $editinfo = mysql_fetch_assoc($query); } else { echo "You cannot edit that particular event, you may only edit events you've created."; } Any idea of syntax or problematic things in this code? Any help will be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted August 19, 2009 Share Posted August 19, 2009 This part should be probably $eid = $_GET['ID']; $euser = $_SESSION['USER']; You could also echo $query; to see if the query string is correct.. Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 19, 2009 Author Share Posted August 19, 2009 Now I'm getting the Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /Users/JPFoster/Sites/Event_Profiler/editevent.php on line 16 I'm having trouble with this argument, sometimes this occurs and other time it doesn't... I'm really not sure I'm getting that warning... Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted August 19, 2009 Share Posted August 19, 2009 That means ur query has failed... try this and see what error it gives $query = mysql_query("SELECT * FROM events WHERE id = '{$eid}' and user = '{$euser}'") or die(mysql_error()); You should probably also echo the query string you are trying to run and see how it looks like.. before you run the query echo "SELECT * FROM events WHERE id = '{$eid}' and user = '{$euser}'"; Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted August 19, 2009 Share Posted August 19, 2009 well first off, you don't need to wrap your variables in curly brackets unless they are arrays I think. also change your query to $query = mysql_query("SELECT * FROM events WHERE id = '{$eid}' and user = '{$euser}'"); or die(mysql_error()); there is obviously an error occuring, that will show what it is. Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 19, 2009 Author Share Posted August 19, 2009 I'm not getting the error anymore, but it still doesn't pass when it's suppose to... Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 19, 2009 Author Share Posted August 19, 2009 So this is the current updated code. I'm not getting any sql error, but it hops to else statement when it really should pass the if statement... any ideas? $eid = $_GET['ID']; $euser = $_SESSION['USER']; $query = mysql_query("SELECT * FROM events WHERE id = '$eid' and user = '$euser'") or die(mysql_error()); if (mysql_num_rows($query) == 1){ $editinfo = mysql_fetch_assoc($query); } else { echo "You cannot edit that particular event, you may only edit events you've created."; } thanks, 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.