Jump to content

help with undifined functions I JUST DON'T NO


jeppers

Recommended Posts

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.