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? Link to comment https://forums.phpfreaks.com/topic/221125-unexpected-t_string-error/ 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'"; } Link to comment https://forums.phpfreaks.com/topic/221125-unexpected-t_string-error/#findComment-1144952 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. Link to comment https://forums.phpfreaks.com/topic/221125-unexpected-t_string-error/#findComment-1144956 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 Link to comment https://forums.phpfreaks.com/topic/221125-unexpected-t_string-error/#findComment-1144968 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.