Jump to content

Problem with SQL (No. 2)


schoolbag

Recommended Posts

<?
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!

Link to comment
https://forums.phpfreaks.com/topic/123791-problem-with-sql-no-2/
Share on other sites

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.

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.