Page 1 of 1

PHP syntax error when testing registration system

Posted: Mon Sep 22, 2008 12:54 am
by runrunforest
This is the error message:

Parse error: syntax error, unexpected '`' in C:\wamp\www\register\Untitled-7.php on line 13

What can i do to make this work?

This is my code:

Code: Select all

<?php
$congig['adress']='localhost';
$congig['username']='craig';
$config['password']='porschegt3';
$config['databsename']='regtut';
 
mysql_connect($config['address'],$config['username'],$congifg['password']);
mysql_select_db($config['databsename']);
 
if ($_POST['submit']) {
 $_POST['username'] = trim($_POST['username']);
if($_POST['username'] && strlen($_POST['username']) >= 3){
$query = mysql_query(”SELECT `id` FROM `users` WHERE `username`=”.$_POST['username'].”‘ LIMIT 1?);
if(mysql_num_rows($query)){
$error['userexists'] = ‘Username exists’;
}
} else {
$error['usernameinput'] = ‘Please enter a username of 3+ characters’;
} 
}
?>
<form name=”reg” method=”post” enctype=”application/x-www-form-urlencoded”>
username: <input type=”text” name=”username” /><br />
email: <input type=”text” name=”email” /><br />
password1: <input type=”password” name=”password1? /><br/>
password2: <input type=”password” name=”password2? /><br/>
<input type=”submit” name=”submit” value=”register” />
</form>

Re: PHP syntax error when testing registration system

Posted: Mon Sep 22, 2008 1:00 am
by wolfwood16

Code: Select all

$query = mysql_query(”SELECT `id` FROM `users` WHERE `username`=”.$_POST['username'].”‘ LIMIT 1?);
change it with this one.

Code: Select all

$query = mysql_query("SELECT id FROM users WHERE username = ".$_POST['username']." LIMIT 1");

Re: PHP syntax error when testing registration system

Posted: Mon Sep 22, 2008 1:24 am
by runrunforest
followed that then this appears

Parse error: syntax error, unexpected T_STRING in C:\wamp\www\register\Untitled-7.php on line 15

Re: PHP syntax error when testing registration system

Posted: Mon Sep 22, 2008 1:39 am
by wolfwood16
use only single qoute ' or double qoute " using echo.

change it to...

Code: Select all

if(mysql_num_rows($query)){
      $error['userexists'] = "Username exists";
}
the same it other statements..

Re: PHP syntax error when testing registration system

Posted: Mon Sep 22, 2008 2:51 am
by runrunforest
then this error

Parse error: syntax error, unexpected T_STRING in C:\wamp\www\register\Untitled-7.php on line 18

Re: PHP syntax error when testing registration system

Posted: Mon Sep 22, 2008 2:56 am
by wolfwood16
runrunforest wrote:then this error

Parse error: syntax error, unexpected T_STRING in C:\wamp\www\register\Untitled-7.php on line 18

read my previous reply :)