tags:

views:

70

answers:

3

I have a simple table:

describe chat_public_messageboard ;

    +--------------+---------------+------+-----+---------+----------------+
    | Field        | Type          | Null | Key | Default | Extra          |
    +--------------+---------------+------+-----+---------+----------------+
    | message_id   | int(100)      | NO   | PRI | NULL    | auto_increment |
    | message_from | varchar(255)  | NO   |     | NULL    |                |
    | message_to   | varchar(20)   | NO   |     | NULL    |                |
    | message_body | tinytext      | NO   |     | NULL    |                |
    | message_time | varchar(50)   | NO   |     | NULL    |                |
    | welcome_msg  | enum('0','1') | NO   |     | 0       |                |
    +--------------+---------------+------+-----+---------+----------------+

When I do an insert from the terminal, it works fine: select * 314 | sweety_margs | daffy | what did you say?

INSERT INTO chat_public_messageboard ( message_from , message_body , message_time , message_to , welcome_msg ) VALUES ( 'pdz' , 'what did you say?\n' , '1260948972' , 'pdz2' , 1 ) "

But when I send this exact query through the mysql db->query() function, the question mark turns to NULL

$query = $querystring = "INSERT INTO chat_public_messageboard ( message_from , message_body , message_time , message_to , welcome_msg ) VALUES ( 'pdz' , 'what did you say?\n' , '1260948972' , 'pdz2' , 1 ) " ;
db->query($querystring);

-

select *
    314 | sweety_margs  | daffy          | what did you sayNULL

Thanks.

+3  A: 

The ? is typically used as a placeholder for parametrized arguments in the PHP interface to various SQL. Thus, it's probably thinking it's a placeholder that you never specified a value for (and thus is NULL).

Amber
+1  A: 

What PHP framework are you using? I'm suspecting that the framework is using '?' to bind parameters into your SQL statement and since you didn't provide the parameter it defaults to NULL.

Lukman
+1  A: 

It looks like it thinks you are trying to add a parameter to that query. http://stackoverflow.com/questions/675010/what-is-the-question-marks-significance-in-mysql

fredrik