Jump to content

[SOLVED] problem with sql with get and user.


Eggzorcist

Recommended Posts

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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}'";

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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,

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.