Page 1 of 2
Error on register scipt
Posted: Wed Jun 07, 2006 12:23 am
by 4Boredom
I get this error
Parse error: parse error, unexpected T_STRING in /home/i4boredo/public_html/register.php on line 67
on the following code
Code: Select all
<?
include 'db.php';
# grab the POST variables from the HTML form
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$password = $_POST['password'];
# Any escaped characters?
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$password = stripslashes($password);
# Any errors in the posted fields?
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
}
if(!$last_name){
echo "Last Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br />";
}
if(!$username){
echo "Desired Username is a required field. Please enter it below.<br />";
}
include 'signup.php';
exit();
}
# does this user already exist in the database?
$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been used by another member in our database. Please use a different email address!<br />";
unset($email_address);
}
include 'signup.php'; // Shows the form again!
exit();
}
# Enter info into the Database.
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, signup_date);
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
// Let's mail the user!
$subject = "Your 4Boredom.com Membership";
$message = "Dear $first_name $last_name,
You are now registered at our website, http://www.4boredom.com!
You are now able to login with the following information:
Username: $username
Password: $password
Please keep this username and password in a location that is easily accessible by you.
Thanks!
Derek Lemire
4boredom.com
This is an automated response, please do not reply!";
mail($email_address, $subject, $message, "From: MyWebSite<derek@4boredom.com>\nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
}
?>
can anyone help?
Posted: Wed Jun 07, 2006 12:36 am
by PrObLeM
Code: Select all
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, signup_date)");
Posted: Wed Jun 07, 2006 1:54 am
by 4Boredom
thank you
Posted: Wed Jun 07, 2006 1:56 am
by 4Boredom
twigletmac | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
now is this right for the databasE? I still get errors?
Code: Select all
<?
# database connection scripts
# the next 4 lines you can modify
$dbhost = 'localhost';
$dbusername = 'mylogin';
$dbpasswd = 'mypassword';
$database_name = 'mysite_main';
#under here, don't touch!
$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");
$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>
twigletmac | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Wed Jun 07, 2006 5:17 am
by itsmani1
4Boredom wrote:twigletmac | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
now is this right for the databasE? I still get errors?
Code: Select all
<?
# database connection scripts
# the next 4 lines you can modify
$dbhost = 'localhost';
$dbusername = 'mylogin';
$dbpasswd = 'mypassword';
$database_name = 'mysite_main';
#under here, don't touch!
$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");
$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>
twigletmac | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color][/quote]
try
mysql_connect()
Posted: Thu Jun 08, 2006 2:19 pm
by 4Boredom
hmm it still says there has been an error creating my account when I do it with that change..
I am new to this, was there something majorlly wrong that I did? It stinks lol I followed a tutorial and even went over it a 2nd time..
If anyone can take 5 min look at my code and help plz msg me, aim : LemIzDaIcon
Posted: Thu Jun 08, 2006 5:16 pm
by 4Boredom
anyone? please?
Posted: Thu Jun 08, 2006 7:02 pm
by Jixxor
You'll need to repost your code with the changes you've made.
Thus far, everything has been simple mistakes:
I.E.
- Forgetting a closing ) or a " here and there
- Mispelling certain function names
Posted: Fri Jun 09, 2006 12:52 am
by 4Boredom
I keep getting errors here on my
signup page
can anyone help?
There are 3 files attached....
Signup.php
Code: Select all
<?php
# starting the session here
session_start();
# this prevents a user from typing or pasting a URL string
# into their browser to get to this page. If the $first_name
# variable is empty, then they log in like everyone else.
?>
<?php require("header.php"); ?>
<center>
<b>New User Signup</b><br><br>
<form name=form1 method=post action=register.php>
<table width=100% border=0 cellpadding=4 cellspacing=0 align="center">
<tr>
<td width=24% align=left valign=top>First Name</td>
<td width=76%><input name=first_name type=text id=first_name></td>
</tr>
<tr>
<td align=left valign=top>Last Name</td>
<td><input name=last_name type=text id=last_name></td>
</tr>
<tr>
<td align=left valign=top>Email Address</td>
<td><input name=email_address type=text id=email_address></td>
</tr>
<tr>
<td align=left valign=top>Desired Username</td>
<td><input name=username type=text id=username></td>
</tr>
<tr>
<td align=left valign=top>Desired Password</td>
<td><input name=username type=text id=password></td>
</tr>
<td align=left valign=top> </td>
<td><input type=submit name=Submit value=Join Now!></td>
</tr>
</table>
</form>
</body>
</html>
db.php
Code: Select all
<?
# database connection scripts
# the next 4 lines you can modify
$dbhost = 'localhost';
$dbusername = 'hidden';
$dbpasswd = 'hidden';
$database_name = 'hidden';
#under here, don't touch!
$connection = mysql_connect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");
$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>
Register.php
Code: Select all
<?
include 'db.php';
# grab the POST variables from the HTML form
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$password = $_POST['password'];
# Any escaped characters?
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$password = stripslashes($password);
# Any errors in the posted fields?
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
}
if(!$last_name){
echo "Last Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br />";
}
if(!$username){
echo "Desired Username is a required field. Please enter it below.<br />";
}
include 'signup.php';
exit();
}
# does this user already exist in the database?
$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been used by another member in our database. Please use a different email address!<br />";
unset($email_address);
}
include 'signup.php'; // Shows the form again!
exit();
}
# Enter info into the Database.
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, signup_date)");
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
// Let's mail the user!
$subject = "Your 4Boredom.com Membership";
$message = "Dear $first_name $last_name,
You are now registered at our website, http://www.4boredom.com!
You are now able to login with the following information:
Username: $username
Password: $password
Please keep this username and password in a location that is easily accessible by you.
Thanks!
Derek Lemire
4boredom.com
This is an automated response, please do not reply!";
mail($email_address, $subject, $message, "From: MyWebSite<derek@4boredom.com>\nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
}
?>
Posted: Fri Jun 09, 2006 1:46 am
by RobertGonzalez
Error check...
Code: Select all
<?php
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, signup_date)") or die("There was an error: " . mysql_error());
?>
Of course, looking at that query, it appears that you are not completing your query...
Code: Select all
<?php
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, signup_date) VALUES (ADD THE SUPPLIED DATA HERE)") or die("There was an error: " . mysql_error());
?>
Oh yeah, please remember to wrap your PHP code in
Posted: Fri Jun 09, 2006 10:02 am
by 4Boredom
What does add the supplied data here mean? Sorry im a little new lol..
I also looked back and realized that the sql database i set up is under mysite_main but with the table users. I do not have the table users anywhere in the code, should that be put somewhere?
Posted: Fri Jun 09, 2006 10:09 am
by RobertGonzalez
Sorry, that was meant to be whatever data you planned on entering into your database.
As a suggestion, you may want to pick up a tutorial or two on interacting PHP with databases. There is a strict syntax to follow when issue SQL commands that you are going to want to know before getting into something like a registration script.
Briefly, a MySQL insert SQL statement looks something like this...
Code: Select all
INSERT INTO `table_name` (`field1`, `field2`, `field3`) VALUES ('value1', 'value2', 'value3');
Posted: Sun Jun 18, 2006 10:21 am
by 4Boredom
I changed this and its still not working???
I am so confused I have tried to look over and try different styles for everything.
Its so frustrating when im trying to learn the language and my database will not interact
If anyone can help PLEASE PLEASE msg me on aim.. LemIzDaIcon
Posted: Sun Jun 18, 2006 2:27 pm
by 4Boredom
anyone know where I can go for cheap tech support for this? I can pay just not like 100 an hour like some will charge hehe im a college kid
Posted: Sun Jun 18, 2006 2:45 pm
by John Cartwright
4Boredom wrote:anyone know where I can go for cheap tech support for this? I can pay just not like 100 an hour like some will charge hehe im a college kid
If you want to hire someone to do this, people can make you offers in the Job Hunt forum.. if your lucky someone may do it for you in the Volunteer forum if your unwillinging to keep taking stabs at it.
As for helping you here, please post your code in
tags so we can read the code better (Twig has already fixed it once for you).. until then you'll likely find people less helpful. Help us help you
