Page 1 of 1

A parse error, unexpected T_STRING....what?

Posted: Fri Jun 14, 2002 4:24 pm
by XepheX
Hi!
Have som problems with mysql_query()

The code is:

Code: Select all

<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<?PHP
/*Öppna databasen*/
$open = mysql_connect("localhost","*****","*****");

mysql_select_db ("doom")

mysql_query ("INSERT INTO members (un, pw, email) VALUES ('".$_POST&#1111;"un"]."', '".$_POST&#1111;"pw"]."', '".$_POST&#1111;"email"]."')");

mysql_close ($open); &#123;

print "Thanks for register";
&#125; 
?>


<body topmargin="40" leftmargin="100">
<h2>So you wanna be a member?</h2>
<P>
Just fill put the forms below, and then, Have fun!
<p>
<table border="0" cellspacing="0" cellpadding="5" class="field">
  <form action="register.php" method="post"> 
    <tr>
		  <td>Username:</td>
			<td><input type="text" name="un" size="16" maxlength="16" class="box"></td>
		</tr>
		<tr>
		  <td>Password:</td>
			<td><input type="text" name="pw" size="16" maxlength="16" class="box"></td>
		</tr>
		<tr>
		  <td>E-mail:</td>
			<td><input type="text" name="email" size="16" maxlength="64" class="box"></td>
			</tr>
			<tr>
			<td>&nbsp;</td>
			<td align="left"><input type="submit" value="submit" class="field"></td>
		</tr>
	</table>
</form>
<p>
All fields are required!<br />
Note! the e-mail is only if you lost you´re password. No other things will be sent.


</body>
</html>
and the errormsg is:
Parse error: parse error, unexpected T_STRING in C:\Program\Apache Group\Apache2\htdocs\Doom_hell_on_net\register.php on line 13


Hope that you can help me!

XepheX

Posted: Fri Jun 14, 2002 5:02 pm
by volka
simply forgot a ;
mysql_select_db ("doom");

Posted: Fri Jun 14, 2002 5:34 pm
by XepheX
Thanks!
Now its just the variables who are undefined.

i changed the code to:

Code: Select all

mysql_query ("INSERT INTO members (un, pw, email) VALUES ('$un', '$pw' '$email')");
How do i fix that?

Posted: Fri Jun 14, 2002 6:43 pm
by volka
read the sticky thread called 'Please, read this BEFORE posting'.

Posted: Sat Jun 15, 2002 3:41 am
by XepheX
Hi again!

I read the sticky note, and as i can se it should look like this:

Code: Select all

mysql_query ("INSERT INTO members (un, pw, email) VALUES ($_POST&#1111;'un'],$_POST&#1111;'pw'],$_POST&#1111;'email'])");
But it still dosent work.

The errormsg. is:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program\Apache Group\Apache2\htdocs\Doom_hell_on_net\register.php on line 45

Posted: Sat Jun 15, 2002 3:57 am
by volka
you have to 'mark' arrays in string for replacement

Code: Select all

mysql_query ("INSERT INTO members (un, pw, email) VALUES (&#123;$_POST&#1111;'un']&#125;,&#123;$_POST&#1111;'pw']&#125;,&#123;$_POST&#1111;'email']&#125;)");

Posted: Sat Jun 15, 2002 5:36 pm
by XepheX
It´s now working as it supposed to.

Thanks to you all