Can anyone tell me the odbc functions to retrieve and display data from an existing SQL server? I tried using odbc_exec, odbc_fetch_row, but that ain't working. The page just comes back blank. This is one example of what I tried that didn't work: <html> <head> </head> <body> <?php $conn = odbc_connect('xyz.com','login','pass'); if ($conn <=0) { echo "Error in connection<BR>"; exit; } else { echo "<P>Connection successful\n"; }; $query = 'SELECT * from XYZ_ITEM'); $result = odbc_exec($conn, $query); while(odbc_fetch_row($result)){ $ITEM=odbc_result($result, "ITEM"); echo "$ITEM"; } ?> </body> </html>
^^ He's using ODBC, so why would he use mysql_connect() ? Have a look at php.net's odbc_fetch_row() manual. There are some examples that may help. Also try putting these lines at the top of your code to make sure all possible errors are displayed: error_reporting(E_ALL); ini_set('display_errors', '1'); PHP:
I added your code to display errors, but the page still comes back blank. If I just leave the code to connect and return "connection successful" or "error in connection" one of those strings is returned, but nothing else is being displayed when I add anything else.
I found the combination of the following lines very useful, as the fieldnames will be simply available as variables by their names. $query="select fieldname from table"; ... $line=mysql_fetch_assoc($query_result); extract($line); echo $fieldname; Code (markup):