sgt_fireman Posted July 26, 2012 Share Posted July 26, 2012 Hey guys, I'm kind of new to PHP so it's probablly something simple, My error is this Parse error: syntax error, unexpected '{', expecting '(' in /home/xxxxxxxx/public_html/files/x/return.php on line 36 on line 36 there is this, $A = $m['A']; $e = $m['e']; // LINE 36 HERE if ($F >= $AV) { $F2 = $F - $e; mysql_query("UPDATE Users SET F=$F2 WHERE id = '$DI'") or die(mysql_error()); $done = 1; } if($A >= $e and $done == 0) { $A2 = $A - $e; mysql_query("UPDATE Users SET A=$A2 WHERE id = '$DI'") or die(mysql_error()); } So I'm not really sure what's wrong, I've checked a few sites and I think I'm using the right syntax? Thanks very much guys! Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/ Share on other sites More sharing options...
jazzman1 Posted July 26, 2012 Share Posted July 26, 2012 Where is line 36 ? There is no syntax error in this file. What's the name of the file ? Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364661 Share on other sites More sharing options...
sgt_fireman Posted July 26, 2012 Author Share Posted July 26, 2012 It's the one with the comment on, $e = $m['e']; // LINE 36 HERE Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364663 Share on other sites More sharing options...
sgt_fireman Posted July 26, 2012 Author Share Posted July 26, 2012 And It's named return.php, Thanks for replying by the way Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364667 Share on other sites More sharing options...
jazzman1 Posted July 26, 2012 Share Posted July 26, 2012 Have you included any others files to this one ? Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364669 Share on other sites More sharing options...
sgt_fireman Posted July 26, 2012 Author Share Posted July 26, 2012 Just a config.php and that contains no syntax erros config.php <?php mysql_connect("localhost", "XXXX", "XXXX") or die(mysql_error()); mysql_select_db("XXXX") or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364672 Share on other sites More sharing options...
jazzman1 Posted July 26, 2012 Share Posted July 26, 2012 Copy/paste entire return.php script. Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364678 Share on other sites More sharing options...
sgt_fireman Posted July 26, 2012 Author Share Posted July 26, 2012 <?php session_start(); include ("../config.php"); mysql_query("UPDATE statistics SET views=views+1 WHERE id = 1") or die (mysql_error()); include ("../config2.php"); $ADI = $_SESSION['ADI']; $y = mysql_query("SELECT SiteURL FROM Users WHERE UID='$DI'") or die(mysql_error()); $z = mysql_fetch_array( $y ); $SITE = $z['SiteURL']; $SITE2 = 'http://' . $SITE . ''; $IP = $_SERVER['REMOTE_ADDR']; $namef = "counter.txt"; $handlef = fopen($namef, 'r') or die ("zero"); $counter = fread($handlef, filesize($namef)); fclose ($handlef); $counter = $counter + 1; $namef2 = "counter.txt"; $handlef2 = fopen($namef2, 'w') or die ("zero"); fwrite($handlef2, $counter); fclose ($handlef2); $final = $counter . ")" . $IP . "<br />"; $name = "iplist.html"; $handle = fopen($name, 'a') or die ("0"); fwrite ($handle, $final); fclose ($handle); $DI = $_SESSION['DI']; $p = mysql_query("SELECT * FROM Users WHERE id = '$DI'") or die(mysql_error()); $m = mysql_fetch_array( $p ); $F = $m['F']; $A = $m['A']; $e = $m['e']; // LINE 36 HERE if ($F >= $AV) { $F2 = $F - $e; mysql_query("UPDATE Users SET F=$F2 WHERE id = '$DI'") or die(mysql_error()); $done = 1; } if($A >= $e and $done == 0) { $A2 = $A - $e; mysql_query("UPDATE Users SET A=$A2 WHERE id = '$DI'") or die(mysql_error()); } header("location: $SITE2"); ?> There you go:) I'm prittey sure there is no syntax errors however Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364682 Share on other sites More sharing options...
Jessica Posted July 26, 2012 Share Posted July 26, 2012 In the future, indent your code properly and use descriptive variable names. This is a bitch to read. Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364688 Share on other sites More sharing options...
jazzman1 Posted July 26, 2012 Share Posted July 26, 2012 What code you have inside "config2.php" ? If you remove line 36, what's happen ? Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364691 Share on other sites More sharing options...
Jessica Posted July 26, 2012 Share Posted July 26, 2012 http://us2.php.net/manual/en/language.operators.comparison.php Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364695 Share on other sites More sharing options...
sgt_fireman Posted July 26, 2012 Author Share Posted July 26, 2012 Ahh thanks jazzman, I removed line 36 and It told me that I had named something wrong, I've changed it and re-added line 36 and It's working fine! Thank-you very much! Quote Link to comment https://forums.phpfreaks.com/topic/266300-if-command-not-working/#findComment-1364700 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.