TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-04-2010, 09:01 AM   #1 (permalink)
The Visitor
 
Join Date: Nov 2010
Posts: 2
Thanks: 0
SanderDeclerck is on a distinguished road
Default mysqli troubles

Hi, this is my code to get my navigation from the database:
PHP Code:
$navigatie = array();
$mysqli = new mysqli(DB_HOSTDB_USERDB_PASSWORDDB_NAMEDB_PORT);
if(
mysqli_connect_errno())
    die(
"Kon geen connectie maken met de database: " mysqli_connect_error());
$q "SELECT anchorText, urlString FROM pagina WHERE parentId = -1 AND showInNavigation = 1 ORDER BY navigationSortIndex";

if(
$stmt $mysqli->prepare($q))
{
    
$stmt->bind_result($anchorText$urlString);
    
$i 0;
    echo 
$stmt->num_rows();
    while(
$stmt->fetch())
    {
        
$navigatie[$i] = array("anchorText" => $anchorText"urlString" => $urlString);
        
$i++;
    }
    
$smarty->assign("hoofdnavigatie"$navigatie);
    
    
$stmt->close();
}
else
{
    die(
"De hoofdnavigatie kon niet geladen worden: " $mysqli->error());
}

$mysqli->close(); 
The problem is that it returns 0 rows, but when i execute the same querry in mysql workbench, it does what it's supposed to do, returning 4 results. Have I made a mistake in my code somewhere?
SanderDeclerck is offline  
Reply With Quote
Old 11-04-2010, 09:28 AM   #2 (permalink)
The Visitor
 
Join Date: Nov 2010
Posts: 2
Thanks: 0
SanderDeclerck is on a distinguished road
Default

Ok, nevermind, i guess i can claim the "dumbest question award" in my first post here, i forgot $stmt->execute();
SanderDeclerck is offline  
Reply With Quote
Old 11-04-2010, 05:07 PM   #3 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by SanderDeclerck View Post
Ok, nevermind, i guess i can claim the "dumbest question award" in my first post here, i forgot $stmt->execute();
That problem is like forgetting a semi-colon, it is an easy error but commonly made. I know I forget it a lot.
__________________

Village Idiot is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing mysqli errors from showing vixxy Absolute Beginners 7 05-18-2009 02:38 PM
mysqli documentation phaesus MySQL & Databases 1 09-03-2008 12:15 PM
Exceptions and suppressing mysqli errors delayedinsanity Advanced PHP Programming 12 05-07-2008 07:27 PM
mysqli wGEric General 7 04-06-2008 06:00 PM
mysqli OOP interface introduction Matt83 General 4 12-22-2007 11:52 PM


All times are GMT. The time now is 05:46 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design