It is currently Thu Mar 28, 2024 10:16 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Fri Aug 10, 2007 12:13 pm 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
did you update

$Query = "SELECT ID FROM #DATABASE TABLE# WHERE username = '$username'";
$Result = mysql_db_query(#DATABASE NAME#, $Query, $Link);

accordingly? everything that is #CAP# is things that need to be changed

_________________
http://www.mjmclocks.co.uk


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 12:24 pm 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
I hadn't but I have now. It now reads

#database table#
#database name#

Yet I still get the error below.

Parse error: parse error, unexpected T_IF, expecting ')' in /home/www/xxxxxx.com/registration2.php on line 9

Regards,
Alan.


Last edited by DumbOne on Fri Aug 10, 2007 12:46 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 12:31 pm 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
on $Result = mysql_db_query(#DATABASE NAME#, $Query, $Link);

change it so it has 'DATABASE NAME'

so its in '

_________________
http://www.mjmclocks.co.uk


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 12:40 pm 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
Getting near the end! It now reads

Parse error: parse error, unexpected T_ECHO, expecting ')' in /home/www/xxxxxx.com/registration2.php on line 16


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 12:46 pm 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
did you make the same changes on the last 2 #CAPS#?

_________________
http://www.mjmclocks.co.uk


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 1:00 pm 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
This is what I now have

<?php
$Link = mysql_connect ('host,'username','password'); //Fill in the details

$username = $_POST['username']; //Gets username
$password = $_POST['password']; //Gets password

$Query = "SELECT ID FROM 'database table' WHERE username = '$username'";
$Result = mysql_db_query('database name', $Query, $Link);
if ($Row = mysql_fetch_array($Result)){
echo "Username already taken"; //Sends Error Message
die(); //Ends Script
}

$Query2 = "INSERT INTO 'database table' VALUES ('', '$username', '$password')";
if ( mysql_db_query('database name', $Query2, $Link)){
echo "Thank you for registering";
}
mysql_close();
?>

And get the message

Parse error: parse error, unexpected T_STRING in /home/www/xxxxxxxx.com/registration2.php on line 2


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 1:12 pm 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
I just noticed I'm missing the ' after host which I have just added.
Now I get the messages;

Warning: mysql_connect(): Unknown MySQL Server Host 'host' (1) in /home/www/xxxxxx.com/registration2.php on line 2

Warning: mysql_db_query(): supplied argument is not a valid MySQL-Link resource in /home/www/xxxxxx.com/registration2.php on line 8

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/xxxxxx.com/registration2.php on line 9

Warning: mysql_db_query(): supplied argument is not a valid MySQL-Link resource in /home/www/xxxxxx.com/registration2.php on line 15

Warning: mysql_close(): no MySQL-Link resource supplied in /home/www/xxxxxx.com/registration2.php on line 18

I'll have to leave it for now, it's 11:15pm and I've had too many late nights.
Thanks for your all help. All going well I'll be back tomorrow.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 1:27 pm 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
well as it doenst know what

host

is, you have to put in your MySQL host!

It will be something like

mysql3.freehostia.com

_________________
http://www.mjmclocks.co.uk


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 11, 2007 8:14 am 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
Josh, I've had a good long stare at the code and have made some minor changes. The code now looks like this;

<?php
$Link = mysql_connect ('mysql3.freehostia.com','my database name','mysql password'); //Fill in the details

$username = $_POST['username']; //Gets username
$password = $_POST['password']; //Gets password

$Query = "SELECT ID FROM 'logintable' WHERE username = '$username'";
$Result = mysql_db_query('my database name', $Query, $Link);
if ($Row = mysql_fetch_array($Result)){
echo "Username already taken"; //Sends Error Message
die(); //Ends Script
}

$Query2 = "INSERT INTO 'logintable' VALUES ('', '$username', '$password')";
if ( mysql_db_query('my database name', $Query2, $Link)){
echo "Thank you for registering";
}
mysql_close();
?>

I'm now getting the error;

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/xxxxxx.com/registration2.php on line 9

I'm unable to work it out, even though I have tried quite a few different code changes.
Thanks Again,
Alan.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 11, 2007 9:13 am 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
Code:
<?php
$Link = mysql_connect ('mysql3.freehostia.com','my database name','mysql password'); //Fill in the details

$username = $_POST['username']; //Gets username
$password = $_POST['password']; //Gets password

$Query = "SELECT ID FROM logintable WHERE username = '$username'";
$Result = mysql_db_query('my database name', $Query, $Link);
echo "Query1: " .  mysql_error(); //Comment out if the script works
if ($Row = mysql_fetch_array($Result)){
echo "Username already taken"; //Sends Error Message
die(); //Ends Script
}

$Query2 = "INSERT INTO logintable VALUES ('', '$username', '$password')";
if ( mysql_db_query('my database name', $Query2, $Link)){
echo "Thank you for registering";
}else{
     echo "Query2: " .  mysql_error(); //Comment out if the script works
}
mysql_close();
?>

_________________
http://www.mjmclocks.co.uk


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 11, 2007 10:14 am 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
I hate being a nuisense but I'm getting another although different error;

Parse error: parse error, unexpected T_STRING in /home/www/xxxx.com/registration2.php on line 15

Give up if you like!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 11, 2007 12:09 pm 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
I'm in luck (almost)! It is now working; the usernames & passwords are loading onto my database, however I can put the same username & password in more than once and there is no message "Username already taken". I get the message below after submitting if I use a username once or twice. I have entered six, two being the same. As you can see the last username I entered was "me".

Query1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'username = 'me'' at line 1
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/xxxxx.com/registration2.php on line 10
Thank you for registering

That's it for tonight, Alan.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Moderators: Moderators, Support Team Go to page Previous  1, 2

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Hosting | Domains | Servers | Extras | Order | Support | Contacts | FreeHostia © 2011