|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Insert query doesn't work
I am having trouble getting this simple insert query to work.
What small thing am i over looking?? PHP Code:
|
|
#2
|
||||
|
||||
|
I guess you mean the only query on that page.
What is the problem? Does the query not run? Does the query give errors? One thing I noticed was your query you have extra backslashes, not needed how you're doing it. PHP Code:
|
|
#3
|
|||
|
|||
|
Quote:
sorry about the bogus extra quotes. I saw those after i posted and removed them. i am not getting any errors from the query. i know the query is good, i matched against another insert query that i have that does almost the same thing. I am not event getting the print statement to display in the browser. This is my updated query: PHP Code:
|
|
#4
|
||||
|
||||
|
It's most likly one of your variables that isn't being set. i.e $c $i $dm or $mgdesc
Make sure each of them is valid, the only thing I see if that $dm isn't being set if you get to $message .= "When do you want this to show as the index page?"; |
|
#5
|
|||
|
|||
|
I ran through the variable line by line, reordered them in my insert statement, and still nothing.
|
|
#6
|
||||
|
||||
|
use a print or echo and find out where your script is running i.e right above
if( $c && $i && $dm && $imgdesc ) put print 'goes here<br>'; and right inside it put print 'goes inside<br>'; then you can see if your code is getting inside that if statement, if it is then something else is wrong, if it's not then that is the problem, if it doesn't reach your first if then something else is wrong. |
|
#7
|
|||
|
|||
|
Quote:
The mysql_error() is only called when there's actually no query done ... It should look more like this: if( $c && $i && $dm && $imgdesc ) { $sql = "INSERT INTO indexpage ( content , datemod , img , imgdesc , datetodisplay ) VALUES ( '$c', now(), '$i', '$imgdesc', '$dm' )"; $result = @mysql_query( $sql ) or die('Error: '.mysql_error()); echo '<p>Your changes have been added</p>'; print ( $sql ); } else { // one of these ($c$i $dm $imgdesc) is not set... } } Then you should get the mysql_error() .... if there's no error, this mean that one of your variables doesn't pass the "if" test ... try to echo them to see what they hold |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Insert query doesn't work |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|