简体   繁体   中英

Data not going into Table (mySQL) (no errors coming up)

I'm building a website that allows people to report problems to others, and thought it would be useful to store each problem in a table. However when I run the code the data isn't entered, when I turned on errors for mysql with or die(mysql_error()); at the end, I got nothing. just a white page.

Here is my insert statement in full. Is there any reason as to why it might not work, or why errors just don't show up?

$sql = "INSERT INTO reported_problems (time, Full Name, E-mail, Phone Number, House Number, First Line, City, Postcode, Problem Type, Description, Urgency) VALUES(now(),'$fullname','$tenantemail','$phonenumber','$housenumber','$streetname','$city','$postcode','$typeofproblem','$probdesc','$severity_desc')";
$query = mysqli_query($db_conx, $sql) or die(mysql_error());

You have spaces in your column identifiers. This can be solved by wrapping your column identifiers in ticks:

$sql = "INSERT INTO reported_problems (`time`, `Full Name`, `E-mail`, `Phone Number`, `House Number`, `First Line`, `City`, `Postcode`, `Problem Type`, `Description`, `Urgency`) VALUES(now(),'$fullname','$tenantemail','$phonenumber','$housenumber','$streetname','$city','$postcode','$typeofproblem','$probdesc','$severity_desc')";

FYI, having column names that are keywords/function names, contain dashes, and with spaces are both discouraged. Use camel case or underscores if possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM