PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Im currently working on a uni assignment using php and mysql the problem is when I try to execute a mysql query using the mysqli_query function I get an error code 0. Im not sure what this means (from my research it may have something to do with not being able to start mysql). The system (CentOS) that the script is running on I have limited access to but I can confirm mysql is running and I can connect to it via the mysql prompt. Here is a the code for you to look at as well:
You're getting a problem with the mysqli_query, not the mysqli_connect. There was no problem with connecting. That means mysqli_connect_errno will return 0. Try mysqli_errno (and mysqli_error) instead.
Couple problems with the query: it has a rogue apostrophe, and it doesn't put quotes around the $_POST values (which are strings so it's necessary).
$SQLstring = "INSERT INTO $TableName VALUES ('$_POST[field1]','$_POST[field2]','$_POST[field3]')";
Also, you need to learn right now that POST, GET, and COOKIE data is NOT safe to put directly into a SQL query. Run the string through mysql_real_escape_string first.