mekha Posted September 3, 2012 Share Posted September 3, 2012 (edited) 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 ? Edited September 3, 2012 by mekha 1 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 (edited) what is inside fetch()? add it $row = fetch($result);var_dump($row); also make sure returned number of rows greater than 0. Edited September 3, 2012 by birbal 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
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now