| | |
SQL problem - table names as variables
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2006
Posts: 8
Reputation:
Solved Threads: 0
Hi,
I have a slight problem. I am trying to create a mail service for a new game which I have started creating recently. Each user that registers also creates a table for their mail. As the usernames are variable and the table name is the username, I need to insert messages, subjects and "froms" into this variable table.
I am using the following code:
The problem is that it will not accept $to as the table name - it just comes up with some nasty error about the syntax of my insert statement. Can anyone help me on this, please?
I have a slight problem. I am trying to create a mail service for a new game which I have started creating recently. Each user that registers also creates a table for their mail. As the usernames are variable and the table name is the username, I need to insert messages, subjects and "froms" into this variable table.
I am using the following code:
MS SQL Syntax (Toggle Plain Text)
$to = $_SESSION["to"]; $subject = $_SESSION["subject"]; $message = $_SESSION["message"]; $from = $_SESSION["username"]; echo "To: $to<br>"; echo "Subject: $subject<br>"; echo "Message: $message<br>"; echo "From: $from<br>"; include 'connection.php'; IF ($to <> "") { IF ($subject <> "") { IF ($message <> "") { $rsusers = $conn->Execute("INSERT INTO $to (subject, message, from) VALUES('$subject', '$message', '$from')"); } } }
The problem is that it will not accept $to as the table name - it just comes up with some nasty error about the syntax of my insert statement. Can anyone help me on this, please?
•
•
Join Date: May 2006
Posts: 8
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by campkev
if you are using sql server, try running profiler to make sure that your php page is actually sending the script correctly
RC
•
•
Join Date: May 2006
Posts: 8
Reputation:
Solved Threads: 0
No, I couldn't find it - I am using Dreamweaver for all my webpages and just use SQL code by reading out of a book or searching on the internet.
The error it comes up with is as follows:
Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft OLE DB Provider for ODBC Drivers
Description: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.' in D:\Websites\ClarkeyBoy\wwwroot\gametrialversion\sendmail.php:76 Stack trace: #0 {main} thrown in D:\Websites\ClarkeyBoy\wwwroot\gametrialversion\sendmail.php on line 76
I have been trying to find a solution all evening but have got nowhere.
I have sort of managed to fix it - but now, whenever I go to the view mail page I get the following error:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
The error it comes up with is as follows:
Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft OLE DB Provider for ODBC Drivers
Description: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.' in D:\Websites\ClarkeyBoy\wwwroot\gametrialversion\sendmail.php:76 Stack trace: #0 {main} thrown in D:\Websites\ClarkeyBoy\wwwroot\gametrialversion\sendmail.php on line 76
I have been trying to find a solution all evening but have got nowhere.
I have sort of managed to fix it - but now, whenever I go to the view mail page I get the following error:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
![]() |
Similar Threads
Other Threads in the MS SQL Forum
- Previous Thread: finding a matches recursively
- Next Thread: chicken and egg problem
| Thread Tools | Search this Thread |





