hi all
i am building a small private school management program and i use alot of the same loops, update statements, and whatnot and i would like to put them all into one php file divided into their own functions. i was just wondering if it is possible to call an individual function on a remote php page.
thanks
eric
10 1815
Of course you can,
Create all of the functions on a separate page ie function.php
then of course you list your functions on that page -
function dbconnect()
-
{
-
global $db, $t_global;
-
$db_con = @MYSQL_CONNECT($db['server'],$db['user'],$db['passwortd]) or die ($t_global['query_false']);
-
$db_check = @MYSQL_SELECT_DB($db['name']);
-
}
-
-
blah, blah, blah
-
-
The in the actual php page that you are using you will need to include the function page -
<?
-
include "function.php";
-
?>
-
And to call the function in your php page you will need to do like the following
Hope the above helps and Good Luck!
Small correction: in order to use this command[php]$connect = dbconnect();[/php] the dbconnect function must return a value, otherwise you cannot assign it to the $connect variable.
Ronald :cool:
Small correction: in order to use this command[php]$connect = dbconnect();[/php] the dbconnect function must return a value, otherwise you cannot assign it to the $connect variable.
Ronald :cool:
Hi Ronald,
I don't quite understand what you mean when you say a variable. Now I know enough to not know -- LOL
What type of variable has to be assigned?
When you assign like
you actually assign the result of the function dbconnect() to the variable $connect.
Since the function dbconnect() does not return anything, no data or boolean, the assignment has no meaning. You cannot properly use variable $connect. Maybe you don't want to, but then the assignment is useless.
Ronald :cool:
OK, I see what you are saying.
The way I have used it has been many times as a straight function call
but I have also used it as in the previous example with other functions.
thanks again.
I still have a lot to learn and just don't quite completely understand the manuals and tutorials.
Yes, a straight function call is fine. But, in this case, I would have passed on a false if an error had occurred during the connect or db select, and a true when no error had occurred.
So the statement then could be [php]if (!dbconnect())
die ("Some error at connect");
else
// continue processing[/php]
Ronald :cool:
kewlness!
Thanks for that snippet, I will integrate it into my own scripts.
maybe not the best place to put this post but...
I love this site. thescripts is the reason i have a job. i was hired to build php scripts with mysql database communication three months ago and i knew html and had heard of php but had never seen the code. now thanks to ron and other members I am building database driven sites without you guys and your detailed descriptions and fast replys to questions i probably wouldn't have a job
thanks
eric
That is the best compliment you could give the team. Thanks.
Ronald :cool:
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Praveen Srinivasan |
last post by:
Hi all,
Are there any important issues that one should be aware of when calling C++
functions from C? In particular, I'm passing a function pointer to a C
routine in a library, and in that...
|
by: reynoldscraigr |
last post by:
Hi All,
I am trying to call 2 functions from the 1 onMouseOver event on an
anchor tag, but I can't seem to get it to work. the following should
demonstrate
<a...
|
by: Ross A. Finlayson |
last post by:
Hi,
I hope you can help me understand the varargs facility.
Say I am programming in ISO C including stdarg.h and I declare a
function as so:
void log_printf(const char* logfilename, const...
|
by: Rob |
last post by:
Hi Gang:
I have a page that loads a remote page into an IFRAME.
I don't have any control over this remote page though the page is owned by
the same company I work for.
The problem is that all...
|
by: William Hudson |
last post by:
I want to be able to ask users for a URL, open that page, change some of the
contents and then display that page as if they had typed the URL into a
browser. I have toyed with some of the php...
|
by: Usenet User |
last post by:
I need to be able to call the same API function from VB, which will
reside in different DLLs. While all of the functions have the same
signature and name, DLL file names are not known at compile...
|
by: Meya-awe |
last post by:
Hi,
What does C# has to offer for calling system functions from within the
VS .NET C# project? I want to kickoff a script or a batch file from my
code.
thanks,
BRAMOIN
*** Sent via...
|
by: Fernando Rodríguez |
last post by:
Hi,
How can I retrieve the "description" meta tag of a remote page?
Thanks!
Fernando
|
by: teju |
last post by:
hi,
i am trying 2 merge 2 projects into one project.One project is using c
language and the other one is using c++ code.
both are working very fine independently.But now i need to merge both...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |