Renlok Posted December 13, 2006 Share Posted December 13, 2006 ok ive got a register form it it keeps returning with the error[b]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 ')' at line 3[/b]but i cant find any errors, can some one else help me outthe code:[code]<? include "includes/messages.inc.php"; include "includes/config.inc.php"; include "includes/countries.inc.php"; //-- getSessionVars(); $auction_id = $sessionVars["CURRENT_ITEM"];if (empty($action)) { $action="first";}if ($REQUEST_METHOD=="POST" && $action=="first") { if ($TPL_surname && TPL_firstname && $TPL_nick && $TPL_password && $TPL_repeat_password && $TPL_email && $TPL_address && $TPL_city && $TPL_prov && $TPL_country && $TPL_zip && $TPL_phone) { // age check $nowday = date("d"); $nowmonth = date("m"); $nowyear = date("Y"); $thereday = $TPL_birthday; $theremonth = $TPL_birthday; $thereyear = $TPL_birthyear; $year = $thereyear - $nowyear; $month = ($nowmonth / 12) - ($theremonth / 12); $day = ($nowday / 365) - ($thereday / 365); $age = $year - $month - $day; $age = $age * -1; if (strlen($TPL_nick)<6) { $TPL_err=1; $TPL_errmsg=$ERR_107; } else if (strlen ($TPL_password)<6) { $TPL_err=1; $TPL_errmsg=$ERR_108; } else if ($TPL_password!=$TPL_repeat_password) { $TPL_err=1; $TPL_errmsg=$ERR_109; } else if (!(ereg("^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-.]?[0-9a-zA-Z])*\\.[a-zA-Z]{2,3}$",$TPL_email))) //Besserer mail check { $TPL_err=1; $TPL_errmsg=$ERR_110; } else if (strlen($TPL_zip)<4) //Primitive zip check { $TPL_err=1; $TPL_errmsg=$ERR_606; } else if (strlen($TPL_phone)<3) //Primitive phone check { $TPL_err=1; $TPL_errmsg=$ERR_607; } else if($age <= 18) { $TPL_err = 1; $TPL_errmsg = $ERR_113; } else { $sql="SELECT nick FROM ".$dbfix."_users WHERE nick=\"". AddSlashes ($TPL_nick)."\""; $res=mysql_query ($sql); if (mysql_num_rows($res)==0) { $id = uniqid(""); $id = eregi_replace("[a-f]","",$id); $TPL_id_hidden=$id; $TPL_nick_hidden=$TPL_nick; $TPL_password_hidden=$TPL_password; $TPL_firstname_hidden=$TPL_firstname; $TPL_surname_hidden=$TPL_surname; $TPL_email_hidden=$TPL_email; } else { $TPL_err=1; $TPL_errmsg=$ERR_111; // Selected user already exists } $sql="SELECT email FROM ".$dbfix."_users WHERE email=\"". AddSlashes ($TPL_email)."\""; $res=mysql_query ($sql); if (mysql_num_rows($res)==0) { $id = uniqid(""); $id = eregi_replace("[a-f]","",$id); $TPL_id_hidden=$id; $TPL_nick_hidden=$TPL_nick; $TPL_password_hidden=$TPL_password; $TPL_firstname_hidden=$TPL_firstname; $TPL_surname_hidden=$TPL_surname; $TPL_email_hidden=$TPL_email; } else { $TPL_err=1; $TPL_errmsg=$ERR_115; // Selected user already exists } if($TPL_err == 0) { $TPL_nick_hidden = addslashes($TPL_nick_hidden); $TPL_password_hidden = addslashes($TPL_password_hidden); $$TPL_firstname_hidden = addslashes($TPL_firstname_hidden); $$TPL_surname_hidden = addslashes($TPL_surname_hidden); $TPL_address = addslashes($TPL_address); $TPL_city = addslashes($TPL_city); $TPL_prov = addslashes($TPL_prov); $TPL_country = addslashes($TPL_country); $TPL_zip = addslashes($TPL_zip); $TPL_phone = addslashes($TPL_phone); $TPL_email_hidden = addslashes($TPL_email_hidden); $sql="INSERT INTO ".$dbfix."_users (id, nick, password, firstname, surname, address, city, prov, country, zip, phone, email, reg_date, rate_sum, rate_num, birthdate) VALUES ('$TPL_id_hidden', '$TPL_nick_hidden', '$TPL_password_hidden', '$TPL_firstname_hidden', '$TPL_surname_hidden', '$TPL_address', '$TPL_city', '$TPL_prov', '$TPL_country', '$TPL_zip', '$TPL_phone', '$TPL_email_hidden', NULL, 0,0,$DATE)"; $res=mysql_query ($sql); if ($res==0) { $TPL_err=1; $TPL_errmsg=mysql_error ();//"Error updating users data"; } else { //-- Get actual users and auctions counters $query = "select users from ".$dbfix."_counters"; $result_counters = mysql_query($query); if(!$result_counters){ $TPL_errmsg = $ERR_001; }else{ $users_counter = mysql_result($result_counters,0,"users") + 1; //-- Update counters table $query = "update ".$dbfix."_counters set users = $users_counter"; $result_update_counters = mysql_query($query); if(!$result_update_counters){ $TPL_errmsg = $ERR_001; } } // - bestätigungsmail verschicken $buffer = file("includes/usermail.inc.php"); $i = 0; $j = 0; while($i < count($buffer)) { if(!ereg("^#(.)*$",$buffer[$i])) { $skipped_buffer[$j] = $buffer[$i]; $j++; } $i++; } //--Reteve message $message = implode($skipped_buffer,""); //--Change TAGS with variables content $message = ereg_replace("<#c_id#>",addslashes($TPL_id_hidden),$message); $message = ereg_replace("<#c_name#>",addslashes($TPL_name_hidden),$message); $message = ereg_replace("<#c_nick#>",addslashes($TPL_nick_hidden),$message); $message = ereg_replace("<#c_address#>",addslashes($TPL_address),$message); $message = ereg_replace("<#c_city#>",addslashes($TPL_city),$message); $message = ereg_replace("<#c_prov#>",addslashes($TPL_prov),$message); $message = ereg_replace("<#c_zip#>",addslashes($TPL_zip),$message); $message = ereg_replace("<#c_country#>",addslashes($countries[$TPL_country]),$message); $message = ereg_replace("<#c_phone#>",addslashes($TPL_phone),$message); $message = ereg_replace("<#c_email#>",addslashes($TPL_email_hidden),$message); $message = ereg_replace("<#c_password#>",addslashes($TPL_password_hidden),$message); $message = ereg_replace("<#c_sitename#>",$SITE_NAME,$message); $message = ereg_replace("<#c_siteurl#>",$SITE_URL,$message); $message = ereg_replace("<#c_adminemail#>",$adminEmail,$message); mail($TPL_email_hidden,"$MSG_098",$message,"From:$SITE_NAME <$adminEmail>\nReplyTo:$adminEmail"); } } // if($TPL_err == 0) } } else { $TPL_err=1; $TPL_errmsg="$ERR_112"; // Data missing }} include "header.php";if (($REQUEST_METHOD=="GET" && $action=="first") || ($REQUEST_METHOD=="POST" && $action=="first" && $TPL_err)) { $country=""; while (list ($code, $name)=each ($countries)) { $country .="<option value=\"$code\""; if ($code==$TPL_country) { $country .= " selected"; } $country .=">$name</option>\n"; } include "templates/register_php3.html";}if ($REQUEST_METHOD=="POST" && $action=="first" && !$TPL_err) { include "templates/registered_php3.html";} include "footer.php"; $TPL_err=0; $TPL_errmsg="";?>[/code] Link to comment https://forums.phpfreaks.com/topic/30508-solved-register-form-error/ Share on other sites More sharing options...
Cagecrawler Posted December 13, 2006 Share Posted December 13, 2006 $sql="INSERT INTO ".$dbfix."_users (id, nick, password, firstname, surname, address, city, prov, country, zip, phone, email, reg_date, rate_sum, rate_num, birthdate) VALUES ('$TPL_id_hidden', '$TPL_nick_hidden', '$TPL_password_hidden', '$TPL_firstname_hidden', '$TPL_surname_hidden', '$TPL_address', '$TPL_city', '$TPL_prov','$TPL_country', '$TPL_zip', '$TPL_phone', '$TPL_email_hidden', NULL, 0,0,$DATE)";$DATE needs to be '$DATE', except I can't see where $DATE is defined. Are you thinking of date()? Link to comment https://forums.phpfreaks.com/topic/30508-solved-register-form-error/#findComment-140428 Share on other sites More sharing options...
timmah1 Posted December 13, 2006 Share Posted December 13, 2006 Anytime that I have ran into this problem, I was trying to insert either more or less fields into the database.Your trying to insert 16 fields into the database.also at the end of yoru insert statement[code]'$TPL_email_hidden', NULL, 0,0,$DATE)";[/code]shouldn't it be like this[code]'$TPL_email_hidden', NULL, 0,0,NOW())";[/code]or this[code]'$TPL_email_hidden', NULL, 0,0,'$DATE')";[/code] Link to comment https://forums.phpfreaks.com/topic/30508-solved-register-form-error/#findComment-140431 Share on other sites More sharing options...
Renlok Posted December 13, 2006 Author Share Posted December 13, 2006 thanks the probleis solved i think it was mainly because i was trying to insert the wrong peice of information. ^^ lol thanks for your help. Link to comment https://forums.phpfreaks.com/topic/30508-solved-register-form-error/#findComment-140458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.