0 Replies Latest reply on Jun 22, 2011 1:50 PM by steesfoy

    FB/PHP/MySQL Problem


      I originally posted this in the Flash Builder forum before seeing this one

      Hi All.. hope someone can help.


      I've started a very simple application and experiencing a problem regarding creating a new record in a MySQL database via PHP & Zend.


      Here's the snippet of AS:



                newLine.buy_price = cursor.current.buy;

                newLine.sell_price = cursor.current.sell;


                createLineResult.token = linesService.commit();




      Here's the snippet of PHP (all generated by FB):



           public function createLines($item) {


                $stmt = mysqli_prepare($this->connection, "INSERT INTO $this->tablename (supplier, sku, product_name, quantity, buy_price, sell_price) VALUES (?, ?, ?, ?, ?, ?)");



                mysqli_stmt_bind_param($stmt, 'iisiii', $item->supplier, $item->sku, $item->product_name, $item->quantity, $item->buy_price, $item->sell_price);






                $autoid = mysqli_stmt_insert_id($stmt);





                return $autoid;





      When I run the createLines() function then commit(), I get the following error popup from my application:



      MySQL Error - 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lines (supplier, sku, product_name, quantity, buy_price, sell_price) VALUES (?, ' at line 1

      #0 C:\wamp\www\XOM-debug\services\LinesService.php(119): LinesService->throwExceptionOnError()

      #1 [internal function]: LinesService->createLines(Object(stdClass))

      #2 [internal function]: ReflectionMethod->invokeArgs(Object(LinesService), Array)

      #3 C:\wamp\www\ZendFramework\library\Zend\Server\Reflection\Function\Abstract.php(380): call_user_func_array(Array, Array)

      #4 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(359): Zend_Server_Reflection_Function_Abstract->__call('invokeArgs', Array)

      #5 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(359): Zend_Server_Reflection_Method->invokeArgs(Object(LinesService), Array)

      #6 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(553): Zend_Amf_Server->_dispatch('createLines', Array, 'LinesService')

      #7 C:\wamp\www\ZendFramework\library\Zend\Amf\Server.php(629): Zend_Amf_Server->_handle(Object(Zend_Amf_Request_Http))

      #8 C:\wamp\www\XOM-debug\gateway.php(69): Zend_Amf_Server->handle()

      #9 {main}




      As as I see it, the parameters are not being replaced by the actual values, so MySQL is freaking out as it's getting question marks in the statements. What I don't understand is how this is happening! Everything is auto-generated by FB. I created a new project from scratch and used only drag & drop from the Data/Services panel to generate a form for data entry and got the same error.


      Any ideas!?