![]() |
Comments Not Inserted Into Database
I've looked around my code multiple times but can't find any problematic areas. It doesn't help that there are no error messages either. I don't know, many I'm overlooking something. Anyway, the problem is...well that the script isn't working right. Not too sure what the exact problem is. I mean, nothing is inserted into the database table. No empty columns are inserted, just nothingness. When I insert comments manually, there are displayed correctly, so its just something with the inserting. What baffles me is this is almost exactly the same code used on another page where the commenting is working properly.
PHP Code:
|
Do you just get a white blank page when you run it?
Are you sure that error reporting is enabled ... so you don't just get a white page when it fails? Add the lines in red ... after the query to make sure it's getting to that part. if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "finished"; exit; . |
Quote:
|
Instead of using NOW() to insert a date into the database, try creating a PHP timestamp, format it as you need it then try inserting the variable.
In my PHP book, it shows in one example to insert using now() but when I tried it, it didn't work. Soon as I created a php timestamp, it worked. Just a thought. Also, what is different in this script to your last script? Regards, LC. |
Just eliminating obvious things:
If the 'date' field is a time-stamp field that it doesn't require assigning NOW(). You haven't just omitted the final closing bracket } ? |
Quote:
Quote:
|
This line:
if ($_POST['submitted'] == 1) { Maybe that "if" statement is false and is skipping over everything? Temporarily change it to this, so it's always true: if ($x=1) { |
Posted-data are initially strings, or arrays of strings:
PHP Code:
|
Quote:
Quote:
|
PHP Code:
|
Quote:
PHP Code:
|
You are using $article to fetch rows from the database. When there are no more rows, $article will be false.
|
yes and? I'm sorry but I seemed to have missed your point.
|
You say that everything works if you manually enter your querys, but when you have the script insert it, it doesn't work?
You have found the problem then. Echo your query statement, instead of executing it, and post it here. It is 100% a syntax error, if what you're saying is true. Edit: True not 100% - directly atleast - any problem with his variables is a problem with his query syntax aswell |
No, there is no guarantee that there exists a syntactical error with the SQL statement. This alone could be a problem here though:
'$subcategory' as it stands out given that its populated from an 'id' could possibly be an integer. MySQL can be configured to strict datatyping.Given the check on the mysql_query function doesn't produce an error report with the mysql_error indicates to me its not syntactical. My take on the description is that it works when manually entered (presumably using a query directly on the client or with something like PHPMyAdmin). Based on what I see here and what the described output is, my first suggestion is to open your error reporting up: PHP Code:
If not, post more code. This isn't by itself (we can see a syntactical fault with a missing end brace if it were by itself), so we cannot tell looking at this that its even possible to reach this branch statement. |
| All times are GMT +1. The time now is 12:37 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.