Jump to content

PHP Warning: mssql_query()


fillfry

Recommended Posts

I have received this in the php error log:

 

PHP Warning:  mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: message: Line 1: Incorrect syntax near '='. (severity 15)

 

coming from somewhere in here:

 

$query = "UPDATE student_info SET f_name = '".$post_vars['f_name']."', m_name = ". wrap($post_vars['m_name']) .", l_name = '".$post_vars['l_name']."', email_personal = '".$post_vars['email_personal']."', phone_number = '".$post_vars['phone_number']."', contact_method = '".$post_vars['contact_method']."', date_submitted = '".date('Y/m/d')."', gender = '".$post_vars['gender']."' WHERE cwid = ".$cwid;

 

if(!($result = mssql_query($query)))

die("Database Error: you might have already submitted the form. Error 1<br/>" . $footer);

 

I am semi new to php and I acquired this with the job...  Any help or suggestions would be AWESOME!!!!  Thanks

Link to comment
https://forums.phpfreaks.com/topic/232323-php-warning-mssql_query/
Share on other sites

Thanks Maq!  When I added the single quotes I received the same error as before, just with ...Incorrect syntax near 'm_name'...

 

early on, I thought it had something to do with the

 

  if(!($result = mssql_query($query)))

    die(...)

 

cause those are the lines that the error_reporting(E_ALL) is giving me in the browser

Warning: mssql_query() [function.mssql-query]: message: Line 1: Incorrect syntax near 'Testing'. (severity 15)

 

$query = "UPDATE student_info SET f_name = '".$post_vars['f_name']."', m_name = '". wrap($post_vars['m_name']) ."', l_name = '".$post_vars['l_name']."', email_personal = '".$post_vars['email_personal']."', phone_number = '".$post_vars['phone_number']."', contact_method = '".$post_vars['contact_method']."', date_submitted = '".date('Y/m/d')."', gender = '".$post_vars['gender']."' WHERE cwid = ".$cwid;

this is what I get when I echo the $query:

UPDATE student_info SET f_name = 'firstnameTest', m_name = ''Testing'', l_name = 'lastnameTest', email_personal = '[email protected]', phone_number = '000-000-0000', contact_method = 'email', date_submitted = '2011/03/31', gender = 'M' WHERE cwid = 000000000

 

Warning: mssql_query() [function.mssql-query]: message: Line 1: Incorrect syntax near 'Testing'. (severity 15)

 

 

OK, I didn't know your wrap() function just put single quotes around the value.  Is there a specific reason you're using that function?  Other than that your query looks fine.  The only other thing I can suggest is getting rid of the wrap() function and just putting single quotes there manually like the other values.

Yeah, apparently.  Thanks a lot, that worked.  Now on to the other errors in the same file!!!

 

Here is the wrap():

function wrap($it, $d = "'"){

if($it){

if(is_numeric($it)){

return $it;

}else{

return $d . $it . $d;

}

}else{

return 'NULL';

}

}

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.