elis Posted September 3, 2008 Share Posted September 3, 2008 I've just started working on a project that someone else started, he used the prepare() and execute() statements, which I have no previous experience/knowledge of since I tend to stick with the old fashion query codes. I'm trying to familiarize myself with this type of coding, so my first question is: are the above statements not compatible with PHP 5.2.6? I've done some of my own searching and have found mixed answers. Some people say it's not compatible, other people say it is. I ask because while trying to test the code on my own computer, I receive the following error: Fatal error: Call to a member function execute() on a non-object in C:\wamp\www\Tests\run.php on line 5 (I believe the computer that's running the actual script I'm working on may have a different PHP version than I, I haven't actually checked yet.) The actual coding that outputs the error is: <?php $db_connection = new mysqli("localhost", "user", "password", "db"); $statement = $db_connection->prepare("SELECT thing FROM testops WHERE id = '2'"); $statement->execute(); ?> (The above code may be incorrect, I'm still learning ???) My second question is: As I've stated before, I have no knowledge of executing queries with the above method. Would anyone happen to know of an idiot, and I mean idiot-proof tutorial of how these work, in the most laymen terms possible? I've used PHP.net's explanation (http://de2.php.net/pdo-prepare), but it successfully managed to go over my head. Link to comment https://forums.phpfreaks.com/topic/122526-two-quick-questions-execute/ Share on other sites More sharing options...
Mchl Posted September 3, 2008 Share Posted September 3, 2008 It's not PDO but mysqli extension, which is 'improved' version of good old mysql. Hope that this link will be of more help prepare() and execute() are methods of mysqli object and are used to execute so called 'prepared statements'. The error you get probably means, that connection to the mysql server failed. Link to comment https://forums.phpfreaks.com/topic/122526-two-quick-questions-execute/#findComment-632632 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.