Problem in my add function

Hi there , am actually trying to add some informations but its keep going to ‘else’
any ideas ?

If you had actually done the things that were listed in your last thread, you would know why your code isn’t working. The error handling that it stated to use for database statement errors would have stopped code execution so that you would see the actual error that is occurring.

1 Like

I actually found a big difficulty to understand your reply on my last topic, is there any video explanation of them or something that can actually let me understand them ?
I just starting in php , not quite for 1 month now.

Thanks in advance,
Waiting your reply

I am completely new, so these are just thoughts, I do not know what you have tried and what I ask is just food for thought.

You said ‘keeps going to else’:
There are only 2 else statements, so

  1. The first else is simple, your $_Session[‘login’] variable is not set.
  2. The second else could be more complicated in my eyes. I see you are echoing the db connection string. So I assume that is set elsewhere, hopefully in your config file, and that the params are correct for attaching to you db. The mysqli_query returns true or false, which is what you are testing. So examine the connection and the query. If Id is an auto-incrementing field, have you tried ‘NULL’ or ‘default’ for that value?(I did read that empty quotes will work but they can throw warnings). Also I know I have issues with escape sequencing. Have you tried putting the ‘VALUES’ in a string and echoing it out to check your number of values?

Again, I am completely new and these questions are just off the top of my head. Also I must agree that error handling is very important. In c#, I always puse try{}catch{} statements to catch the inform me of proplems. For instance it might have caught my typing and spelling errors in the post, lol.

If the issue is English, google’s online translator does a good job with word form and word order for most languages.

For most of the items in that list, I specifically stated what you should do instead. Do you have a specific question about any items? If so, ask them one at a time.

Sponsor our Newsletter | Privacy Policy | Terms of Service