PDA

View Full Version : Please help with simple PHP/MySQL script!


Derek Zoolander
04-16-2007, 03:07 AM
I'm trying to write a simple script to submit a name and email into a table titled 'name.'
I'm getting this error:
Parse error: syntax error, unexpected T_STRING in home/media224/public_html/name.php on line 3

Here are the files I'm using:
name.html

<HTML>
<BODY>
<h2><font color="blue">Enter Player Name</font></h2>
<font size="2">
<i>To begin the game, please enter all fields below.</i></font><br>
<hr>
<form method="post" action="name.php">
<br>
Name <input type="text" name="name"><br>
Email <input type="text" name="email"><br>
<br>
<input type="submit" value="Submit Name">
<br>
</form>
</BODY>
</HTML>


name.php - x's are my host, username, and password

<?php
$link = mysql_connect(“xxxxx”, “xxxxx”, “xxxxx”) or die(“connect
error:”.mysql_error());
Print “successfully connected.\n”;
$db = “xxxxx”;
mysql_select_db($db, $link) or die(“select DB error:”.mysql_error());
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$result = mysql_query(“INSERT INTO name VALUES ('$name','$email')”);
print “<br><br>One record has been entered into name table<br>”;
mysql_close($link);
?>


TIA

nikkiH
04-16-2007, 03:18 PM
You have a table with the name "name"? Watch out for reserved words. You may want to quote it as `name` instead.

That said, check values being passed for things like apostrophes and quotes. You aren't checking anything here, so you're open to some interesting script hacks.

Lastly, if you still can't find it, make sure that line 3 here that you posted really is line 3. The error is saying that line 3 has a string where something else was expected, so you're either missing a semi-colon, have parenthesis mis-matched, or you have an apostrophe in the input somewhere. At least those are my best guesses, without being sure line 3 up there really is line 3 of the code.

Derek Zoolander
04-28-2007, 08:53 PM
Sorry, I forgot to reply. I got it working. Thanks bro!

rafiki
04-28-2007, 08:56 PM
well post your solution for people with this problem as a future reference!