Thread: Error in Mysql
View Single Post
Old 09-28-2008, 08:18 AM   #1 (permalink)
zxt3st
The Addict
 
zxt3st's Avatar
 
Join Date: Apr 2008
Posts: 200
Thanks: 18
zxt3st is on a distinguished road
Default Error in Mysql

Here is the error

Code:
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 '@yahoo.com, )' at line 2
Here is my code.

PHP Code:
<?php

include('includes/dbsettings.php');

$duplicates "SELECT username FROM users WHERE username='".trim($_POST['username'])."'";
$result mysql_query($duplicates$link)or die("Could not execute query");
if (
mysql_num_rows($result)>0)
{
    print (
"<script>\n alert('Username already exists!')\n history.back(); </script>");
    exit();
}
if ((
$_POST['username'] == "")||($_POST['password'] == "" && $_POST['password2'] == "")||($_POST['email'] == "")||($_POST['name'] == ""))
{
    print (
"<script>\n alert('All fields are required!')\n history.back(); </script>");
    exit();
}
if (
$_POST['password'] != $_POST['password2'])
{
    print (
"<script>\n alert('Password does not match!!')\n history.back(); </script>");
    exit();
}
if(!
eregi("^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*@[a-zA-Z0-9]+[a-zA-Z0-9_.-])*\.[a-z]{2,4}$"$_POST['email']))
{
    print (
"<script>\n alert('Email is invalid!!!')\n history.back(); </script>");
    exit();
}
$md5pass md5($_POST['password']);
$usrAdd "INSERT INTO users(username, password, email, fullName)
            VALUES("
.$_POST['username'].", ".$md5pass.", ".$_POST['email'].", ".$_POST['fullName'].")";
if(
mysql_query($usrAdd$link))
{
    echo 
"User SUccessfully Added!";
}else{
    echo 
mysql_error();
}

?>
above is my code, its still plain and not the purpose is to just solely register an account.

I already do some research in google but i stil can't find my answers. THanks.
zxt3st is offline  
Reply With Quote