FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » CLP - ON TOPIC! - Need PHP form email help, Please!
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173194 is a reply to message #173192] Sun, 27 March 2011 00:42 Go to previous messageGo to previous message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma:
Member
"Tim" wrote in message news:260320111732264412%batwzrd(at)hotmail(dot)com...

> $new_profile = $FTGfirstname"_"$FTGlastname".html";
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");

The first argument of fopen() must be a string.

Here is a portion of your code that I ran through an on-line PHP lint:
http://www.icosaedro.it/phplint/phplint-on-line.html

with some corrections and additions:

<?php
#defined dummy function to reduce errors
/*.string.*/ function DoStripSlashes($rawstr) {
return "str"; }

$FTGheadshot = $_FILES['headshot']['name'];
$FTGfirstname = DoStripSlashes( $_POST['firstname'] );
$FTGlastname = DoStripSlashes( $_POST['lastname'] );
$FTGaddress = DoStripSlashes( $_POST['address'] );
$FTGcity = DoStripSlashes( $_POST['city'] );
$FTGstate = DoStripSlashes( $_POST['state'] );
$FTGzip = DoStripSlashes( $_POST['zip'] );
$FTGhomenum = DoStripSlashes( $_POST['homenum'] );
$FTGmaincontact = DoStripSlashes( $_POST['maincontact'] );
$FTGcellnum = DoStripSlashes( $_POST['cellnum'] );
$FTGworknum = DoStripSlashes( $_POST['worknum'] );
$FTGfaxnum = DoStripSlashes( $_POST['faxnum'] );
$FTGemail = DoStripSlashes( $_POST['email'] );

# Save image to profiles directory
$path = "profiles/";
$path = $path . basename($FTGheadshot);
if(move_uploaded_file($_FILES['headshot']['tmp_name'], $path)) {
echo "The file ". basename( $_FILES['headshot']['name']).
" has been uploaded";//moves file and notifies if successful
} else{
echo "There was an error uploading the file, please try again!";//or not
}

# This was very wrong
# $new_profile = $FTGfirstname"_"$FTGlastname".html";

# I'm not sure if this works as desired, but it parses correctly
$new_profile = $FTGfirstname . $FTGlastname . ".html";

$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
?>

Error report:

$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
\_ HERE
==== 30: notice: unhandled error(s): E_WARNING

$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
\_ HERE
==== 30: ERROR: undeclared constant `profiles'

$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
\_ HERE
==== 30: ERROR: `... / EXPR': found string, expected a number.

$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
\_ HERE
==== 30: ERROR: `exit()' (aka `die()') isn't a function, it is a statement.
Trying to continue anyway, but probably the result of the expression will be
of the wrong type.

I'm not a PHP expert, but I caught the fopen error without using the lint
utility. And the lint utility gave some very good hints that I did not know,
such as how to declare a function return value as string.

Paul
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ip address of client
Next Topic: Islandnet.com dropping support for PHP4
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 21:19:34 GMT 2024

Total time taken to generate the page: 0.04328 seconds