Jump to content

Recommended Posts

i get this 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 '(email, username, password) VALUES('test@test.com', 'test', '77004' at line 1

 

this is reg.php

<?php
$host = "localhost";
$username = "root";
$password = "";
$db_name ="alivecsetup";
$tbl_name ="members";

@mysql_connect($host, $username, $password) or die ("Can't Connect");
@mysql_select_db($db_name) or die(mysql_error());

$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];

$username = stripslashes($username);
$email = stripslashes($email);

if((!$username) || (!$password) || (!$email)){
echo '<h3>All fields are required!</h3>';
include 'register.html';
exit();
}
$db_password = md5($password);


$sql = mysql_query("INSERT INTO $table_name (email, username, password)
        VALUES('$email', '$username', '$db_password', now())")
        or die (mysql_error());

    


if(!$sql)

echo "There was an error while creating you account. Please contact an admin.";

else
{
$userid = mysql_insert_id();
//mailing time 
    $subject = "Membership at my-website.com";
    $message = "Dear $username,
    Thank you for registering at our website, 
    
        Here is your login information:
    Username: $username
    Password: $password
    
    Thanks!
    The Webmaster
    
    This is an automated response, please do not reply!";
    
mail($email, $subject, $message, "From: E-Nuke Webmaster<admin@e-nuke.net>\n X-Mailer: PHP/" . phpversion());
echo "<meta http-equiv=\"Refresh\" content=\"0; URL=http://friiks.awardspace.com/register.htm\"/>You will be redirected to login page.";  }       ?>

 

i don't know if you need this but..

<html>
<head>


<title>Register</title>
</head>
<body>
<form action='reg.php' method="post" name="loginform" id="loginform">
<table>
<tr>
<td>Username:</td><td><input type="username" name="username" class='text'></td>
</tr>
<tr>

<td>Password:</td><td><input type="password" name="password" class='text'>
</td>
</tr>
<tr>
<td>E-mail:</td><td><input type="email"    name="email"    class='text'>
</td>
</tr>
<tr><td><input type="submit"   name="Submit"   class='button' value="Register"></td>
</tr>
</table>
</form>
</body>
</html>

 

now i know

echo "There was an error while creating you account. Please contact an admin.";

i should add { and } but when i do i get this error
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\login\reg.php on line 35
thank you for helping i hope you can figure this out i cant.
Link to comment
https://forums.phpfreaks.com/topic/97899-php-errors/
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.