Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/10/2023 in all areas

  1. People can not help you debug if you don't provide information about the failure. How is it that you know it doesn't insert in the database? Is it because there's a 500 error, or the script runs and displays "Booking failed" or what? You don't provide the form code, so that could be an issue. Probably the statement execution is failing with a sql error but you don't capture/log the error. Beginners seem to always do what you are doing and create a bunch of variables that just copy values from the superglobal for no reason. $Bus_id =$_POST['Bus_id']; $city = $_POST['city']; $Destination = $_POST['Destination']; //etc Several things jump out at me: The $_POST array is already an array variable, and you can use it to pass the values. Don't make a bunch of other variable names for no reason There is an established variable naming standard for php. It's camelcase. Don't make a variable named $Bus_id. It should be $busId. $Destination should be $destination. Be consistent with your html attribute naming. You are all over the place. You have 'Bus_id' and 'city' and 'Destination'. The most commonly accepted convention is "all lowercase, with words separated either by a '-' or an '_'. I would suggest underscore as html is often manipulated later with javascript, and the '-' is a symbol in javascript, but otherwise choose which one you like. So fixing your form input names 'bus_id' 'city' 'destination' The other question that arises in your code, is why you have a bus_id and not a city_id and destination_id? At any rate, I bring up the lack of rigor in your html and php variable naming, because lack of standards often lead to bugs that get traced back to inconsistent variable naming.
    1 point
  2. 1 point
  3. You do not use single-quotes around DB identifiers like the DB name, table name, column names, etc. Single quotes are only for string literals. Generally you simply do not quote the identifiers at all, there's no reason too unless you're trying to use reserved words or restricted characters (which you shouldn't do anyway). If for some reason you want to quote the identifiers, you do so using back-ticks (`).
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.