Page 1 of 1

i need help again... T.T

Posted: Sat Jan 17, 2004 12:29 pm
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" ?

Posted: Sat Jan 17, 2004 12:33 pm
by Straterra
You have to use date() then any arguements inside the ()'s

Posted: Sat Jan 17, 2004 1:00 pm
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 .