Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-22-2011, 03:18 PM   PM User | #1
renseewmada
New to the CF scene

 
Join Date: Feb 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
renseewmada is an unknown quantity at this point
Question need help making functions call other functions

i have these several functions that i want to be able to call other functions like this.

Code:
	function confirm_query($result_set){
		if(!$result_set){
			die("Database query failed: ".mysql_error());
		}	
	}
	
	function bookmarksections(){
			$bookmarksections = mysql_query("SELECT * FROM bookmarksections");
			confirm_query($bookmarksections);
			return $bookmarksections;
	}
	
	function bookmarksection(){
		$bookmarksections = bookmarksections();
		$bookmarksection = mysql_fetch_array($bookmarksections);
		return $bookmarksection;
	}
	
	function bookmarks(){
		$bookmarksection = bookmarksection();
		$bookmarks = mysql_query("SELECT * FROM bookmarks WHERE SectionID = {$bookmarksection["ID"]}");
		confirm_query($bookmarks);
		return $bookmarks;
	}
but when i try to call the functions in my code it doesnt work.. plz help
-Adam
renseewmada is offline   Reply With Quote
Old 02-22-2011, 03:26 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Looks like it should work fine to me. Bookmarks will only return a resource though.
Are you calling the bookmarks function from somewhere? I assume your connection is open somewhere; mysql should be a global resource so it will find whatever open connection you have regardless of scope.
Can you be more specific by doesn't work?
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 +1. The time now is 05:16 PM.


Advertisement
Log in to turn off these ads.