Fatal Error w. php

software development

#1

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


#2

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


#3

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

#4

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


yerba# rm -rf /etc
yerba#


#5

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?

#6

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


#7

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”);


yerba# rm -rf /etc
yerba#


#8

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

to 'Connections/


#9

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.


yerba# rm -rf /etc
yerba#


#10

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


#11

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

When I did that, the new errors were:
[b]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 [/b]

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


#12

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; } ?>


[color=#6600CC]Norm[/color]

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.


#13

Norm,

You’re a genius! That worked perfectly.

Thanks a million,
Eileen