Fatal Error w. php

Fatal Error w. php

Posted by: eileenfp
Posted on: 2006-05-15 14:12:00

When I try to view my registration file online, this is the message I get:

Fatal error: Call to undefined function: virtual() in /home/.handyman/aea/aeawebpage.org/registration.php on line 1

Does anyone have any idea what I did wrong?

The page is at www.aeawebpage.org/registration.php

I'm not a techie, so make it simple, please.

thanks,
Eileen

Re: Fatal Error w. php

Posted by: kngtaco
Posted on: 2006-05-15 14:14:00

hmm, try using include() instead of virtual()

Re: Fatal Error w. php

Posted by: forgotusername
Posted on: 2006-05-15 14:17:00

Firstly, is this an online registration you wrote yourself...or is a a script you downloaded?

you may want to post like the first 10 lines of code on that page.

does it start with

<?php



Re: Fatal Error w. php

Posted by: guice
Posted on: 2006-05-15 15:45:00

In reply to:

virtual() is an Apache-specific function


Will only work through mod_php. Since that option isn't available anymore, I'd recommend changing it to include().

Re: Fatal Error w. php

Posted by: eileenfp
Posted on: 2006-05-16 18:13:00

Here are the first 10 lines of code. It was created in Dreamweaver 8.0

<?php include('/Connections/conn_aea.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;

Now the bottom part of the page is loading, but the top banner is showing these messages:
Warning: main(/Connections/conn_aea.php): failed to open stream: No such file or directory in /home/.handyman/aea/aeawebpage.org/registration.php on line 1

Warning: main(/Connections/conn_aea.php): failed to open stream: No such file or directory in /home/.handyman/aea/aeawebpage.org/registration.php on line 1

Warning: main(): Failed opening '/Connections/conn_aea.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/.handyman/aea/aeawebpage.org/registration.php on line 1

Any ideas what the issue is now?


Re: Fatal Error w. php

Posted by: kngtaco
Posted on: 2006-05-17 00:54:00

it looks as if you're either missing a file, or it's in the wrong directory.

Re: Fatal Error w. php

Posted by: guice
Posted on: 2006-05-17 06:14:00

That's easy, the first include is incorrect: /Connections/conn_aea.php

That's looking for Connections directory in the ROOT directory of the server (note the / there). Fix the include to have the right path and you're set.

You can use $_SERVER['DOCUMENT_ROOT'] if all your files are in your web directory:
include ($_SERVER['DOCUMENT_ROOT'] . "/Connections/conn_aea.php");

Re: Fatal Error w. php

Posted by: forgotusername
Posted on: 2006-05-17 08:02:00

it may be that you just need to get rid of the first / in '/Connections/

to 'Connections/



Re: Fatal Error w. php

Posted by: guice
Posted on: 2006-05-17 17:42:00

I don't think that'll work. If the author of the script assumed / is root, then most likely there could very easily be other scripts in other directories using / as well.

A good method in solving this, and keeping the code clean:

define ('ROOT', $_SERVER['DOCUMENT_ROOT']);
include(ROOT.'/Connections....');

Change the _SERVER[] part to what ever directory this script resides in if it's not in your web root.

Re: Fatal Error w. php

Posted by: forgotusername
Posted on: 2006-05-18 08:50:00

Dreamweaver creates a folder called "Connections" which includes a file with the database connection information.

in the poster's case, the database connection information resides at /home/.handyman/aea/aeawebpage.org/Connections/conn_aea.php

In my scripts, I use <?php require_once('Connections/dbconn.php'); ?>

which works. If I add the / in front, I get the same error.

Warning: main(/Connections/dbconn.php): failed to open stream: No such file or directory in /home/.kalendar/mywebid/mysite.com/members.php on line 1

Fatal error: main(): Failed opening required '/Connections/memberlist.php' (include_path='.:/usr/local/lib/php') in /home/.kalendar/mywebid/mysite.com/members.php on line 1




Re: Fatal Error w. php

Posted by: eileenfp
Posted on: 2006-05-19 17:24:00

Thank you for the code. I copied it and pasted it as is. Was that right?

When I did that, the new errors were:
Warning: mysql_pconnect(): Access denied for user 'aea'@'kroner.dreamhost.com' (using password: NO) in /home/.handyman/aea/aeawebpage.org/Connections/conn_aea.php on line 9

Fatal error: Access denied for user 'aea'@'kroner.dreamhost.com' (using password: NO) in /home/.handyman/aea/aeawebpage.org/Connections/conn_aea.php on line 9


Lines 7-10 are
7 switch ($theType) {
8 case "text":
9 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
10 break;

Re: Fatal Error w. php

Posted by: norm1037
Posted on: 2006-05-20 02:24:00

Are you trying to connect to a MySQL database?
You are missing the password out if you are.

This is what I use to include in php scripts to connect to databases.

<?php

// connect to your database
function db_connect()
{
$result = @mysql_pconnect("hostname.example.com", "username", "password");
if (!$result)
return false;
if (!@mysql_select_db("database"))
return false;

return $result;
}
?>



--
Norm

Opinions are my own views and are not the views of DreamHost.
Any advice offered by me should be acted upon only at your own risk.

Re: Fatal Error w. php

Posted by: eileenfp
Posted on: 2006-06-02 15:14:00

Norm,

You're a genius! That worked perfectly.

Thanks a million,
Eileen

Tags: phpundefined functiontechieidealine 1fatal error