I was recently given a task to add a table to a MS SQL Server and a few PHP
pages to insert, edit, delete and display records from this table.
The site is currently running off an Linux Server with PHP 4.03 and a
Windows NT box running MS SQL Server 7.0.  The SQL Server is unreachable
using MS Tools because it is behind a firewall.

I created a table using the SQL command "CREATE TABLE()" [see source below].
I used MS SQL Manager to generate the SQL Script. I added records later on
using "odbc_exec()" and the SQL Command "INSERT" and everything was fine.
When I tried to retrieve the records using "SELECT * FROM TableA" [see
source below], I got the following error "Warning: SQL Error:
[OpenLink][ODBC][Driver]General error, SQL state S1000 in SQLExecDirect in
/[php file path]... line 9"

I have check the name of the table and it's existence using the following
SQL Query "SELECT * FROM sysobject WHERE name = 'TableA'" All other tables
that were created by the original developer using the MS Tools can be
queried using the same php source.

John Nunez

PHP source (I have removed the error check for display purposes only.)
$conn = odbc_connect("db","name","password");
$dbresult = odbc_exec($conn, "SELECT * FROM TableA");
$tbContent = odbc_result_all($dbresult);
echo $tbContent;


SQL Script
CREATE TABLE [dbo].[TableA] (
    [taID] [int] IDENTITY (1, 1) NOT NULL ,
    [Title] [varchar] (255) NULL ,
    [Message] [varchar] (5000) NULL ,
    [ImgPath] [varchar] (1000) NULL ,
    [ImgHeight] [int] NULL ,
    [ImgWidth] [int] NULL ,
    [EntryDate] [datetime] NULL ,
    [Display] [varchar] (1) NULL

PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to