i need help again... T.T

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
newbi
Forum Newbie
Posts: 11
Joined: Thu Jan 08, 2004 12:58 am
Contact:

i need help again... T.T

Post by newbi »

$addStmt = "Insert into $tableName1(order_no, username, item_no, quantity, date) values('%d','%s','%s','%d','%s')";

...statement to connect db....

//Execute the statement
if(!mysql_query(sprintf($addStmt,$order_no,$username,$item_no,$quantity,$date),$link))
{
DisplayErrMsg(sprintf("Error in executing %s stmt",$stmt));
DisplayErrMsg(sprintf("error:%d %s",mysql_errno ($link),
mysql_error($link)));
exit();
}

---------------------------------------------------------------------------------
($addStmt,$order_no,$username,$item_no,$quantity,$date),$link))
---------------------------------------------------------------------------------
Sorry ! i having troble again . the values i insert into db "date". can i use %s ?
and the statement here...table field can represent in $order_no ? or just put the field name "order_no" ?
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

You have to use date() then any arguements inside the ()'s
User avatar
phpcoder
Forum Contributor
Posts: 158
Joined: Sat Nov 02, 2002 1:18 pm
Location: Manchester, UK

Post by phpcoder »

yep u can use '%s' for date .

Code: Select all

if(!mysql_query(sprintf($addStmt,$order_no,$username,$item_no,$quantity,$date),$link))
here u dont have to use table field name here u have to provide values to these fields here u have 2 use variables names doesnt matter .
Post Reply