Jump to content

PHP Code Help Admin check


devangel

Recommended Posts

never mind about that one guys, stuck on this:

 

im trying to make an array to store all my users info so i can display it.

 

$data = mysql_query("SELECT * FROM users where userid="$_SESSION['SESS_USERID']) or die(mysql_error());

$usr = mysql_fetch_array( $data );

 

 

this is my code so far. i can pull info from the database, but i edited it with "where userid=$_SESSION['SESS_USERID']}"

to get the users id from my session.

 

but it still doesn't work, this code is located in my config file so i can reference it onto other files.

 

 

Link to comment
Share on other sites

Did you try to echo out the sql statement? Do that and see what is being filled in for your session value, and then copy/paste that into your MySQL interface and see if you get results.

 

Right now, from your statement, I see that you may want to try and escape your "" and that you aren't ending the last quote correctly:

mysql_query("SELECT * FROM users where userid="$_SESSION['SESS_USERID'])

to

mysql_query("SELECT * FROM users WHERE userid = '".$_SESSION['SESS_USERID']."'")

 

Link to comment
Share on other sites

tried that:

 

$data = mysql_query("SELECT * FROM users WHERE userid = '".$_SESSION['SESS_USERID']."'")) or die(mysql_error());

$usr = mysql_fetch_array( $data );

 

and got this parse error:

 

 

Parse error: parse error in C:\wamp\www\hero\game\includes\config.php on line 43

 

which is clean

 

function clean($str)

{

if (is_numeric($str)) $str=floor($str);

$cleaned=strip_tags($str);

$cleaned=htmlspecialchars($cleaned);

$cleaned=mysql_real_escape_string($cleaned);

$to_clean=array("%20", "\"", "'", "\\", "=", ";", ":");  <-- 43

$cleaned=str_replace($to_clean, "", $cleaned);

return $cleaned;

}

Link to comment
Share on other sites

$data = mysql_query("SELECT * FROM users WHERE userid = '".$_SESSION['SESS_USERID']."'")) or die(mysql_error());

 

extra ) at the end of your query (before the "or die") part. Did you try to echo out the whole query (ie, between the $data =... and the $user =... you put a die($data);) and see if it successfully executes in MySQL?

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.