At 09:52 06.11.2002, Steve Jackson said: --------------------[snip]-------------------- >function get_order_numbers() >{ >$conn = db_connect(); >$query = "select orders.orderid from orders, email where orders.orderid >= email.orderid and email.checked='no'"; >$result = mysql_query($query) or die("Error: cannot select >orderid<BR>$query<BR>".mysql_error()); >while( $row = mysql_fetch_array($result)) > { > extract($row); > $orderid = $row; > $query2 = "SELECT * FROM orders WHERE orderid=\"$orderid\""; > $result2 = mysql_query($query2) or die("Error: cannot fetch >order<BR>$query2<BR>".mysql_error()); > extract(mysql_fetch_array($result2)); > } >} > > >The SQL works Ok. At least I get no errors now. >It's my PHP to display the SQL I think I get a result of 8 errors with >the following message. >Warning: Wrong datatype in call to extract() in >/www/u1255/eadmin/eshop_fns.php on line 40. >Where line 40 is: >extract(mysql_fetch_array($result2));
Steve, maybe the second fetch doesn't return anything because the resultset is empty? You should assign the second fetch to a variable and test it before passing it to extract (as with the first fetch): $row2 = mysql_fetch_array($result2); if (is_array($row2)) { extract($row2); // ... } >What does extract do? I am under the assumption it extracts row >information so why a datatype error? >Any pointers? --------------- [doc] --------------- int extract ( array var_array [, int extract_type [, string prefix]]) This function is used to import variables from an array into the current symbol table. It takes an associative array var_array and treats keys as variable names and values as variable values. For each key/value pair it will create a variable in the current symbol table, subject to extract_type and prefix parameters. --------------- [/doc] -------------- May I suggest getting the "Camel Book", or at least consult the EXCELLENT online PHP manual at http://www.php.net/manual/en/. If you read about mysql_fetch_array you'll notice the additional optional parameter "result_type". Since you're going to pass the resulting data to extract it helps to specify MYSQL_ASSOC as result_type, this will omit the numerically indexed data from the fetched array, which isn't used by extract() anyway. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/