mekha Posted September 3, 2012 Share Posted September 3, 2012 i have this connection: <?php$dbhost = 'localhost';$dbuser = 'zzzz_u';$dbpass = 'zzzzzzz';$dbname = 'zzzz_db'; $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);/* check connection */if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } $mysqli->query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'");?> ...and site_queries.php: [/color]<?php function getfrompages() { $sqlStr = "select * from tbl_pages where page_id = ?"; return $sqlStr; }?> ... and site.php: <?phpinclude "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"];?> and all the files in the same folder....why my code doesnt work ? the echo ? Link to comment Share on other sites More sharing options...
birbal Posted September 3, 2012 Share Posted September 3, 2012 what is inside fetch()? var_dump() the $row to see what does it holds. Link to comment Share on other sites More sharing options...
mekha Posted September 3, 2012 Author Share Posted September 3, 2012 i tryed:$row= var_dump($result); .. and no results :S Link to comment Share on other sites More sharing options...
birbal Posted September 3, 2012 Share Posted September 3, 2012 what is inside fetch()? add it $row = fetch($result);var_dump($row); also make sure returned number of rows greater than 0. Link to comment Share on other sites More sharing options...
mekha Posted September 3, 2012 Author Share Posted September 3, 2012 without results too...blank page Link to comment Share on other sites More sharing options...
birbal Posted September 3, 2012 Share Posted September 3, 2012 show the updated code Link to comment Share on other sites More sharing options...
mekha Posted September 3, 2012 Author Share Posted September 3, 2012 this is where i am showing my results: <?phpinclude "includes/site_includes.php";?><?php$sql = getfrompages();if ($result = $mysqli->prepare($sql)){$rekza = (int)1;$result->bind_param("i",$rekza);$result->execute();$result->store_result();$rowsZ = $result->num_rows;}if($rowsZ>0){$row = fetch($result);}echo $row[0]["page_title"];echo $site_url;?> this is the connection: <?php$dbhost = 'localhost';$dbuser = 'xxx';$dbpass = 'zzzzz';$dbname = 'yyy'; $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);/* check connection */if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; }$mysqli->query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'");?> this the query: <?phpfunction getfrompages(){ $sqlStr = "select * from tbl_pages where page_id = ?"; return $sqlStr;}?> Link to comment Share on other sites More sharing options...
mekha Posted September 4, 2012 Author Share Posted September 4, 2012 mm...ok thanks i succeed Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.