[prev in list] [next in list] [prev in thread] [next in thread] 

List:       phplib
Subject:    Re: [PHPLIB] Importing Users: moderately urgent.
From:       Chester McLaughlin <chester23 () home ! com>
Date:       2000-01-31 22:17:19
[Download RAW message or body]

$db->query(sprintf("SELECT * FROM %s WHERE name_first = '%s' AND 
name_last = '%s'", $table_name, $firstname, $lastname));


Try using sprintf like shown above (the definitions and instructions 
on when to use %s or %d or whatnot are in the Docs.

>I need to create a variable to hold the name of a table column. How do I use
>the variable in a query? For example, with a variable called
>"$current_theme", I want to do something like:
>
>mysql_query("select * from themes where name = $current_theme", $db);
>
>For reasons dictated by my purposes, I can't just type in the name of the
>column - it must go through a variable. What is the correct way to do this?
>
>Thanks...
>--
>Damien J. Moody
>Technology Coordinator
>damienm@vsarts.org
>
>Think about it:
>Plato was an object-oriented programmer.
>
>-
>PHP3 Base Library Mailing List. Send messages to <phplib@lists.netuse.de>.
>To unsubscribe, send "unsubscribe" to <phplib-request@lists.netuse.de> in
>the body, not the subject, of your message.

-
PHP3 Base Library Mailing List. Send messages to <phplib@lists.netuse.de>.
To unsubscribe, send "unsubscribe" to <phplib-request@lists.netuse.de> in
the body, not the subject, of your message.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic