-2

I am getting the following error: Parse error: syntax error, unexpected end of file in /usr/www/whatsup4/Tool/run.php on line 31

Here is my code:

define('DB_NAME', 'whatsup4_tool');
define('DB_USER', 'whatsup4');
define('DB_PASSWORD', 'xxxxx');
define('DB_HOST', 'localhost');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$link) {
     die('Could not connect: ' . mysql_error());
     }

     $db_selected = mysql_select_db(DB_NAME, $link);

     if (!$db_selected) {
     die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
     }

     $value1 = $_POST['64id'];
     $value2 = $_POST['b64id'];
     $value3 = $_POST['info'];
     $value4 = $_POST['ev'];

     $sql = "INSERT INTO whatsup4_tool (64id, b64id, info, ev) VALUES ('$value', '$value2', 
     '$value3', '$value4');
     mysql_query($sql);

     mysql_close();
?>

Is there anything else I need to add at the end? I have never coded using SQL before. If it is relevant, here is the HTML code:

<form action="run.php" method="post"/>
<p>User's 64 ID: <input type="text" name="64id"/></br>
<p>Your 64 ID: <input type="text" name="b64id"/></br>
<p>Infringement: <input type="text" name="info"/></br>
<p>Evidence: <input type="text" name="ev"/></br>
<input type="submit" value="Submit"/>
</form>
Gamma032
  • 441
  • 4
  • 7
  • 2
    The syntax coloring applied to your code in the question body should give a pretty strong hint as to what's wrong... – Jon May 19 '14 at 08:36
  • Try to use a proper editor to help you. Like `PHPStorm`, `Netbeans`, `ZendStudio` or other – John Priestakos May 19 '14 at 08:37
  • I used Adobe Edge Code to make it, but I just opened it with notepad while I copied it over. I can see my mistake now and how I can avoid it in the future, so thanks. – Gamma032 May 19 '14 at 08:43
  • you might want to take a look at this. http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php?rq=1 cuz sql injection isnt cool.... – cptnk May 19 '14 at 09:52

2 Answers2

2

you missed " (closing double quote) on query close

try replace

$sql = "INSERT INTO whatsup4_tool (64id, b64id, info, ev) VALUES ('$value', '$value2', 
     '$value3', '$value4');

to

$sql = "INSERT INTO whatsup4_tool (64id, b64id, info, ev) VALUES ('$value', '$value2', '$value3', '$value4')";
Rakesh Sharma
  • 13,680
  • 5
  • 37
  • 44
1

You are receiving the error since you have missed a double quote:

This code:

$sql = "INSERT INTO whatsup4_tool (64id, b64id, info, ev) VALUES ('$value', '$value2', 
 '$value3', '$value4')<double-quote-missing>; 

Should be:

$sql = "INSERT INTO whatsup4_tool (64id, b64id, info, ev) VALUES ('$value', '$value2', 
 '$value3', '$value4')";
Kanishk Dudeja
  • 1,201
  • 3
  • 17
  • 33