Jump to content


Photo

please help


  • Please log in to reply
26 replies to this topic

#1 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 02:05 AM

hello there, im creating a login for my website, the html for the login page is below


<form name="register" method="post" action="register.php">
  <input name="login id" type="text" value="loginid" size="20"/><br>
  <input name="password" type="text" value="password" size="20"/><br>
  <input name="email" type="text" value="email" size="50"/><br>
  <input type="submit" name="submit" value="submit"/>
  <input type="reset" name="reset" value="reset"/>


this is the register.php file:


<?php

@mysql_connect("localhost", "usuallymyrealuser", "usuallymypassword") or die("Cannot connect to DB!");
@mysql_select_db("tbl_login") or die("Cannot select DB!");
$sql="INSERT INTO login_tbl (loginid, password and email) VALUES (".$loginid.”,”.$password.”,”.$email.”)”;
$r = mysql_query($sql);
if(!$r) {
  $err=mysql_error();
  print $err;
  exit();
}

?>


AFTER DOING THIS, AND SUBMITTING THE INFORMATION ON THE HTML PAGE, I GET THE FOLLOWING ERROR:

Parse error: parse error, unexpected ',' in myaddress/register.php on line 5



CAN U HELP PLEASE, IM NOT GREAT WITH PHP AND DONT UNDERSTAND THE PROBLEM!
THANKYOU!

#2 Moon-Man.net

Moon-Man.net
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 24 July 2006 - 02:25 AM

Check your quoting. Make sure that if you use " with in " quotes that you Excape them like this:

$sql="INSERT INTO login_tbl (loginid, password and email) VALUES (\".$loginid.\",\".$password.\",\".$email.\")";
Try replacing line 5 with that


#3 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 02:28 AM

well thankyou very much, that has obviously fixed it, my only other problem is, it now says cannot connect to DATABSE lol, any ideas? wot do i put the three parts, "localhost" "username" "password"??
in the username, the username for the database??
password, password for database?
wot about localhost?

cheers m8

#4 Moon-Man.net

Moon-Man.net
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 24 July 2006 - 02:34 AM

No worries, we all learn somehow...
The password field : password for database
the username filed: username for database
the other field(not called Localhost field): that is the location of the database, "localhost" refers to the computer the webserver is running on. so if the database is on the same box as the webserver use "localhost" if not then the IP address of the computer running the SQL server.

also in the above line. you may want to remove all those "."'s because i presume where ever you got that code from they were trying to concatinate the strins, and it will insert LITERLAY ".VARIABLEVALUE." (With out quotes)"

Anything else u need help with, just drop a line :)


#5 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 02:42 AM

i still havent got it mate, ive entered the databse which is ots_users and the password which is the password lol, so that is, "ots_users" "password" for them two. i think it is the other one i am having problems with, my sql database is online on my webspace so what do i put for that? thanx

#6 Moon-Man.net

Moon-Man.net
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 24 July 2006 - 02:46 AM

If the SQL server is running on the same copmuter as the webserver, you can enter localhost(try that). but if it is running on a seperate computer then enter the IP address of that computer.
Is this a server you have setup or something you have hired? (eg with a Hosting company)
Cheers,
Nathan

#7 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 02:50 AM

its with a hosting company, ive now got past that point, but now cant select DB lol, any ideas mate, really sorry to keep asking, i am tryin trial and error though!

#8 Moon-Man.net

Moon-Man.net
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 24 July 2006 - 02:53 AM

What is the error your getting?
Cheers,
nathan

#9 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 02:56 AM

Cannot select DB!

cheers

#10 Moon-Man.net

Moon-Man.net
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 24 July 2006 - 02:57 AM

Make sure that database is in the Server, have you connected to it before?
spaces rewin things,

Cheers,
Nathan

#11 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 03:01 AM

ok my database is ots_users, and the table i have created with loginid password and email is called tbl_login. is this all correct? and how do i test it to see if its working ok?

#12 Moon-Man.net

Moon-Man.net
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 24 July 2006 - 03:06 AM

in the line where you say "@mysql_select_db("tbl_login") or die("Cannot select DB!");" put  "ots_users" instead of "tbl_login".
tbl_login is a table within the database ots_users.
Try that :)
Cheers,

@mysql_select_db("ots_users") or die("Cannot select DB!");


#13 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 12:20 PM

after doing that, i now get the following error:

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 'and email) VALUES (\..\,\.psw.\,\.email@email.com.\)' at line 1

any ideas?

#14 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 24 July 2006 - 12:31 PM

try this

$sql = "INSERT INTO login_tbl (loginid, password and email) VALUES ('$loginid', '$password', '$email')";

Good luck,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#15 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 12:36 PM

i did that mate and it changed to this

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 'and email) VALUES ('', 'psw', 'email@email.com')' at line 1

the login_tbl in the line you specified, is the table with the ots_users database right? if so the actual table is called tbl_login?? does this make a difference?

#16 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 12:40 PM

$sql = "INSERT INTO login_tbl (loginid, password and email) VALUES ('$loginid', '$password', '$email')";

that line there, i have changed the bold to

$sql = "INSERT INTO login_tbl (loginid, password, email) VALUES ('$loginid', '$password', '$email')";

and the insert into login_tbl to tbl_login because that is the table, i click and ive got a blank screen, maybe a sign that its working?

#17 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 12:44 PM

where do i add a line to say u have successfully registered?? do i add this to the html or the php? and what line do i add? can u please help?

#18 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 01:11 PM

CAN ANYBODY HELP?? I NEED A LINE TO ADD IN SO WHEN PEOPLE HAVE SIGNED UP IT SAYS THAT THEY ARE SUCCESSFULLY REGISTERED!

#19 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 24 July 2006 - 01:16 PM

relax,  I am writing you a better register script

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#20 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 01:23 PM

thankyou mate, ive now got it registering users on the database! just nothing on the screen to say it!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users