mysql LAST_INSERT_ID() is causing some SQL problems when passing back value retrieved

666bloody666

New Member
I need some help figuring out why the following scenario does not work. I'm trying to retrieve a value from the last updated ID in mysql, then pass that value via javascript over to an ajax call which calls a .php page, which also calls another function "ZEND_emaiL" in a different php page.In the very first php page that retrieves the id from mysql LAST_INSERT_ID(), if I hard code the value "100" it works, but if I use the value returned from LAST_INSERT_ID() it causes a failure.Here's the php code for the LAST_INSERT_ID():\[code\]$sql='SELECT LAST_INSERT_ID();';$last_updated_id = $db->get_var( $sql );$last_updated_id = $last_updated_id+0;//make intecho $last_updated_id; //send output back to the ajax callvar_dump($last_updated_id); ------------->RETURNS **int 149**\[/code\]if I send back a hard coded "100" like this: \[code\]echo 100;\[/code\] then it works.Any ideas? Thanks for your help in advance.The following are values retrieved from the php page that contains the ZEND_email() function. I grabbed these for debugging purposes hoping it would help.RETURN VALUES for Hard Coded:\[code\]var_dump($n_id);---------->Returns **int 100**var_dump($sqlresult);----->Returns **resource 24**var_dump($row);----------->Returns **array of data to parse through**\[/code\]RETURN VALUES FOR Passed in Variable (Fails):\[code\]function ZEND_email($to, $from="", $subject="", $msg="", $notif_id='', $root_dir=""){var_dump($notif_id);---------------------->RETURNS **string '100'**$notif_id = $notif_id+0;//convert to intvar_dump($notif_id);---------------------->RETURNS **int 100**$n_id = $notif_id; $xsql = $sql_str->SQL_SELECT_all_notif_attachments($account_id, $n_id);$sqlresult=mysql_query($xsql);$row=mysql_fetch_row($sqlresult);var_dump($n_id);---------------->RETURNS **int 100**var_dump($sqlresult);----------->RETURNS **resource 24**var_dump($row);----------------->RETURNS **boolean false**}\[/code\]
 
Back
Top