Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
godlydanny
Starting Member
25 Posts |
Posted - 2010-12-07 : 08:52:34
|
Hello please help me solve this error:Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Disallowed implicit conversion from data type varchar to data type binary, table 'databasename.dbo.users', column 'passwd'. Use the CONVERT function to run this query., SQL state 37000 in SQLExecDirect in C:\xampplite\htdocs\Register\index.php on line 176Seems like I need to convert my text password to Binary(16),but I dont know how please help me or contact me at godlydanny@hotmail.com for further assistant. I am willing to pay if anyone can do this registration system for me.Thank you for your kind attentionSincerely,Danny<?php$ipLog='ipLogFile.txt';$date=date("Y-m-d H:i:s");$register_globals = (bool) ini_get('register_gobals');if ($register_globals) {$vis_ip = getenv(REMOTE_ADDR);}else {$vis_ip = $_SERVER['REMOTE_ADDR'];}function recordData($vis_ip,$ipLog,$date,$username,$mail){//$filePointer = fopen($ipLog,"a+");//$logMsg = $date."][".$vis_ip."][".$mail."][".$username."\n";//fputs($filePointer,$logMsg);//fclose($filePointer);}function checkLog($vis_ip,$ipLog){global $valid; $ip=$vis_ip;$data=file("$ipLog");foreach ($data as $record){$subdata=explode("][",$record);if ($ip == $subdata[1]){$valid=0;break;}}}//checkLog($vis_ip,$ipLog);// error reportingerror_reporting(E_ALL);ini_set('display_errors','on');// configuration$config = array('db_username' => 'sa', // database username'db_password' => 'password', // database password'db_dsn' => 'odbc_users', // system DSN to the database'template' => 'registration.tpl', // registration template path/filename'debug' => false, // show SQL errors if true);// HTML errordefine('UI_ERROR','<span class="error">%s</span>');// if submittedif(strtolower($_SERVER['REQUEST_METHOD']) == 'post') {checkLog($vis_ip,$ipLog);$username = $_POST['username'];$password = $_POST['password'];$mail=$_POST["email"];$emailresult=preg_match("/^[^@ ]+@[^@ ]+\.[^@ ]+$/",$mail,$trashed);$error = array();// validate usernameif(!ctype_alnum($username)) {$error['username'] = sprintf(UI_ERROR,'Illigal characters in the username');}elseif ((StrLen($username) < 1) or (StrLen($username) > 8)) {$error['username'] = sprintf(UI_ERROR,'Username must be between 1-8 characters');}elseif ((StrLen($password) < 1) or (StrLen($password) > 8)) {$error['password'] = sprintf(UI_ERROR,'Password must be between 1-8 characters');}elseif ($valid =="0") {$error['iplocked'] = sprintf(UI_ERROR,'You can not create more accounts with us');}// validate passwordelseif(!ctype_alnum($password)) {$error['password'] = sprintf(UI_ERROR,'Illigal characters in the password');}elseif(!$emailresult){$error['email'] = sprintf(UI_ERROR,'Please enter a valid email');}// no errors, continue to username checkif(empty($error)) {// db connect$conn = odbc_connect($config['db_dsn'],$config['db_username'],$config['db_password']);// check about account name is taken$check = "SELECT[name] FROM [users]WHERE[name]='%s'OR[name]='%s'OR[name]='%s'OR[name]='%s'";$check = sprintf($check,$username,strtolower($username),strtoupper($username),ucfirst($username));$exec = odbc_exec($conn,$check);// check for errorsif(!$exec && ($config['debug'] === true)) {echo odbc_errormsg($conn);die();}// is the account registered?$data = odbc_fetch_array($exec);if($data !== false) {$error['username'] = sprintf(UI_ERROR,'Account already registered,please choose another name');} else {//include 'Password.php';///WRITE DATArecordData($vis_ip,$ipLog,$date,$username,$mail);// encode password//$password = Password::encode($password);//$Salt = $username.$password;//$Salt = md5($Salt);//$Salt = "0x".$Salt;// prepare sql$sql = "INSERT INTO[users] ([name],[passwd],[Prompt],[answer],[truename],[idnumber],[email],[mobilenumber],[province],[city],[phonenumber],[address],[postalcode],[gender],[birthday],[creatime],[qq],[passwd2])VALUES('".$username."','".$password."','','','','','','','','','','','','','','','','')";// insert user$result = odbc_exec($conn,$sql);if(!$result && ($config['debug'] === true)) {echo odbc_errormsg($conn);die();}}}}include $config['template'];?> |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-12-07 : 08:57:05
|
Do not use single quote around the password columntry this.VALUES('".$username."',".$password.",'','','','','','','','','','','','','','','','') N 56°04'39.26"E 12°55'05.63" |
 |
|
godlydanny
Starting Member
25 Posts |
Posted - 2010-12-07 : 09:07:08
|
quote: Originally posted by Peso Do not use single quote around the password columntry this.VALUES('".$username."',".$password.",'','','','','','','','','','','','','','','','') N 56°04'39.26"E 12°55'05.63"
Thank you very much Peso, you resolved that problem. But now my username getting problems too, Could you help me?my username i inserted is called "testing"than this error poped outWarning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The name 'testing' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted., SQL state 37000 in SQLExecDirect in C:\xampplite\htdocs\Register\index.php on line 176thank you for answer from last postBest regards,Danny |
 |
|
Lumbago
Norsk Yak Master
3271 Posts |
|
godlydanny
Starting Member
25 Posts |
Posted - 2010-12-07 : 09:41:48
|
quote: Originally posted by Lumbago I really hate this cross-posting, keep it all in one place! -> http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=153889- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com
Sorry , I am in a rush to finish this script that is why i posted in 3 sections. Just to get attention from more professionals like you guys.Sincerely,Danny |
 |
|
|
|
|
|
|