ohdang888 Posted December 25, 2008 Share Posted December 25, 2008 i am getting this error: Parse error: syntax error, unexpected T_VARIABLE in /home/socialap/public_html/posters/include/rating_system/rate.php on line 1 from this code: connect.php has no errors... i've already tested it. Maybe i'm just blind, but i can't seem to find out why i would ever get this error!?!? thanks. <?php include('../../connect.php'); $id = mysql_real_escape_string($_GET['id']); $rating = mysql_real_escape_string($_GET['rating']); if(empty($id) or empty($rating) or $rating > 5){ die("Invalid poster/no rating"); } Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/ Share on other sites More sharing options...
kucerar Posted December 25, 2008 Share Posted December 25, 2008 try in-lining it. ??? Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723719 Share on other sites More sharing options...
.josh Posted December 25, 2008 Share Posted December 25, 2008 that's all you have in the file, and that file isn't being included anywhere? Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723727 Share on other sites More sharing options...
Yesideez Posted December 26, 2008 Share Posted December 26, 2008 First of all, this is wrong: if(empty($id) or empty($rating) or $rating > 5){ die("Invalid poster/no rating"); } There is no "or" with PHP - use these instead... || OR (two "bar" symbols) && AND != Not equals to == Equals to So your code should read: if(empty($id) || empty($rating) || $rating > 5){ die("Invalid poster/no rating"); } That's probably not the error but worth pointing out. It's worth also having a look at "connect.php" and make sure the code there is correct. Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723743 Share on other sites More sharing options...
.josh Posted December 26, 2008 Share Posted December 26, 2008 First of all, this is wrong: if(empty($id) or empty($rating) or $rating > 5){ die("Invalid poster/no rating"); } There is no "or" with PHP - use these instead... || OR (two "bar" symbols) && AND != Not equals to == Equals to So your code should read: if(empty($id) || empty($rating) || $rating > 5){ die("Invalid poster/no rating"); } That's probably not the error but worth pointing out. It's worth also having a look at "connect.php" and make sure the code there is correct. error says line 1. That condition is at the very least, line 6. It has nothing to do with that line. And FYI, there most certainly is an 'or' in php. and an 'and'. They word exactly like their || and && counterparts, except that they are lower on the order of operation list. http://us3.php.net/manual/en/language.operators.php Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723746 Share on other sites More sharing options...
ohdang888 Posted December 26, 2008 Author Share Posted December 26, 2008 nope..connect .php is just fine... here's the link to that: http://socialapps.sclek.com/posters/include/connect.php and heres the link to rate.php http://socialapps.sclek.com/posters/include/rating_system/rate.php this is soooooooooo weird. the contents of rate.php are exactly, character by character, the same as written above. could this be an error of php malfunctioning? Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723783 Share on other sites More sharing options...
.josh Posted December 26, 2008 Share Posted December 26, 2008 okay, so the url you provided for connect.php is one directory above rate.php but in your script you have double ../'s so you're trying to include http://socialapps.sclek.com/posters/connect.php, which either doesn't exist or is bugged (I got a 404 error on it). Try doing include('../connect.php'); Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723794 Share on other sites More sharing options...
.josh Posted December 26, 2008 Share Posted December 26, 2008 ...though I'm still not sure how that translates to a unexpected T_VARIABLE error... should have gotten a warning from that...well, you could have error reporting off, which would explain not getting the warning, but it still doesn't explain the syntax error.. Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723798 Share on other sites More sharing options...
kenrbnsn Posted December 26, 2008 Share Posted December 26, 2008 Are you sure you're not saving your script with a UTF-8 character set. Try saving it again as plain ASCII. Ken Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723800 Share on other sites More sharing options...
PFMaBiSmAd Posted December 26, 2008 Share Posted December 26, 2008 I'm going to guess the file contains "something" at the beginning that makes php think it is parsing php code. I recommend making a new file and typing in just the bare minimum of the php tags and your include statement to test it. Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723801 Share on other sites More sharing options...
ohdang888 Posted December 26, 2008 Author Share Posted December 26, 2008 ok i've found the problem, but i don't know how to solve it... i'm use FileZilla to upload files, rather than editing them in the browser, because i hate doing that. So in my notepad++ it displays the code as i write it, in differenet lines. But i looked at the file on the server, and it displays it like this: <?php session_start();$head = false;require_once '../../include.php';$id = mysql_real_escape_string($_GET['id']); so the whole thing is on 1 line...which makes it impossible to solve errors. I've tried re-loading the file to get it into different lines, buts it not working... hm, any ideas how to make that automatically go to seperate lines... i don't have this problem in all my other files i uploaded... Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723827 Share on other sites More sharing options...
kenrbnsn Posted December 26, 2008 Share Posted December 26, 2008 Make sure you're uploading your script as ASCII not BINARY. Ken Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723832 Share on other sites More sharing options...
ohdang888 Posted December 26, 2008 Author Share Posted December 26, 2008 how do i do that? thanks Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723954 Share on other sites More sharing options...
PFMaBiSmAd Posted December 26, 2008 Share Posted December 26, 2008 It would be a setting in your FTP client program. Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723955 Share on other sites More sharing options...
kenrbnsn Posted December 26, 2008 Share Posted December 26, 2008 If you're using program to transfer files, you should know how to do that. Just make sure that the ASCII option is checked in the "Transfer" menu: Ken Quote Link to comment https://forums.phpfreaks.com/topic/138412-solved-really-weird-error-can-php-malfunction/#findComment-723957 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.