Reguser Problem

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
Nexus
Posts: 293
Joined: Sat Jun 18, 2011 10:42 pm

Reguser Problem

Post by Nexus »

Well I made my own reguser after kind of coming up with my own coding style and when I submit my things in register I keep getting parse errors like this
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\stillstanding\reguser.php on line 17
I checked that line but I can't see anything wrong with it but here is my code

Code: Select all

<?php
include_once 'connect.php';
?>
<?php
include 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="reguser" align="center">
<?php
$player=$_GET['player'];
$password=$_GET['password'];
$pass2=$_GET['pass2'];
$email=$_GET['email'];

if($email == "")
{
    echo "You did not enter an email!<br/><a href="register.php"><input type="submit" value="Go Back" name="submit" />";
    exit;
}
if($pass2 != $password)
{
    echo "Your passwords did not match!<br/><a href="register.php"><input type="submit" value="Go Back" name="submit" />";
    exit;
}
if($player == "")
{
    echo "You did not enter a username!<br/><a href="register.php"><input type="submit" value="Go Back" name="submit" />";
    exit;
}
if ($password == "")
{
    echo "You did not enter a password!<br/><a href="register.php"><input type="submit" value="Go Back" name="submit" />";
    exit;
}
if($pass2 == "")
{
    echo "You did not retype your password!?<br/><a href="register.php"><input type="submit" value="Go Back" name="submit" />";
    exit;
}
if($password == $pass2)
{
    $isplayer="SELECT * from players where name='$player'";
    $isplayer2=mysql_query($isplayer) or die("Could not get players");
    $isplayer3=mysql_fetch_array($isplayer2) or die("Could not get array");
}
if($isplayer3)
{
    echo "There is already someone with that name!<br/><a href="register.php"><input type="submit" value="Go Back" name="submit" />";
    exit;
}
else
{
    $password=md5($password);
    $mysql="INSERT into players(name, password, email, level, exper, hpoints, attack, defence, damage) VALUES ($name, $password,                             $email, 1, 0, 30, 5, 5, 5)";
    mysql_query($mysql) or die("Could not update players");
    echo "Thanks for registering!<br/><a href="login.php"><input type="submit" value="Login" name="submit" />";
}
?>
Tim
Posts: 37
Joined: Fri Jun 10, 2011 12:49 am

Re: Reguser Problem

Post by Tim »

Hello Nexus,

I will try and help, but I am just learning myself.

If I remember correctly, I believe when you echo a line that would normally have quotation marks in HTML, you use single quotation marks instead so php doesn't mistake it as an end of a string.

For instance, let's try changing:

Code: Select all

if($email == "")
{
    echo "You did not enter an email!<br/><a href="register.php"><input type="submit" value="Go Back" name="submit" />";
    exit;
}
to

Code: Select all

if($email == "")
{
    echo "You did not enter an email!<br/><a href='register.php'><input type='submit' value='Go Back' name='submit' />";
    exit;
}
Let me know if that works. :)
User avatar
Nexus
Posts: 293
Joined: Sat Jun 18, 2011 10:42 pm

Re: Reguser Problem

Post by Nexus »

that fixed my parse errors :D but now my problem is with mysql connecting
Here are my errors

Code: Select all

Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www\stillstanding\connect.php on line 6
Call Stack
#	Time	Memory	Function	Location
1	0.0009	687984	{main}( )	..\reguser.php:0
2	0.0012	692800	include_once( 'C:\wamp\www\stillstanding\connect.php' )	..\reguser.php:2
3	0.0201	699656	mysql_connect ( )	..\connect.php:6

( ! ) Warning: mysql_connect() [function.mysql-connect]: [2002] php_network_getaddresses: getaddrinfo failed: No such host is kn (trying to connect via tcp://standing:3306) in C:\wamp\www\stillstanding\connect.php on line 6
Call Stack
#	Time	Memory	Function	Location
1	0.0009	687984	{main}( )	..\reguser.php:0
2	0.0012	692800	include_once( 'C:\wamp\www\stillstanding\connect.php' )	..\reguser.php:2
3	0.0201	699656	mysql_connect ( )	..\connect.php:6

( ! ) Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www\stillstanding\connect.php on line 6
Call Stack
#	Time	Memory	Function	Location
1	0.0009	687984	{main}( )	..\reguser.php:0
2	0.0012	692800	include_once( 'C:\wamp\www\stillstanding\connect.php' )	..\reguser.php:2
3	0.0201	699656	mysql_connect ( )
Tim
Posts: 37
Joined: Fri Jun 10, 2011 12:49 am

Re: Reguser Problem

Post by Tim »

Can you post your connect.php code please?
User avatar
Nexus
Posts: 293
Joined: Sat Jun 18, 2011 10:42 pm

Re: Reguser Problem

Post by Nexus »

Here it is

Code: Select all

<?php

$db=mysql_connect("localhost","root","") or die("Could not connect");
if(!$db)
die("Cannot connect to database");
if(!mysql_connect("standing","$db"))
die("No database selected");

?>
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Reguser Problem

Post by hallsofvallhalla »

Code: Select all

echo "You did not enter an email!<br/><a href="register.php"><input type="submit" value="Go Back" name="submit" />";
As mentioned above You are breaking your echo with "

Should be

Code: Select all

echo "You did not enter an email!<br/><a href='register.php'><input type='submit' value='Go Back' name='submit' />";
Echo entails everything inside of the quotes. If you break that you need to concatenate it with . then it goes to PHP code.


is it set to localhost?

how about you post your connect.php
User avatar
Nexus
Posts: 293
Joined: Sat Jun 18, 2011 10:42 pm

Re: Reguser Problem

Post by Nexus »

I posted it above if you haven't already seen it.
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Reguser Problem

Post by hallsofvallhalla »

Is your WAMP icon green?

is your DB named standing?
User avatar
Nexus
Posts: 293
Joined: Sat Jun 18, 2011 10:42 pm

Re: Reguser Problem

Post by Nexus »

Yes it is green and yes it is named standing.
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Reguser Problem

Post by hallsofvallhalla »

Nexus wrote:Here it is

Code: Select all

<?php

$db=mysql_connect("localhost","root","") or die("Could not connect");
if(!$db)
die("Cannot connect to database");
if(!mysql_connect("standing","$db"))
die("No database selected");

?>
should be

Code: Select all

$db = mysql_connect("localhost", "root", "") or die("Could not connect.");
if(!$db) 
	die("no db");
if(!mysql_select_db("standing",$db))
 	die("No database selected."); 
Post Reply

Return to “Beginner Help and Support”