Hi all,

I have a small problem and I just can't find any online doc about this since searching for '%s' or %d just give me the results I need.

I know some PHP and I'm used to write into a MySQL database with a string something like this:

INSERT INTO TABLENAME (code, role_id, user_id) VALUES ('$code', '$role_id', '$user_id');

Now I found a module I want to adjust and use for my own site and I noticed drupal uses this a bit different to insert data into the tables

it uses something like this:

INSERT INTO {rolecode_codes} (code, role_id, user_id, expires) VALUES ('%s', %d, NULL, %d);

What do those '%s', %d stand for and what value do I have to put there if I want to simple add another field for simple text??

I tried it all but won't seem to get anywhere. This most likely just some small PHP stuff I don't know about yet, but I also can't find this anywhere on the net.
A link that explains this to me or a small explanation would be very appreciated.

Thanks a lot

Tino

Comments

styro’s picture

http://api.drupal.org/api/function/db_query/5

They are placeholders to prevent sql injection attacks.

more info:

http://api.drupal.org/api/group/database/5

--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal

DonTino’s picture

thanks a lot

all I needed to know

-----
Discover The Divine Truth - Are You Ready?