Error when calling global function
Posted by: thudson (---.dynamic.dsl.as9105.com)
Date: October 25, 2011 08:38PM

Hi

I have just recently installed WAMP server on my laptop, after successfully running Apache, PHP and MySQL on my desktop. These I installed separately as I did not know about WAMP then.

I get an error on the WAMP installation [Call to undefined function doDB() in.......].

Here is the fuction in my store_connect.php script:

<?
//set up a couple of functions for use by eStore

function doDB() {
global $mysqli;

//connect to server and select database; you may need it
$mysqli = mysqli_connect("localhost", "root", "xxxxxx", "store"winking smiley;

//if connection fails, stop script execution
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
}
?>

This script is called from several scripts with the following lines:

include("store_connect.php"winking smiley;
doDB();

Rocky48

Options: ReplyQuote
Re: Error when calling global function
Posted by: stevenmartin99 (---.b-ras1.srl.dublin.eircom.net)
Date: October 25, 2011 08:49PM

its not an error. its bad coding.


Define your var being using it.

Read the warning - Undefined

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Error when calling global function
Posted by: thudson (---.dynamic.dsl.as9105.com)
Date: October 26, 2011 02:04PM

Hi Steven

I don't understand?

Exactly the same coding works on my desktop computer??

I am relatively new to PHP and can't see what is wrong!

Rocky48

Options: ReplyQuote
Re: Error when calling global function
Posted by: stevenmartin99 (---.251.255.15.threembb.ie)
Date: October 26, 2011 02:52PM

Define the variable - give it a value

Before you say it's global - it must exist or at least give it a value while setting it


Global $var = null;
Global $var = 0;
Global $var = false;

It's a warning to tell you that the var is useless as its not set at that point - so why would you write it there ....

Some servers have warning disabled - a development server like wamp has warning on.

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Error when calling global function
Posted by: thudson (---.dynamic.dsl.as9105.com)
Date: October 26, 2011 04:09PM

Hi Steve

I still can't get it to work!

Put the var before the function call:

Global $var = false;
function doDB() {
global $mysqli;

Also just before global $mysqli

function doDB() {
Global $var = false;
global $mysqli;

Or does it go in every script that calls this function? I did not think this was likely.

Have any other sugestions?

Rocky48

Options: ReplyQuote
Re: Error when calling global function
Posted by: thudson (---.dynamic.dsl.as9105.com)
Date: January 05, 2012 07:18PM

Can anyone out there help?
This still does not work.

I have tried all of the above.

As stated before it DOES work on another computer, but this was installed by installing the components separately.

My thoughts are that it must be a setting in the ini files, but which one?

Rocky48

Options: ReplyQuote
Re: Error when calling global function
Posted by: stevenmartin99 (---.b-ras1.srl.dublin.eircom.net)
Date: January 05, 2012 08:11PM

can i take a look using teamviewer?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Error when calling global function
Posted by: thudson (---.dynamic.dsl.as9105.com)
Date: January 05, 2012 08:53PM

Hi Steve

Want is Teamviewer?

Is it like Windows Remote Assistance?

I will have to boot up my laptop, as I am on desktop at the moment.

Rocky48

Options: ReplyQuote
Re: Error when calling global function
Posted by: stevenmartin99 (---.b-ras1.srl.dublin.eircom.net)
Date: January 05, 2012 11:25PM

yes its likek that but a bit better

if u want, get it and email me the id and pass to the gmail address below

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote


Sorry, only registered users may post in this forum.