Jump to content

returning a recordset through external functions file


otuatail

Recommended Posts

Hi

I am trying to get as much code out of my PHP pages mainly for security but also to make the website easier to manage. I have lots of functions in a functions page which is in a folder protected by htaccess. I am making calls to a database in the php pages for example

 

$sql = “SELECT DOB FROM Children WHERE Surname = ‘Robinson’”;

ConnectDB(5);

$query = mysql_query ($sql) or die ("E010A");

$rs = mysql_fetch_array($query) or die ("E110A");

$Surname = $rs[‘Surname’];

 

Admitedly this is not a good example for only retrieving one value but it is an example.

 

I could move all the code out and create a function in the functions.php file

 

$Surname = GetSurname(‘Robinson’);

 

Now I am keeping most of my database query and table names secret. My problem is I might want to return a recordset not just one value. If I wanted the surname of all the children in Class ‘B’ could I do the same like

 

$Class = GetChildrenInClass(‘B’);

This is returning a record set now. I want to get all this code out also in the case that I want to use a different database. If I wanted to to use database 4, I would have to go through tons of web pages changing ConnectDB(5).

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.