why i cant connect to mysqli?
Posted: Sun Sep 02, 2012 12:48 pm
i have this connection:
...and site_queries.php:
... and site.php:
and all the files in the same folder....why my code doesnt work ? the echo ?
Code: Select all
<?php
DEFINE('DATABASE_USER', 'xxxxxxxx');
DEFINE('DATABASE_PASSWORD', 'xxxxxxxx');
DEFINE('DATABASE_HOST', 'localhost');
DEFINE('DATABASE_NAME', 'xxxxxxx');
$mysqli = new mysqli(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
else {
//connected
}
?>
Code: Select all
<?php
function getfrompages()
{
$sqlStr = "select * from tbl_pages where page_id = ?";
return $sqlStr;
}
?>
Code: Select all
<?php
include "connection.php";
include "site_queries.php";
global $mysqli;
?>
<?php
$sql = getfrompages();
if ($result = $mysqli->prepare($sql))
{
$rekza = 1;
$result->bind_param("i",$rekza);
$result->execute();
$result->store_result();
$rowsZ = $result->num_rows;
}
if($rowsZ>0)
{
$row = fetch($result);
}
echo $row["page_title"];
?>