Status
Not open for further replies.

gamma

Member
11
2012
1
0
there's a syntax error in this mysql statement.. please help.. thanks a ton..

$fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM 'members' WHERE username=".$_SESSION['username'].""));

---------- Post added 16th Apr 2012 at 07:04 AM ---------- Previous post was 15th Apr 2012 at 11:38 AM ----------

bump
 
8 comments
please help me :( I keep getting this error: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/linksnap/public_html/includes.php
 
Instead of 1 big line, try to split it up, so you can identify the error better.

PHP:
$username = $_SESSION['username'];
$mysqlquery = mysql_query("SELECT * FROM members WHERE username='$username'");
$fetch_users_data = mysql_fetch_object($mysqlquery);
 
Instead of 1 big line, try to split it up, so you can identify the error better.

PHP:
$username = $_SESSION['username'];
$mysqlquery = mysql_query("SELECT * FROM members WHERE username='$username'");
$fetch_users_data = mysql_fetch_object($mysqlquery);

Thanks Moggy. But it gives the following error for the last line($fetch_users_data = mysql_fetch_object($mysqlquery);)

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/jaggadak/public_html/includes.php on line 4
 
try this
PHP:
$username = $_SESSION['username'];
echo $username;
$mysqlquery = mysql_query("SELECT * FROM members WHERE username='" . $username ."'");
$fetch_users_data = mysql_fetch_object($mysqlquery);
 
try this:
Code:
$username = $_SESSION['username'];
$sql = mysql_query("SELECT * FROM members WHERE username='" . $username ."'") or die(mysql_error());
$fetch_users_data = mysql_fetch_object($mysqlquery);

will show the mysql error
 
try this
PHP:
$username = $_SESSION['username'];
echo $username;
$mysqlquery = mysql_query("SELECT * FROM members WHERE username='" . $username ."'");
$fetch_users_data = mysql_fetch_object($mysqlquery);

Now it gives the error on line 5 ($fetch_users_data = mysql_fetch_object($mysqlquery);
)

I think the error is because of the function 'mysql_fetch_object' Any ideas?
 
No, i think the error is because the username is empty, try
PHP:
$username = $_SESSION['username']; 
$mysqlquery = mysql_query("SELECT * FROM members WHERE username='" . $username ."'"); 
if ($mysqlquery)
$fetch_users_data = mysql_fetch_object($mysqlquery);
else
die("username=" . $username . " mysql error=" . mysql_error());
 
No, i think the error is because the username is empty, try
PHP:
$username = $_SESSION['username']; 
$mysqlquery = mysql_query("SELECT * FROM members WHERE username='" . $username ."'"); 
if ($mysqlquery)
$fetch_users_data = mysql_fetch_object($mysqlquery);
else
die("username=" . $username . " mysql error=" . mysql_error());

Thanks a lot Moggy its working now love you :D
 
Status
Not open for further replies.
Back
Top