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!
Hi,
My program works on WAMP (PHP Version 5.5.12) running on my machine. However, the same program will not run on remote server (PHP Version 5.4.32). Basically, I'm trying to insert values obtained from a form into a database. I've checked and rechecked the table I'm inserting into and I can't find anything wrong with it. The trouble is it's hard to debug a PHP program. Unlike, say, C++ which requires a compiler, you can trace the program line by line to look for errors. That's not possible with PHP and makes it so much harder to look for faults.
The relevant functions used to send data to database are shown below. insert() is returning false every time and I can't understand why! I wonder if anyone can suggest where things might be going wrong. I would be very grateful.
Have you tried tracking the error message? If the query itself failed then there will be an error message you can surface to your code to find out why.
If not the query then the only other way you could get false is if $fields is empty. Checked that yet?
The only way insert() can return false is if $this->_query->execute() fails. Maybe do a print_r($this->_query->errorInfo()) if it fails to see the database error?
Previously it said "Unknown column 'address' in 'field list'". Now it's saying "Unknown column 'postcode' in 'field list' ". There is nothing wrong with the fields in the database. I've checked them a hundred times. There is something wrong with the database. Could this be a problem with the server rather than my coding? Please help?
public static function salt($length)
{
$intermediateSalt = md5(uniqid(rand(), true));
return(substr($intermediateSalt, 0, $length));
}
Result is my program works on a remote server with operating system linux but not on a remote server using windows operating system, my program is intended for latter. I still get:
Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'postcode' in 'field list' ) Problem creating an account!