logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 04-10-2012, 09:31 PM   #1
tony09uk
 
Join Date: Oct 2010
Posts: 340
Default Call to undefined function query()

I am getting the following error message:

Call to undefined function query()

My code is this:

if(!isset($_GET['id'])){
header('Location: index.php');
exit();
} else {
$id = $_GET['id'];
}

$db = new mysqli('localhost', 'root', 'penbird098', 'blog') or die('error with connection');

if(!is_numeric($id)){
header('Location: blogIndex.php');
}

$sql = query("SELECT title, body FROM posts WHERE posts_id='$id'");
$query = $db->query($sql);
if($query !=1){
header('Location: index.php');
exit();
}

I know from the error message it is something to do with:
$query = $db->query($sql);
But I can't figure out what. I have done a few searches on google and not really found anything that is helpful to me. Can someone please provide me with a bit of guidance.

Many thanks

Tony
tony09uk is offline   Reply With Quote
Old 04-10-2012, 09:46 PM   #2
tony09uk
 
Join Date: Oct 2010
Posts: 340
Default

well, it seems I'd been staring at the problem so long I couldn't see the wood for the trees.

$sql = query("SELECT title, body FROM posts WHERE posts_id='$id'");

was wrong, I didnt need query()
tony09uk is offline   Reply With Quote
Reply


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:45 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com