Undefined function!

software development

#1

This:

if ((!isset($_POST[‘login’]))OR(safe($_POST[‘login’],"",“20”)===""))

gets me THIS error:

Fatal error: Call to undefined function safe()

…and I can’t fix it. Can someone help me?


#2

Are you a programmer?

Did you copy and paste code from somewhere else?

Did you install a PHP application? If so, which one?

Inquiring minds want to know!

Because the error message is straight forward. PHP doesn’t come with a safe() function. So you need to get one or stop trying to use one. And if you had one beats me where it went. You could make one up, but would it really be “safe” ?

Apparently the intent of the function is to sanitize input data. One would have to know what the data is to be used for to determine how it should be sanitized. Are you going to use it for medical care or for food preparation?

:cool: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7


#3

The code was written for me. I’m a giant noob when it comes to all this, but I’m slowly learning. Heh.

As for what it’s doing, it’s part of a registration form.

[quote]if ((isset($_POST[‘check’]))AND($_POST[‘check’] == SID))
{

if ((!isset($_POST[‘login’]))OR(safe($_POST[‘login’],"",“20”)===""))
{
echo ‘No login value
’;
echo ’ Back </ >’;
exit () ;
}[/quote]

Is there anything else I should c/p here to make it clearer? Apologies in advance for my noobish ways. :stuck_out_tongue:


#4

If it was written for you, your best bet would be to ask that person where the safe() function is.

I’d guess that you’re either missing a file that needs to be included, or you’re missing the code that includes the file.


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#5

Is there anyway around this?


#6

Unless you know where to find the function in your files and how to include it (if it’s even there), you would need to know how to write a function that does whatever that one was supposed to do.

Personally, I’d probably suggest dumping whatever the script is, if it’s broken out of the box and the author can’t be reached to fix it.

Maybe look around sites like hotscripts.com and see if you can find one that does whatever you’re trying to do with this one.

The only other thing would be to post all of the code, including any files that are included, here and see if someone can help. If you want to do that, just make sure there isn’t any sensitive info in there that you shouldn’t make public (user names, passwords, etc…).

Otherwise, little snippets here and there probably won’t reveal much.


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#7

Okay thanks. I sent him an email and a message at the site I met him at. If he doesn’t reply ,I’ll post the whole thing here.


#8

:slight_smile: I emailed him and he told me it was in one of the other .php files delivered to me.

Now what? Heh

[quote]if ((isset($_POST[‘check’]))AND($_POST[‘check’] == SID)) ;
{

if ((!isset($_POST[‘login’]))OR(safe $string, $mode, $size)($_POST[‘login’],"",“20”)===""))
{
echo ‘No login value
’;
echo ’ Back </ >’;
exit () ;
}[/quote]

Should I put the entire piece into the area?


#9

If he gave you multiple files, then maybe they’re in the wrong places.

It would probably be best to ask him for step-by-step installation instructions, or at least where the files should be.

If you start moving code from file to file, you could break something else, depending on how he has it setup.


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#10

If that is the case, there must be at least one require() or include() function somewhere earlier in your document that points to the document where the safe() function has been defined, otherwise it will not work. Check to see if this is the case.

si-blog
Max discount on any plan with promocode SCJESSEYTOTAL


#11

Alright, woot. He fixed it for me. Now, I’ve got another problem. :stuck_out_tongue: It says this:

[quote]Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host ‘xx’ (1) in xx on line 32

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host ‘xx’ (1) in /xx on line 34
? ??? ??? ??? ukr!
Unknown MySQL server host ‘xx’ (1)[/quote]
I edited out the names and stuff, but I entered all the correct info. :\


#12

According to those error messages, you either did not enter “all the correct info”, or your MySQL server is unreachable :wink: .

Can you connect to it directly by browsing to it (http://your.hostname.tld)?

–rlparker


#13

edit: misread what you said. It’s 5 am, my apologizes. I’ll reply when I’m coherent in the afternoon.


#14

I did enter the correct info. I can access the db that they say is unknown on my browser. :\


#15

Hmmm… the only other thing I can think of is whether or not you are trying to access it from a script running on your own computer, or from a script running on Dreamhost?

–rlparker


#16

I’m trying to access it from Dreamhost. I was using the webFTP from my control panel. Hrmm…I’m thinking about making a new db and doing it over.


#17

You can’t access your database via webFTP, or any FTP program for that matter.

You said you could see it in a browser - and the only way you can do that is via the phpMyAdmin interface that is presented if you type the hostname into a browser (and answer the user/pass questions).

did you type in:

http://mysql.yourdomain.com/

…or whatever the hostname was you assigned the database to when you created it?

If so, and if you can get access to your database that way, then you have most likely something improperly set in your applications connection settings (variables) that is generating the error (somehow sees it differently than when you put in in a browser). I’m assuming that you are not putting any “http://” in front of the hostname in those setting, correct?

*I can’t tell what you are doing as you have obfuscated the error message and not provided the code section that has your settings, or the name of your host - I’m not nearly a good enough mind-reader to sort that out.

Without knowing the details of your database/host, or seeing how you have entered these settings in whatever part of whatever program you are running, I have no Idea how to help you further.

You might consider getting your friend who gave you whatever code this is to help you get it installed - we simply don’t know enough about what you are trying to run, of how the program is configured, to be able to “guess” what you may be doing wrong.

[color=#CC0000]Note:[/color] The current DH network/DNS problems may be part of the problem you are having. As I pointed out earlier, those error messages can mean your MySQL server is unreachable, even if your settings are all correct.

If you cannot connect to your database via a browser as described above, contact support; if you can, then you are either going to have to figure it out for yourself, or get help from someone you can trust to show the code/settings/configuration details to.

Unfortunately this type of back and forth discussion does not seem to be helping you. :frowning:

–rlparker


#18

Heh, I appreciate the help. Again, I didn’t clarify what I meant. I was accessing/editing the script from webftp.

[quote]
did you type in:

http://mysql.yourdomain.com/[/quote]

Yup and got into phpmyadmin where it says the db exists. I kept going back to my DH panel to see if I got the hostname correct and yeah, it is.

Also, sorry if I’m not providing enough information. I try to keep things limited as possible. I’m sure it’s a silly mistake anyhow. Such as a missing variable, as you said.


#19

Ok, good deal …that clears that all up. :wink:

Fair enough … why don’t you try this:

Copy/paste into a post the “section” of your program where the db settings are defined, including what you have in those locations except your username/password (the domain and hostname are not a significant risk) and let’s see if we can figure it out from there, ok?

One last thing - you should not be editing a script with webFTP - it does not handle *nix line endings properly and you could be introducing “very hard to track down bugs” by editing it that way. Use a text editor that handles *nix style line-ending properly, and edit on your computer then re-upload the edited files.

There are many such free editors available fro download; you didn’t say what OS you are using, so I don’;t know what to suggest. :wink:

–rlparker


#20

Alright, I’ll post my stuff in a bit.

Im on Windows XP, by the way. I was using Notepad to change stuff in the scripts and uploading it through FileZilla for a while but I kind of got Lazy