Jump to content

Another form problem


blink359

Recommended Posts

The error is: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/nathan/unstuck.php on line 16

 

from my form:

<?php
include("config.php");
mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
$user = $_POST['user'];
$pass = $_POST['pass'];
$character = $_POST['character'];
{     
     if(!$user || !$pass || !$character)
     {
         $problemMessage = "Please fill in all required fields";
         $success = false;
     }
     if($success);
     {
         $result = mysql_query "SELECT acct FROM accounts WHERE login = '".$account."' AND password = '".$password."'";
         or die(mysql_error());
         $numrows = mysql_num_rows($result);
     }
 else
 {
         die("Account name or password is incorrect");
     }

     $result = mysql_query "update characters SET positionX = 16237, positionY = 16396, positionZ = 60, mapId = 1, zoneId = 0, deathstate = 0 WHERE name = '".$character."'" or die(mysql_error());
     echo "Character '".$character."' has been unstuck!";
     mysql_close();
?>
<html>
<head>
<title>Auto Unstucker</title>
</head>
<body>
<center>
<form name=myform method=post action='unstucker.php'>
<center><h1>Character Unstucker</h1></center>
Account Name:<input type=text name=account value=''><br>
Character Name:<input type=text name=character value=''><br>
Password:<input type=password name=password value=''><br>
<br><input type=submit name=submit value=Unstuck><br>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/155732-another-form-problem/
Share on other sites

<?php
include("config.php");
mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
$user = $_POST['user'];
$pass = $_POST['pass'];
$character = $_POST['character'];
    
     if(!$user || !$pass || !$character)
     {
         $problemMessage = "Please fill in all required fields";
         $success = false;
     }
     if($success)
     {
         $result = mysql_query "SELECT acct FROM accounts WHERE login = '".$account."' AND password = '".$password."'"
         or die(mysql_error());
         $numrows = mysql_num_rows($result);
     }
 else
 {
         die("Account name or password is incorrect");
     }

     $result = mysql_query "update characters SET positionX = 16237, positionY = 16396, positionZ = 60, mapId = 1, zoneId = 0, deathstate = 0 WHERE name = '".$character."'" or die(mysql_error());
     echo "Character '".$character."' has been unstuck!";
     mysql_close();
?>
<html>
<head>
<title>Auto Unstucker</title>
</head>
<body>
<center>
<form name=myform method=post action='unstucker.php'>
<center><h1>Character Unstucker</h1></center>
Account Name:<input type=text name=account value=''><br>
Character Name:<input type=text name=character value=''><br>
Password:<input type=password name=password value=''><br>
<br><input type=submit name=submit value=Unstuck><br>
</form>
</body>
</html>

still Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/nathan/unstuck.php on line 16

Link to comment
https://forums.phpfreaks.com/topic/155732-another-form-problem/#findComment-819719
Share on other sites

Umm, you have forgotten to wrap your query in parenthesis's when you call mysql_query on lines 16 and 25

 

The correct syntax for using mysql_query is

$result = mysql_query('your query here');

 

Not

$result = mysql_query 'your query here';

Link to comment
https://forums.phpfreaks.com/topic/155732-another-form-problem/#findComment-819722
Share on other sites

    }

 

    $result = mysql_query("update characters SET positionX = 16237, positionY = 16396, positionZ = 60, mapId = 1, zoneId = 0, deathstate = 0 WHERE name = '".$character."'"); or die(mysql_error());

    $numrows = mysql_num_rows($result);

    }

 

Parse error: syntax error, unexpected T_LOGICAL_OR in /var/www/nathan/unstuck.php on line 24

Link to comment
https://forums.phpfreaks.com/topic/155732-another-form-problem/#findComment-819744
Share on other sites

Do you not understand what I did to fix that issue?

 

I mean come on now...

 

$result = mysql_query("update characters SET positionX = 16237, positionY = 16396, positionZ = 60, mapId = 1, zoneId = 0, deathstate = 0 WHERE name = '".$character."'") or die(mysql_error());
     $numrows = mysql_num_rows($result);

 

I would hope that you are able to fix the others yourself, given that all I did was remove the semicolon before the or die statement.

Link to comment
https://forums.phpfreaks.com/topic/155732-another-form-problem/#findComment-819754
Share on other sites

<?php
$dbhost = "localhost"; 
$dbuser = "nathan"; 
$dbpass = "your_password"; 
$dbname = "logon"; 
mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
$user = $_POST['user'];
$pass = $_POST['pass'];
$character = $_POST['character'];
    
     if(!$user || !$pass || !$character)
     {
         $problemMessage = "Please fill in all required fields";
         $success = false;
     }
     if($success)
     {
         $result = mysql_query("SELECT acct FROM accounts WHERE login = '".$account."' AND password = '".$password."'") or die(mysql_error());
         $numrows = mysql_num_rows($result);
     }
 else
 {
         die("Account name or password is incorrect");
     }

     $result = mysql_query("update characters SET positionX = 16237, positionY = 16396, positionZ = 60, mapId = 1, zoneId = 0, deathstate = 0 WHERE name = '".$character."'") or die(mysql_error());
     $numrows = mysql_num_rows($result);
     
     echo "Character '".$character."' has been unstuck!";
     mysql_close();
?>
<html>
<head>
<title>Auto Unstucker</title>
</head>
<body>
<center>
<form name=myform method=post action='unstucker.php'>
<center><h1>Character Unstucker</h1></center>
Account Name:<input type=text name=account value=''><br>
Character Name:<input type=text name=character value=''><br>
Password:<input type=password name=password value=''><br>
<br><input type=submit name=submit value=Unstuck><br>
</form>
</body>
</html>

its now just          die("Account name or password is incorrect");

Link to comment
https://forums.phpfreaks.com/topic/155732-another-form-problem/#findComment-819758
Share on other sites

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.