schoolbag Posted September 11, 2008 Share Posted September 11, 2008 <? include("../include/session.php") $q = "SELECT username,points FROM users WHERE username='" . $username . "'"; $result = $database->query($q); if(!$result || ($num_rows < 0)){ echo "Error displaying info"; return; } if($num_rows == 0){ echo "Database table empty"; return; } for($i=0; $i<$num_rows; $i++){ $existingpoints = mysql_result($result,$i,"points"); $points = $existingpoints + $addpoints; echo = "$points"; ?> Is there anything wrong with this code? Every time I try to execute it, I get this error message: Parse error: syntax error, unexpected T_VARIABLE in /home/levente/public_html/site/test/admin/processpoints.php on line 4 Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/123791-problem-with-sql-no-2/ Share on other sites More sharing options...
448191 Posted September 11, 2008 Share Posted September 11, 2008 Missing a semicolon after include("../include/session.php"). Read this to prevent this type of thing in the future: http://www.phpfreaks.com/tutorial/debugging-a-beginners-guide Quote Link to comment https://forums.phpfreaks.com/topic/123791-problem-with-sql-no-2/#findComment-639171 Share on other sites More sharing options...
schoolbag Posted September 11, 2008 Author Share Posted September 11, 2008 Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/123791-problem-with-sql-no-2/#findComment-639172 Share on other sites More sharing options...
schoolbag Posted September 11, 2008 Author Share Posted September 11, 2008 Do you think there is something wrong with the server? When I try to post this form: <html> <head> <title>Add points</title> </head> <body> <form action="processpoints.php" method=post> <b>Username: </b><input type="text" name="korisnickoime" size=30> <br /><br /> <b>How many points would you like to add: </b><input type="text" name="addpoints" size=5> <br /><br /> <input type=submit> </form> </body> </html> To this PHP: <p><?=$korisnickoime ?></p> <br /><br /> <p><?=$points ?></p> And it does not display anything. Quote Link to comment https://forums.phpfreaks.com/topic/123791-problem-with-sql-no-2/#findComment-639181 Share on other sites More sharing options...
MatthewJ Posted September 11, 2008 Share Posted September 11, 2008 Should be fine as long as you are setting the variables to the posted data like <?php $korisnickoime = $_POST['korisnickoime']; $points = $_POST['addpoints']; ?> before displaying them. Quote Link to comment https://forums.phpfreaks.com/topic/123791-problem-with-sql-no-2/#findComment-639189 Share on other sites More sharing options...
KevinM1 Posted September 11, 2008 Share Posted September 11, 2008 Do you think there is something wrong with the server? Nope, your code is just wrong. First, in your HTML, put quotes around the word post: <form action="processpoints.php" method="post"> Then in your PHP, try: <p><?php echo $_POST['korisnickoime']; ?></p> <br /><br /> <p><?php echo $_POST['points']; ?></p> Quote Link to comment https://forums.phpfreaks.com/topic/123791-problem-with-sql-no-2/#findComment-639191 Share on other sites More sharing options...
schoolbag Posted September 11, 2008 Author Share Posted September 11, 2008 Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/123791-problem-with-sql-no-2/#findComment-639195 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.