almightyegg Posted August 1, 2007 Share Posted August 1, 2007 I'm getting this error: Parse error: syntax error, unexpected T_VARIABLE in /home/lordofth/public_html/player/viewfind.php on line 75 $ac2 = mysql_query("SELECT * FROM users WHERE username LIKE '%$account%'") or die(mysql_error()); $ac2 = mysql_num_rows($ac2) or die(mysql_error()); // unrelated code. $accounts = mysql_fetch_array($ac2) $ID = $accounts['id']; // LINE 75 header("Location: view.php?id=$ID"); Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/ Share on other sites More sharing options...
wildteen88 Posted August 1, 2007 Share Posted August 1, 2007 Add a semi-colon at the end of line 74: $accounts = mysql_fetch_array($ac2); Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312883 Share on other sites More sharing options...
almightyegg Posted August 1, 2007 Author Share Posted August 1, 2007 oops oh yeah NowI have another error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/lordofth/public_html/player/viewfind.php on line 48 <? while($accounts = mysql_fetch_array($ac2)){ //line 48 ?> Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312888 Share on other sites More sharing options...
almightyegg Posted August 1, 2007 Author Share Posted August 1, 2007 $ac2 is defined here: $ac2 = mysql_query("SELECT * FROM users WHERE username LIKE '%$account%'") or die(mysql_error()); $ac2 = mysql_num_rows($ac2) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312906 Share on other sites More sharing options...
wildteen88 Posted August 1, 2007 Share Posted August 1, 2007 This line is overriding the result resource and is causing the error: $ac2 = mysql_num_rows($ac2) or die(mysql_error()); Either remove it or change $ac2 to a different variable name. Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312908 Share on other sites More sharing options...
almightyegg Posted August 1, 2007 Author Share Posted August 1, 2007 Still the same error when I change it to this: $acc = mysql_query("SELECT * FROM users WHERE username LIKE '%$account%'") or die(mysql_error()); $ac2 = mysql_num_rows($acc); Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312914 Share on other sites More sharing options...
DeepakJ Posted August 1, 2007 Share Posted August 1, 2007 Make sure that query exists in your table. Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312917 Share on other sites More sharing options...
wildteen88 Posted August 1, 2007 Share Posted August 1, 2007 mysql_fetch_array requires the result resource from mysql_query not mysql_num_rows $ac2 = mysql_query("SELECT * FROM users WHERE username LIKE '%$account%'") or die(mysql_error()); $accounts = mysql_fetch_array($ac2); $ID = $accounts['id']; header("Location: view.php?id=$ID"); Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312922 Share on other sites More sharing options...
almightyegg Posted August 1, 2007 Author Share Posted August 1, 2007 Oops, yep that is sorted now just one last thing. Warning: Cannot modify header information - headers already sent by (output started at /home/lordofth/public_html/player/db.php:10) in /home/lordofth/public_html/player/viewfind.php on line 76 The header is made after the <html> is closed... and it is not in the same if/else statement as any <html> tags anyway... why does it show the error? Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312929 Share on other sites More sharing options...
wildteen88 Posted August 1, 2007 Share Posted August 1, 2007 Oooh more errors! You have output on line10 in db.php. What is line 10. Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312937 Share on other sites More sharing options...
almightyegg Posted August 1, 2007 Author Share Posted August 1, 2007 ?> = line 10 ??? Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312944 Share on other sites More sharing options...
wildteen88 Posted August 1, 2007 Share Posted August 1, 2007 Is there anything after ?> There is most probably a space or even a new line there. Remove any thing after the closing tag. Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-312950 Share on other sites More sharing options...
almightyegg Posted August 1, 2007 Author Share Posted August 1, 2007 Ohh there was 1 space. It works now. Thanks for th help Quote Link to comment https://forums.phpfreaks.com/topic/62854-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-313042 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.