Jump to content

mysql error


stugreenham

Recommended Posts

can anyone help me, just registered with 1and1 for the webspace and mysql database and am having some problems, i uploaded phpmyadmin, and got a table on the database but when i try to interact with it for example, add a user, i keep getting this error:

 

Parse error: parse error, unexpected '{' in /homepages/24/d136628883/htdocs/register.php on line 98

 

heres the code for the page...

 

 

<?php

 

include 'db.inc';

 

// Define post fields into simple variables

$email = $_POST['email'];

$fname = $_POST['f_name'];

$sname = $_POST['s_name'];

$street = $_POST['street'];

$city = $_POST['city'];

$county = $_POST['county'];

$pcode = $_POST['p_code'];

$ref_email = $_POST['referral'];

$ipod_code = $_POST['ipod_code'];

 

 

 

$email = stripslashes($email);

$f_name = stripslashes($f_name);

$s_name = stripslashes($s_name);

$street = stripslashes($street);

$city = stripslashes($city);

$county = stripslashes($county);

$p_code = stripslashes($p_code);

$ref_email = stripslashes($ref_email);

$ipod_code = stripslashes($ipod_code);

 

 

if((!email) || (!$f_name) || (!$s_name) || (!$street) || (!$city) || (!$county) || (!p_code)){

echo 'You did not submit the following required information: <br />';

if(!$email){

echo "Email is a required field. Please enter it below.<br />";

}

if(!$f_name){

echo "First Name is a required field. Please enter it below.<br />";

}

if(!$s_name){

echo "Surname is a required field. Please enter it below.<br />";

}

if(!$street){

echo "Street is a required field. Please enter it below.<br />";

}

if(!$city){

echo "City is a required field. Please enter it below.<br />";

}

if(!$county){

echo "County is a required field. Please enter it below.<br />";

}

if(!$p_code){

echo "Post Code is a required field. Please enter it below.<br />";

}

echo "Please <a href=javascript:history.back()>Click Here</a> to return to the form";

exit();

}

 

 

$sql_email_check = mysql_query("SELECT email FROM members

WHERE email = '$email'");

 

$email_check = mysql_num_rows($sql_email_check);

 

if(($email_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 submit a different Email address!<br />";

unset($email);

}

echo "Please <a href=javascript:history.back()>Click Here</a> to return to the form";

exit();

}

 

 

function makeRandomPassword() {

$salt = "abchefghjkmnpqrstuvwxyz0123456789";

srand((double)microtime()*1000000);

$i = 0;

while ($i <= 7) {

$num = rand() % 33;

$tmp = substr($salt, $num, 1);

$pass = $pass . $tmp;

$i++;

}

return $pass;

}

 

$random_password = makeRandomPassword();

 

$db_password = md5($random_password);

 

// Enter info into the Database.

$sql = mysql_query("INSERT INTO members (email, password, f_name, s_name, street, city, county, p_code, referral, ipod_code, signup_date)

VALUES('$email', '$db_password', '$f_name', '$s_name', '$street', '$city', $county, $p_code, $referral, $ipod_code, now())")

or die (mysql_error());

 

if(!$sql){

echo 'There has been an error creating your account. Please contact the webmaster.';

}

}

 

?>

 

 

<br /><br />

 

</center>

</td >

 

<tr>

<td colspan="3"><br /></td>

</tr>

 

</div>

 

 

 

..also can anyone help me with the exact script i should have in my db.inc file, thanks

 

stu

Link to comment
Share on other sites

please point out line 98... and in the future, enclose your code in the BBCode PHP or CODE tags. Preferably [ PHP ], without the spaces. Look at the buttons above your post area.

 

also can anyone help me with the exact script i should have in my db.inc file, thanks

 

I'm thinking you would want something like this...

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?

 

$host [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"mysqlservername\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]$username [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"username\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]$password [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"password\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]$db [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"databasename\"[/span][span style=\"color:#007700\"];

 

@[/span][span style=\"color:#0000BB\"]mysql_connect[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$host[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$username[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$password[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

@[/span][span style=\"color:#0000BB\"]mysql_select_db[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$db[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

 

[/span][span style=\"color:#0000BB\"]?>[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

And you shoud rename db.inc to db.inc.php or something ending with .php. If you leave it as .inc, I could just navigate to http://www.yourdomain.com/db.inc and it would show me the username and password for your database server.

Link to comment
Share on other sites

this is from line 98 in dreamweaver...

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

 

if(($email_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 submit a different Email address!<br />\";

        unset($email);

    }

    echo \"Please <a href=javascript:history.back()>Click Here</a> to return to the form\";

    //include \'join_form.html\'; // Show the form again!

    exit();  // exit the script so that we do not create this account!

}

 

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.