jeppers Posted February 13, 2011 Share Posted February 13, 2011 <?php require_once('includes/connection.php'); // connect to MySQL $conn = dbConnect('read'); // prepare the SQL query $sql = 'SELECT * FROM images WHERE caption LIKE BINARY "%maiko%"'; // submit the query and capture the result $result = $conn->query($sql) or die(mysqli_error()); // find out how many records were retrieved $numRows = $result->num_rows; ?> the problem is that it just won't let me run this line of code $result = $conn->query($sql) or die(mysqli_error()); i am not sure why but could it be something to do with my php please help <?php function dbConnect($usertype, $connectionType = 'mysqli') { $host = 'localhost'; $db = 'gallery'; if ($usertype == 'read') { $user = '####'; $pwd = '####'; } elseif ($usertype == 'write') { $user = '####'; $pwd = '####'; } else { exit('Unrecognized connection type'); } if ($connectionType == 'mysqli') { return new mysqli($host, $user, $pwd, $db) or die ('Cannot open database'); } } ?> hear is my connection code if that will help Quote Link to comment https://forums.phpfreaks.com/topic/227522-help-with-undifined-functions-i-just-dont-no/ Share on other sites More sharing options...
denno020 Posted February 13, 2011 Share Posted February 13, 2011 What is the error that you're given and on which line.. Denno Quote Link to comment https://forums.phpfreaks.com/topic/227522-help-with-undifined-functions-i-just-dont-no/#findComment-1173555 Share on other sites More sharing options...
jeppers Posted February 13, 2011 Author Share Posted February 13, 2011 Fatal error: Call to a member function query() on a non-object in C:\webs\comments.php on line 5 Quote Link to comment https://forums.phpfreaks.com/topic/227522-help-with-undifined-functions-i-just-dont-no/#findComment-1173557 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.