It is currently Tue Mar 19, 2024 6:47 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 1, 2  Next
Author Message
 Post subject: Code Fault? or me!
PostPosted: Fri Aug 10, 2007 3:43 am 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
I have found a post "Account Script" from 22 March 2007 that Josh Waller replied to that has helped me out greatly so far. I'm very new at this html, php etc so go easy on me!
I couldn't get "registration2.php" to work and amazingly discovered that the <?php tag was missing from the start. I added the tag and when I click on "Register" I get directed to a new page with the message;

Parse error: parse error, unexpected ';' in /home/www/xxxxxxxxx.com/registration2.php on line 4

What does that mean?

Thanks,
Alan.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 7:22 am 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
that means you have made a code error by adding in an extra ;

post lines 1 to 6 and i will take a look for you.

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 8:28 am 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
Sorry Josh I should have put the code in. This is the code you supplied to another member on the 23rd of March 2007. I just did a "copy" & "paste".

$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();
?>

Thanks for your help. I'm SURE I'll need it again!
Regards,
Alan.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 8:46 am 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
I have just realised that the "Register" code is in a "html" file but that seems to work. I've been trying to change it to a "php" file but am having problems with renaming & deleting files & folders. The help desk is trying to sort that out for me; I am able to do it on another P.C so I don't know why I have trouble on this P.C. Sometimes it works, most times it doesn't. But that's another story!
Will changing to "php" make a difference with the file that the "Register" code is in?
Regards,
Alan.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 8:52 am 
Newbie
Newbie

Joined: Wed Aug 08, 2007 7:45 am
Posts: 5
Hey Alan,

I only looked quick but I think I've found the problem... When you define $Query2, you forget the " at the end of the line.

$Query2 = "INSERT INTO #DATABASE TABLE# VALUES ('', '$username', '$password')";

Maybe it works. And I don't think changing to a .php extension won't help if a .html is being parsed too.

Regards
Mark


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 9:05 am 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
Yeh mark is right, i forgot the last bit on Query2 could you pass my a link to where i put in the incorrect code so i can fix it please.

Mark if you like php you will like the next post im going to make.

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 9:06 am 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
Hi Mark,
Tried that and it made no difference. According to the message (see above), the fault is in line 4.
Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 9:16 am 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
Can you post what exactly you are using personaly, so i can get a better look at it. If there is a username / password in it change it for ####

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 9:35 am 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
Josh, here is the link.

http://forum.freehostia.com/viewtopic.p ... unt+script

The code above IS exactly what I am using, and there lies the fault (I guess)!

What goes in the "HOST" section? I pressume my freehostia username & password go in the other sections?

Thanks again,
Alan.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 9:50 am 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
You need to create a MySQL database through the control panel of your hosting first.

It is a different username and password for mysql (which you set when you create the database) to your control panel login.

The mysql host will be shown when you create the table, its usualy something like

mysql3.freehostia.com

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 9:51 am 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
line 4 would be

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

and there is nothing wrong with that.

did you change anything on

$Link = mysql_connect (#HOST# ,#USERNAME#,#PASSWORD#); //Fill in the details

? like did you leave out a ' thats why i want to see the one that YOU are using

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 10:31 am 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
I have already created the MySql database as per your instruction on that posting in March and it all went well.

The code I posted above is the one I used. I only added <?php at the very start. I then added the " as mark suggested which didn't appear to make a difference so I took it back out. I will put it back in though and try again.

Regards,
Alan.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 10:37 am 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
Josh,
I just copied this code from my "register2.php" file.

<?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();
?>

This is exactly what's on that file.
Regards,
Alan.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 10:39 am 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
change

$Link = mysql_connect (#HOST# ,#USERNAME#,#PASSWORD#); //Fill in the details


to

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

(replacing the writeing in the middle with the correct information leaving in the '

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 10:57 am 
Newbie
Newbie

Joined: Mon Jan 15, 2007 10:20 am
Posts: 18
Location: Charmhaven, Australia
We must be getting somewhere, now the error is

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

Regards,
Alan.


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

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