Issue with MySQL INSERT via PHP mysql_query -


i'm having problems bizarre problem when trying insert record mysql via php , wondering if shed light on it, because i'm out of ideas now.

database table:

field       type        null    default comments userid      bigint(20)  no      autoincrement userguid    text        no        serverid    int(11)     no        username    text        no        passwrd     text        no        prompt      text        no        answer      text        no        email       text        no        verified    int(11)     no  0     language    text        no        gender      int(1)      yes     null      dateofbirth int(11)     yes     null      country     int(11)     yes     null      postcode    text        yes     null      state       text        yes     null      town        text        yes     null      

snippit of relevant php code...

public function signupuser($uid, $pwd, $prompt, $answer, $email, $lang, ... &$result)  {     $guid = $this->getguid();      $serverid = 1;     $result = mysql_query("insert user(userguid, serverid, username, passwrd, email) " +                                     "values ('$guid', $serverid, '$uid', '$pwd', '$email')"); 

before tells me should using mysqli, parameterising queries , like, please aware php/mysql local test harness only, on private network , development purposes until real web service (dotnet/oracle) comes available.

so if call function above suitable parameters, $result comes with...

"you have error in sql syntax; check manual corresponds mysql server version right syntax use near '0' @ line 1"

but if reduce query just...

$result = mysql_query("insert user(userguid, serverid, username, passwrd) " +                                         "values ('$guid', $serverid, '$uid', '$pwd')"); 

it works! happily inserts record (despite there being nulls in not null fields!?!) add further complications, if run (original) query suitable values e.g.

insert user(userguid, serverid, username, passwrd, email) values ('guid', serverid, 'uid', 'pwd', 'email') 

directly against database via phpmyadmin, works!!

this driving me nuts. i've tried changing field names, nullability, order, fields use in query (after first 4 work), values - none of makes difference. seems if doesn't want more 4 fields.

please... anyone...? @ loss understand why won't accept fifth field, makes no sense can see. unfortunately error returned of no @ all, vague , seems equivalent of oh-so-useful "errors occurred" ms.

if have change on mysqli i'd prefer not have re-craft test harness if can avoid it.

edited after revelation: take in comments concatenation operator in php absolutely . not + put money problem right there... didnt see on first look.

in past ive run odd troubles similar - , able solve encapsulating table , column names in backticks columnx, columny - try adding space between table name 'user' , parenthesis containing column names in sql syntax

mysql_query("insert user(userguid, serverid, username, passwrd, email) " +                                 "values ('$guid', $serverid, '$uid', '$pwd', '$email')"); 

take @ this question? similar yours successful results

hope of assistance


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -