![]() |
|
#1
|
|||
|
|||
Trouble connecting to MySQLi have tried to make a login code and members area that i found in a teach php book but everytime i upload it it comes up with unexpected T_STRING on either line 13 or 14 this is the code i am using
PHP Code:
|
|||
|
#2
|
||||
|
||||
Re: Please Help!!!!!!!Hi,
Use an appropriate title for your post. Dont post new threads for the same question. I dont know anything about PHP but here is my guess: PHP Code:
the error is that there is an extra single quote ' after the email. In this line, PHP Code:
so, Add a semicolon at the end of the statement. and remove that single quote. I hope this helps a little bit. Here is the updated one: PHP Code:
Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#3
|
|||
|
|||
Re: Please Help!!!!!!!I have done that but now when i go to register a new user it says sorry you left a field blank when i havent
|
|
#4
|
|||
|
|||
Re: Please Help!!!!!!!well, im no genius but i have edited a new one and i have forund this
<html> <p>create a new user <?php $dbhost = "hab-globe.com"; $dbname = "userdetails"; $dbuser = "user"; $dbpass = "habbo250"; $username = $_POST['newusername']; $userpass = $POST_['newpassword']; $useremail = $_POST['email']; $today = date("y-m-d"); if ($username = "" $userpass = " or $useremail = ") die ("<p>sorry you left a field empty please click the back butto to check your details") $query = "INSERT INTO user (username, password, joindate, email') VALUES ('$username', '$userpass', '$today', '$useremail')"; $connection mysql_connect(dbhost, $dbuser, $dbpass) or die ("<br>sorry couldnt connect to hab-globe.com"); $db = mysql_select_db($dbname, $dbconnection) or die("<br>Sorry http://www.hab-globe.com Is Not Allowing Logins Today!!"); $result = mysql_query($query) or die ("sorry that user has been taken"); $_SESSION['login'] = 'yes'; ?> <p>thank you, your new user has been created. Please click <ahref="login.php"> here</a> to log into your hab-globe user account.<p> </html> |
|
#5
|
|||
|
|||
Re: Please Help!!!!!!!<html>
<p>create a new user <?php $dbhost = "hab-globe.com"; $dbname = "userdetails"; $dbuser = "user"; $dbpass = "habbo250"; $username = $_POST['newusername']; $userpass = $POST_['newpassword']; $useremail = $_POST['email']; $today = date("y-m-d"); if ($username = "" $userpass = " or $useremail = ") die ("<p>sorry you left a field empty please click the back butto to check your details") $query = "INSERT INTO user (username, password, joindate, email') VALUES ('$username', '$userpass', '$today', '$useremail')"; $connection mysql_connect(dbhost, $dbuser, $dbpass) or die ("<br>sorry couldnt connect to hab-globe.com"); $db = mysql_select_db($dbname, $dbconnection) or die("<br>Sorry http://www.hab-globe.com Is Not Allowing Logins Today!!"); $result = mysql_query($query) or die ("sorry that user has been taken"); $_SESSION['login'] = 'yes'; ?> <p>thank you, your new user has been created. Please click <ahref="login.php"> here</a> to log into your hab-globe user account.<p> </html> <html> <p>create a new user <?php $dbhost = "hab-globe.com"; $dbname = "userdetails"; $dbuser = "user"; $dbpass = "habbo250"; $username = $_POST['newusername']; $userpass = $POST_['newpassword']; $useremail = $_POST['email']; $today = date("y-m-d"); if ($username = "" $userpass = " or $useremail = ") die ("<p>sorry you left a field empty please click the back butto to check your details") $query = "INSERT INTO user (username, password, joindate, email') VALUES ('$username', '$userpass', '$today', '$useremail')"; $connection mysql_connect(dbhost, $dbuser, $dbpass) or die ("<br>sorry couldnt connect to hab-globe.com"); $db = mysql_select_db($dbname, $dbconnection) or die("<br>Sorry http://www.hab-globe.com Is Not Allowing Logins Today!!"); $result = mysql_query($query) or die ("sorry that user has been taken"); $_SESSION['login'] = 'yes'; ?> <p>thank you, your new user has been created. Please click <ahref="login.php"> here</a> to log into your hab-globe user account.<p> </html> <html> <p>create a new user <?php $dbhost = "hab-globe.com"; $dbname = "userdetails"; $dbuser = "user"; $dbpass = "habbo250"; $username = $_POST['newusername']; $userpass = $POST_['newpassword']; $useremail = $_POST['email']; $today = date("y-m-d"); if ($username = "" $userpass = " or $useremail = ") die ("<p>sorry you left a field empty please click the back butto to check your details") $query = "INSERT INTO user (username, password, joindate, email') VALUES ('$username', '$userpass', '$today', '$useremail')"; $connection mysql_connect(dbhost, $dbuser, $dbpass) or die ("<br>sorry couldnt connect to hab-globe.com"); $db = mysql_select_db($dbname, $dbconnection) or die("<br>Sorry http://www.hab-globe.com Is Not Allowing Logins Today!!"); $result = mysql_query($query) or die ("sorry that user has been taken"); $_SESSION['login'] = 'yes'; ?> <p>thank you, your new user has been created. Please click <ahref="login.php"> here</a> to log into your hab-globe user account.<p> </html> <html> <p>create a new user <?php $dbhost = "hab-globe.com"; $dbname = "userdetails"; $dbuser = "user"; $dbpass = "habbo250"; $username = $_POST['newusername']; $userpass = $POST_['newpassword']; $useremail = $_POST['email']; $today = date("y-m-d"); if ($username = "" $userpass = " or $useremail = ") die ("<p>sorry you left a field empty please click the back butto to check your details") $query = "INSERT INTO user (username, password, joindate, email') VALUES ('$username', '$userpass', '$today', '$useremail')"; $connection mysql_connect(dbhost, $dbuser, $dbpass) or die ("<br>sorry couldnt connect to hab-globe.com"); $db = mysql_select_db($dbname, $dbconnection) or die("<br>Sorry http://www.hab-globe.com Is Not Allowing Logins Today!!"); $result = mysql_query($query) or die ("sorry that user has been taken"); $_SESSION['login'] = 'yes'; ?> <p>thank you, your new user has been created. Please click <ahref="login.php"> here</a> to log into your hab-globe user account.<p> </html> |
|
#6
|
|||
|
|||
Re: Please Help!!!!!!!Quote:
Also The Datbase Connection String Should Be Formatted in a way which it is easy to view |
|
#7
|
|||
|
|||
Re: Please Help!!!!!!!You haven't gotten there yet, but on line 15:
$connection mysql_connect(dbhost, $dbuser, $dbpass) the 'dbhost' needs a '$' in front of it to be a valid variable. Here's the corrected code: $connection mysql_connect($dbhost, $dbuser, $dbpass) Hope that helps. |
|
#8
|
||||
|
||||
Re: Please Help!!!!!!!There are so many syntax errors, I don't know where to start
PHP Code:
When user-supplied data/input is inserted within your SQL statement, you really should screen the data first. PHP Code:
From your example code: PHP Code:
Line 3 : Where did $dbconnection come from? I thought it was $connection? PHP Code:
I appreciate that you're experimenting (and learning) but you'll understand new PHP stuff (like connecting to MySQL) a lot faster if you revisit a page like: basic PHP syntax (Expressions) and understand the basics about the language. Really, it's not complicated at all. While I am replying to this post of yours, may I suggest that you do NOT use titles like "Please Help!!!!!!!" in forums. It's considered bad form. |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| php and mysql | vladimy | MySQL / PHP Forum | 2 | 28-May-2005 06:17 |
| Error connecting to MySQL | Kilgayne | MySQL / PHP Forum | 4 | 27-May-2005 14:45 |
| Trouble connecting to most of the internet | jrobbio | Web Hosting Forum | 7 | 18-Jan-2004 11:11 |
| Windows: From only £20p/y,Linux: from $10p/m. ASP, ASP.NET, PHP, Free MySQL, +More | EyotaHosts | Web Hosting Advertisements & Offers | 0 | 28-Jun-2003 14:54 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The