jeff5656 Posted December 9, 2010 Share Posted December 9, 2010 I have looked really carefully at this code and can't uderstand why i am getting the unexpected T_STRING error: $qq = "select * from pts where v1 like '$lname%' and user_id = '". $userarray['id'] ."'"; $rr = mysql_query($qq) or die (mysql_error()); In the pts table there is a field called v1 and user_id. Also the value of $lname is often blank but that shouldn't give me an error right? Quote Link to comment Share on other sites More sharing options...
litebearer Posted December 9, 2010 Share Posted December 9, 2010 Being old fart, I hate double and single quotes, that said perhaps try... $user_id = $userarray['id']; if(strlen(trim($lname))<1){ $qq = "select * from pts where user_id = 'user_id'"; }else{ $qq = "select * from pts where v1 like '$lname%' and user_id = '$user_id'"; } Quote Link to comment Share on other sites More sharing options...
jeff5656 Posted December 9, 2010 Author Share Posted December 9, 2010 UGH! Here was my problem: I had $num mysql_num_rows($rr); instead of $num = mysql_num_rows($rr); But the error was referring to the query line 2 lines above the $num, so I couldnt figure it out. Quote Link to comment Share on other sites More sharing options...
Maq Posted December 9, 2010 Share Posted December 9, 2010 Just a side note, for handling errors, specifically mysql ones in your case, read this - http://www.phpfreaks.com/blog/or-die-must-die 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.