If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

PHP MySQL insert statement not working.

ok here is the problem code
the output here is the error message i have programmed for when the query doesn't work, i know all of my fields are getting posted and collected by the variables but it doesn't insert the fields, i can't seem to track down the problem here.

i assigned the query to a variable to begin with but i read online that the mysql_query statement sometimes does not work when passing a variable rather than the inline statement, i changed it to see if that would fix my issue.

the error message i get is the message i created here without any specific SQL error appended to the end of it.

maybe replacing the deprecated functions will make this work i will try that now thanks.

Also, my suspicion is that the first value should be NULL instead of '', assuming it's an auto-numbered primary key? (Actually, if that's the case, you could provide a list of columns that does not include that field, then you don't have to have it in your VALUES() clause; besides which using an explicit field list avoids nasty bugs when your database table is altered in any way that changes the default field order.

OK i have it now working, but its all using the now deprecated mysql_* is there a tutorial or something anyone can share that will help with converting over to PDO? i tried using mysqli_ but for some reason my site was not allowed access to the site while using the improved version. giving me this message.

1 - Why are you doing a query for all records when the whole point is to do an insert? Are you actually using an id that represents the number of rows at a given time? No Good. What happens if you delete a row?
2 - You must check the results of the query before trying to use the results!! Your check for num rows will fail if $result is not valid because the query failed, so swap them.
I don't see the error checking code I provided.

OK i have it now working, but its all using the now deprecated mysql_* is there a tutorial or something anyone can share that will help with converting over to PDO? i tried using mysqli_ but for some reason my site was not allowed access to the site while using the improved version. giving me this message.

1 - Why are you doing a query for all records when the whole point is to do an insert? Are you actually using an id that represents the number of rows at a given time? No Good. What happens if you delete a row?
2 - You must check the results of the query before trying to use the results!! Your check for num rows will fail if $result is not valid because the query failed, so swap them.
I don't see the error checking code I provided.

the $result variable is for checking for the updated fields, they display further down on the page, i just declared it at the top so i did not have to write 2 variables to get the number of rows.

if this is a bad way of inserting User ID how do you insert a value into a row with an auto increment ID field?