Re: [PHP-DB] Image / file uploader
Try using the following: $_SERVER[PHP_SELF] Mainly, get rid of the quotes inside the brackets. Usually this error 'T_String' generally occurs when you have quotes ( or ') where they shouldn`t be. Give it a try if that thing still troubles you... Good luck Craig Hoffman wrote: Sorry to be a pest but I tried that. It giving me the same error. __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 29, 2004, at 7:10 PM, Daniel Clark wrote: Change to double quotes for the HTML portion. action=$_SERVER['PHP_SELF'] When I put single quotes in the PHP_SELF and I get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING and I can't use double quotes because its in an echo statement. What am I missing? echo (form method='post' action='$_SERVER['PHP_SELF']' encType='multipart/form-data' Any more thoughts? CH -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
I think you need the quotes: $_SERVER['PHP_SELF'] Try using the following: $_SERVER[PHP_SELF] Mainly, get rid of the quotes inside the brackets. Usually this error 'T_String' generally occurs when you have quotes ( or ') where they shouldn`t be. Give it a try if that thing still troubles you... Good luck -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Image / file uploader
On 30 April 2004 01:10, Craig Hoffman wrote: When I put single quotes in the PHP_SELF and I get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING and I can't use double quotes because its in an echo statement. What am I missing? Curly braces: echo (form method='post' action='{$_SERVER['PHP_SELF']}' encType='multipart/form-data' Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
This is really becoming an irritating small bug. I tried the curly brackets and the photo name still does not show up when I echo out the query. Everything else about the script works fine. Why does PHP choke on forms that submit files to themselves? I am slowly running out things to try... Suggestions? Thanks for everyone's help. CH __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 30, 2004, at 5:05 AM, Ford, Mike [LSS] wrote: On 30 April 2004 01:10, Craig Hoffman wrote: When I put single quotes in the PHP_SELF and I get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING and I can't use double quotes because its in an echo statement. What am I missing? Curly braces: echo (form method='post' action='{$_SERVER['PHP_SELF']}' encType='multipart/form-data' Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Craig Hoffman wrote: This is really becoming an irritating small bug. I tried the curly brackets and the photo name still does not show up when I echo out the query. Everything else about the script works fine. Why does PHP choke on forms that submit files to themselves? I am slowly running out things to try... Suggestions? Remove the action attribute of your form tag. Default is to post back to same page. echo (form method='post' action='{$_SERVER['PHP_SELF']}' encType='multipart/form-data' Also yuk! Have you considered at the very least separating your presentation layer out into separate files so that you don't echo() your HTML? This will make your life easier if ever you want some non-PHP person to help w/ layout. It'll also make your life easier if you want to redesign the form later w/o having to muck around in your processing logic or if you want to add caching to your site. It'll also make your life easier if you want to move templates out of the web root or want to change your app design to use an object-oriented application framework (like Mojavi, Binarycloud, etc.). etc., etc., etc. Hans -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Hans, Thanks Hans. I tried what your suggested and still no luck. __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 30, 2004, at 7:57 AM, Hans Lellelid wrote: Craig Hoffman wrote: This is really becoming an irritating small bug. I tried the curly brackets and the photo name still does not show up when I echo out the query. Everything else about the script works fine. Why does PHP choke on forms that submit files to themselves? I am slowly running out things to try... Suggestions? Remove the action attribute of your form tag. Default is to post back to same page. echo (form method='post' action='{$_SERVER['PHP_SELF']}' encType='multipart/form-data' Also yuk! Have you considered at the very least separating your presentation layer out into separate files so that you don't echo() your HTML? This will make your life easier if ever you want some non-PHP person to help w/ layout. It'll also make your life easier if you want to redesign the form later w/o having to muck around in your processing logic or if you want to add caching to your site. It'll also make your life easier if you want to move templates out of the web root or want to change your app design to use an object-oriented application framework (like Mojavi, Binarycloud, etc.). etc., etc., etc. Hans -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Thanks Hans. I tried what your suggested and still no luck. What does the actual HTML form look like? Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Here you go: I mostly echo out the HTML. I have included the entire form here. Thanks - CH echo (form method='post' action='{$_SERVER['PHP_SELF']}' encType='multipart/form-data'); echo (table border='0' cellpadding='5' width='500' cellspacing='0' id='result_table' tr bgcolor='#DBE6D1' td width='100'bName:b/td td$row[name]/td); echo (/tr); echo (tr); if ($row[photo_name] != '') { echo (tdimg src='images/clients/$row[photo_name]' width='50' align='right' id='photo_login' /td); } else { $photo_name = 'nbsp;'; } echo(tr bgcolor='#ECF8DF' tdbBio:/b/td td colspan='2'textarea rows='4'name='bio' cols='45'$row[bio]/textarea/td /tr tr bgcolor='#DBE6D1' tdbGoals:/b/td td colspan='2'textarea rows='4' name='goals' cols='45'$row[goals]/textarea/td /tr tr bgcolor='#ECF8DF' tdbFavorite Race:/b/td td colspan='2'textarea rows='4' name='fav_race' cols='45'$row[fav_race]/textarea/td /tr tr bgcolor='#DBE6D1' tdbFavorite Place to Train:/b/td td colspan='2'textarea rows='4' name='fav_train' cols='45'$row[fav_train]/textarea/td /tr tr bgcolor='#ECF8DF' td bUpload Photo:/b/td td colspan='2'input type='file' name='photo' /tr tr bgcolor='#DBE6D1' td colspan='3' INPUT type='hidden' name='MAX_FILE_SIZE' value='1000' input type='hidden' name='oldimage' value='.$row[photo_name].' input type='hidden' name='user_id' value='$row[0]' input type='hidden' name='postback_bio' value='true' input type='submit' value='Submit' id='submit_buttom'/td /tr /table /form); __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 30, 2004, at 8:47 AM, Chris Boget wrote: Thanks Hans. I tried what your suggested and still no luck. What does the actual HTML form look like? Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Here you go: I mostly echo out the HTML. I have included the entire form here. Thanks - CH echo (form method='post' action='{$_SERVER['PHP_SELF']}' encType='multipart/form-data'); echo (table border='0' cellpadding='5' width='500' ... If you could send the actual resulting HTML that is echoed by your script, that would be more helpful in diagnosing why your browser isn't posting back to the right page. HL -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
No problem - Here you go. Thanks - CH !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head titleeClimb Media and RaceLogix Traininglog/title meta name=generator content=BBEdit 7.1.3 / meta name=author content=eClimb Media - www.eclimbmedia.com / meta name=copyright content=eClimb Media - www.eclimbmedia.com / meta name=description content=online personal traininglog brought to you by eClimb Media and RaceLogix / meta name=keywords content=personal training, marathon training program, racelogix, eclimb media, running, traininglog, training / /head link rel=stylesheet rev=stylesheet href=css/standard.css media=all / body table width=700 border=0 cellspacing=0 cellpadding=0 align=center id=main_content_table tr td colspan=4 id=content_headerh2Welcome to Training log/h2/td /tr tr valign=top td width=100 id=content_table_navtable id=left_nav_table cellpadding=0 cellspacing=0 tr td width=100 height=22 id=homea href=index.phpHome/a/td /tr /table br / table id=left_nav_tablecellpadding=0 cellspacing=0 tr td width=100 height=22 id=coachinga href=login.phpLogin/a/td /tr tr td width=100 height=22 id=mailinga href=mailinglist.phpMailing List/a/td /tr tr td width=100 height=22 id=contacta href=contact.phpContact/a/td /tr /table br / table id=left_nav_table cellpadding=0 cellspacing=0 tr td width=125 height=22 id=coachinga href=coaching.phpCoaching/a/td /tr tr td width=125 height=22 id=Group Runa href=grouprun.phpGroup Runs/a/td /tr tr td width=125 height=22 id=Group Runa href=featuredathlete.phpFeatured Athlete/a/td /tr /table br / table id=left_nav_tablecellpadding=0 cellspacing=0 tr td width=100 height=22 id=utilitiesa href=util.phpUtilities/a/td /tr tr td width=100 height=22 id=logouta href=logout.phpLogout/a/td /tr /table/td td id=content_cell width=500h4Edit Your Bio/h4 h2Tell us a little about yourself./h2 p id='message'No new image supplied./p UPDATE users SET bio = 'Hello World - Bio', goals = 'Hello World - Goal', fav_race = 'Hello World - Race', fav_train = 'Hello World - Trainingf', photo_name = '' WHERE user_id = '12' form method='post' action='/~choffman/www/mtrain/client_profile.php' encType='multipart/form-data'table border='0' cellpadding='5' width='500' cellspacing='0' id='result_table' tr bgcolor='#DBE6D1' td width='100'bName:b/td tdCraig Hoffman/td/trtrtr bgcolor='#ECF8DF' tdbBio:/b/td td colspan='2'textarea rows='4'name='bio' cols='45'Hello World - Bioing/textarea/td /tr tr bgcolor='#DBE6D1' tdbGoals:/b/td td colspan='2'textarea rows='4' name='goals' cols='45'Hello World - Goaling/textarea/td /tr tr bgcolor='#ECF8DF' tdbFavorite Race:/b/td td colspan='2'textarea rows='4' name='fav_race' cols='45'Hello World - Raceing/textarea/td /tr tr bgcolor='#DBE6D1' tdbFavorite Place to Train:/b/td td colspan='2'textarea rows='4' name='fav_train' cols='45'Hello World - Trainingfsdf/textarea/td /tr tr bgcolor='#ECF8DF' td bUpload Photo:/b/td td colspan='2'input type='file' name='photo' /tr tr bgcolor='#DBE6D1' td colspan='3' INPUT type='hidden' name='MAX_FILE_SIZE' value='1000' input type='hidden' name='oldimage' value='' input type='hidden' name='user_id' value='12' input type='hidden' name='postback_bio' value='true' input type='submit' value='Submit' id='submit_buttom'/td /tr /table /form /td /tr /table /body /html __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 30, 2004, at 8:56 AM, Hans Lellelid wrote: Here you go: I mostly echo out the HTML. I have included the entire form here. Thanks - CH echo (form method='post' action='{$_SERVER['PHP_SELF']}' encType='multipart/form-data'); echo (table border='0' cellpadding='5' width='500' ... If you could send the actual resulting HTML that is echoed by your script, that would be more helpful in diagnosing why your browser isn't posting back to the right page. HL -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Image / file uploader
Craig, Where is the code that actually handles the image upload? Is it in /~choffman/www/mtrain/client_profile.php? If so, can you post that too? Rich -Original Message- From: Craig Hoffman [mailto:[EMAIL PROTECTED] Sent: Friday, April 30, 2004 10:08 AM To: Hans Lellelid Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Image / file uploader No problem - Here you go. Thanks - CH !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head titleeClimb Media and RaceLogix Traininglog/title meta name=generator content=BBEdit 7.1.3 / meta name=author content=eClimb Media - www.eclimbmedia.com / meta name=copyright content=eClimb Media - www.eclimbmedia.com / meta name=description content=online personal traininglog brought to you by eClimb Media and RaceLogix / meta name=keywords content=personal training, marathon training program, racelogix, eclimb media, running, traininglog, training / /head link rel=stylesheet rev=stylesheet href=css/standard.css media=all / body table width=700 border=0 cellspacing=0 cellpadding=0 align=center id=main_content_table tr td colspan=4 id=content_headerh2Welcome to Training log/h2/td /tr tr valign=top td width=100 id=content_table_navtable id=left_nav_table cellpadding=0 cellspacing=0 tr td width=100 height=22 id=homea href=index.phpHome/a/td /tr /table br / table id=left_nav_tablecellpadding=0 cellspacing=0 tr td width=100 height=22 id=coachinga href=login.phpLogin/a/td /tr tr td width=100 height=22 id=mailinga href=mailinglist.phpMailing List/a/td /tr tr td width=100 height=22 id=contacta href=contact.phpContact/a/td /tr /table br / table id=left_nav_table cellpadding=0 cellspacing=0 tr td width=125 height=22 id=coachinga href=coaching.phpCoaching/a/td /tr tr td width=125 height=22 id=Group Runa href=grouprun.phpGroup Runs/a/td /tr tr td width=125 height=22 id=Group Runa href=featuredathlete.phpFeatured Athlete/a/td /tr /table br / table id=left_nav_tablecellpadding=0 cellspacing=0 tr td width=100 height=22 id=utilitiesa href=util.phpUtilities/a/td /tr tr td width=100 height=22 id=logouta href=logout.phpLogout/a/td /tr /table/td td id=content_cell width=500h4Edit Your Bio/h4 h2Tell us a little about yourself./h2 p id='message'No new image supplied./p UPDATE users SET bio = 'Hello World - Bio', goals = 'Hello World - Goal', fav_race = 'Hello World - Race', fav_train = 'Hello World - Trainingf', photo_name = '' WHERE user_id = '12' form method='post' action='/~choffman/www/mtrain/client_profile.php' encType='multipart/form-data'table border='0' cellpadding='5' width='500' cellspacing='0' id='result_table' tr bgcolor='#DBE6D1' td width='100'bName:b/td tdCraig Hoffman/td/trtrtr bgcolor='#ECF8DF' tdbBio:/b/td td colspan='2'textarea rows='4'name='bio' cols='45'Hello World - Bioing/textarea/td /tr tr bgcolor='#DBE6D1' tdbGoals:/b/td td colspan='2'textarea rows='4' name='goals' cols='45'Hello World - Goaling/textarea/td /tr tr bgcolor='#ECF8DF' tdbFavorite Race:/b/td td colspan='2'textarea rows='4' name='fav_race' cols='45'Hello World - Raceing/textarea/td /tr tr bgcolor='#DBE6D1' tdbFavorite Place to Train:/b/td
Re: [PHP-DB] Image / file uploader
Sure - I never thought i would have some many issues with a simple postback. ;) Here 's the code: ? function display_edit_bio($user_id) { if($_POST['postback_bio']) { include include/dbadmin.php; //image uploader $uploadpath = 'images/clients/'; $source = $HTTP_POST_FILES['photo']['tmp_name']; $photo_name = $HTTP_POST_FILES['photo']['name']; $dest = ''; if (($source != '') ($source != '')) { $dest = $uploadpath.$photo_name; if ($dest != '') { if (move_uploaded_file($source, $dest)) { echo (p id='message'Image and Bio has been successfully stored./p ); } else { echo (p id='message'Image could not be stored./p); } } } else { echo (p id='message'No new image supplied./p); $photo_name = $oldimage; } //declare varibles $user_id = $_POST[user_id]; $name = $_POST[name]; $bio = $_POST[bio]; $goals = $_POST[goals]; $fav_race = $_POST[fav_race]; $fav_train = $_POST[fav_train]; $photo = $_POST[photo_name]; $query = UPDATE users SET bio = '$bio', goals = '$goals', fav_race = '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name' WHERE user_id = '$user_id'; echo $query; $msg = span style='color:red' id='message'Could not update record/span; $result = mysql_query($query, $db) or ($msg); } ? __ Craig Hoffman iChat: m0untaind0g __ On Apr 30, 2004, at 9:17 AM, Hutchins, Richard wrote: Craig, Where is the code that actually handles the image upload? Is it in /~choffman/www/mtrain/client_profile.php? If so, can you post that too? Rich -Original Message- From: Craig Hoffman [mailto:[EMAIL PROTECTED] Sent: Friday, April 30, 2004 10:08 AM To: Hans Lellelid Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Image / file uploader No problem - Here you go. Thanks - CH !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head titleeClimb Media and RaceLogix Traininglog/title meta name=generator content=BBEdit 7.1.3 / meta name=author content=eClimb Media - www.eclimbmedia.com / meta name=copyright content=eClimb Media - www.eclimbmedia.com / meta name=description content=online personal traininglog brought to you by eClimb Media and RaceLogix / meta name=keywords content=personal training, marathon training program, racelogix, eclimb media, running, traininglog, training / /head link rel=stylesheet rev=stylesheet href=css/standard.css media=all / body table width=700 border=0 cellspacing=0 cellpadding=0 align=center id=main_content_table tr td colspan=4 id=content_headerh2Welcome to Training log/h2/td /tr tr valign=top td width=100 id=content_table_navtable id=left_nav_table cellpadding=0 cellspacing=0 tr td width=100 height=22 id=homea href=index.phpHome/a/td /tr /table br / table id=left_nav_tablecellpadding=0 cellspacing=0 tr td width=100 height=22 id=coachinga href=login.phpLogin/a/td /tr tr td width=100 height=22 id=mailinga href=mailinglist.phpMailing List/a/td /tr tr td width=100 height=22 id=contacta href=contact.phpContact/a/td /tr /table br / table id=left_nav_table cellpadding=0 cellspacing=0 tr td width=125 height=22 id=coachinga href=coaching.phpCoaching/a/td /tr tr td width=125 height=22 id=Group Runa href=grouprun.phpGroup Runs/a/td /tr tr td width=125 height=22 id=Group Runa href=featuredathlete.phpFeatured Athlete/a/td /tr /table br / table id=left_nav_tablecellpadding=0 cellspacing=0 tr td width=100 height=22 id=utilitiesa href=util.phpUtilities/a/td /tr tr td width=100 height=22 id=logouta href=logout.phpLogout/a/td /tr /table/td td id=content_cell width=500h4Edit Your Bio/h4 h2Tell us a little about yourself./h2 p id='message'No new image supplied./p UPDATE users SET bio = 'Hello World - Bio', goals = 'Hello World - Goal', fav_race = 'Hello World - Race', fav_train = 'Hello World - Trainingf', photo_name = '' WHERE user_id = '12' form method='post' action='/~choffman/www/mtrain/client_profile.php' encType='multipart/form-data'table border='0' cellpadding='5' width='500' cellspacing='0' id='result_table' tr bgcolor='#DBE6D1' td width='100'bName:b/td tdCraig Hoffman/td/trtrtr bgcolor='#ECF8DF
Re: [PHP-DB] Image / file uploader
That worked! Han's and everyone else thank you very much. I owe everyone who helped out a beer. ;) Thanks CH __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 30, 2004, at 9:22 AM, Hans Lellelid wrote: Errr $HTTP_POST_FILES is not superglobal (am I wrong?) $_FILES or specify global $HTTP_POST_FILES Hans Craig Hoffman wrote: ? function display_edit_bio($user_id) { if($_POST['postback_bio']) { include include/dbadmin.php; //image uploader $uploadpath = 'images/clients/'; $source = $HTTP_POST_FILES['photo']['tmp_name']; $photo_name = $HTTP_POST_FILES['photo']['name']; $dest = ''; if (($source != '') ($source != '')) { $dest = $uploadpath.$photo_name; if ($dest != '') { if (move_uploaded_file($source, $dest)) { echo (p id='message'Image and Bio has been successfully stored./p ); } else { echo (p id='message'Image could not be stored./p); } } } else { echo (p id='message'No new image supplied./p); $photo_name = $oldimage; } //declare varibles $user_id = $_POST[user_id]; $name = $_POST[name]; $bio = $_POST[bio]; $goals = $_POST[goals]; $fav_race = $_POST[fav_race]; $fav_train = $_POST[fav_train]; $photo = $_POST[photo_name]; $query = UPDATE users SET bio = '$bio', goals = '$goals', fav_race = '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name' WHERE user_id = '$user_id'; echo $query; $msg = span style='color:red' id='message'Could not update record/span; $result = mysql_query($query, $db) or ($msg); } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Image / file uploader
Jinkeys! I had a hunch the problem was with that upload script. Nice catch, Hans! Rich -Original Message- From: Craig Hoffman [mailto:[EMAIL PROTECTED] Sent: Friday, April 30, 2004 10:41 AM To: Hans Lellelid Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Image / file uploader That worked! Han's and everyone else thank you very much. I owe everyone who helped out a beer. ;) Thanks CH __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 30, 2004, at 9:22 AM, Hans Lellelid wrote: Errr $HTTP_POST_FILES is not superglobal (am I wrong?) $_FILES or specify global $HTTP_POST_FILES Hans Craig Hoffman wrote: ? function display_edit_bio($user_id) { if($_POST['postback_bio']) { include include/dbadmin.php; //image uploader $uploadpath = 'images/clients/'; $source = $HTTP_POST_FILES['photo']['tmp_name']; $photo_name = $HTTP_POST_FILES['photo']['name']; $dest = ''; if (($source != '') ($source != '')) { $dest = $uploadpath.$photo_name; if ($dest != '') { if (move_uploaded_file($source, $dest)) { echo (p id='message'Image and Bio has been successfully stored./p ); } else { echo (p id='message'Image could not be stored./p); } } } else { echo (p id='message'No new image supplied./p); $photo_name = $oldimage; } //declare varibles $user_id = $_POST[user_id]; $name = $_POST[name]; $bio = $_POST[bio]; $goals = $_POST[goals]; $fav_race = $_POST[fav_race]; $fav_train = $_POST[fav_train]; $photo = $_POST[photo_name]; $query = UPDATE users SET bio = '$bio', goals = '$goals', fav_race = '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name' WHERE user_id = '$user_id'; echo $query; $msg = span style='color:red' id='message'Could not update record/span; $result = mysql_query($query, $db) or ($msg); } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
does it puke when its not using _self? Craig Hoffman wrote: This is really becoming an irritating small bug. I tried the curly brackets and the photo name still does not show up when I echo out the query. Everything else about the script works fine. Why does PHP choke on forms that submit files to themselves? I am slowly running out things to try... Suggestions? Thanks for everyone's help. CH __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 30, 2004, at 5:05 AM, Ford, Mike [LSS] wrote: On 30 April 2004 01:10, Craig Hoffman wrote: When I put single quotes in the PHP_SELF and I get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING and I can't use double quotes because its in an echo statement. What am I missing? Curly braces: echo (form method='post' action='{$_SERVER['PHP_SELF']}' encType='multipart/form-data' Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
I think you want single quotes around PHP_SELF. $_SERVER['PHP_SELF'] I have a script where it uploads a image to directory. I have used the script several times and it works when I send the form to another page. The problem is I have changed the form to submit to itself and I can't seem to get it to work. echo ( form method='post' action='$_SERVER[PHP_SELF]' encType='multipart/form-data'); The thing is all my other fields update except for the image. Further, the image does not even show up if I echo the query out. UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test', fav_race = 'Fav Races - test', fav_train = 'Traing -test', photo_name = '' WHERE user_id = '1' Here is the code of the image uploader and my query, perhaps someone could take a look let me know what I'm missing. Thanks - CH input type='file' name='photo' if($_POST[postback_bio]) { include include/dbadmin.php; //image uploader $uploadpath = '/images/clients/'; $source = $HTTP_POST_FILES['photo']['tmp_name']; $photo_name = $HTTP_POST_FILES['photo']['name']; $dest = ''; if (($source != '') ($source != '')) { $dest = $uploadpath.$photo_name; if ($dest = '') { if (move_uploaded_file($source, $dest)) { echo (p id='message'Image and Bio has been successfully stored./p ); } else { echo (p id='message'Image could not be stored./p); } } } else { echo (p id='message'No new image supplied./p); $photo_name = $oldimage; } //declare varibles $user_id = $_POST[user_id]; $name = $_POST[name]; $bio = $_POST[bio]; $goals = $_POST[goals]; $fav_race = $_POST[fav_race]; $fav_train = $_POST[fav_train]; $photo = $_POST[photo_name]; $query = UPDATE users SET bio = '$bio', goals = '$goals', fav_race = '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name' WHERE user_id = '$user_id'; echo $query; $msg = span style='color:red' id='message'Could not update record/span; $result = mysql_query($query, $db); } __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
When I put single quotes in the PHP_SELF and I get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING and I can't use double quotes because its in an echo statement. What am I missing? echo (form method='post' action='$_SERVER['PHP_SELF']' encType='multipart/form-data' Any more thoughts? CH __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 29, 2004, at 6:49 PM, Daniel Clark wrote: I think you want single quotes around PHP_SELF. $_SERVER['PHP_SELF'] I have a script where it uploads a image to directory. I have used the script several times and it works when I send the form to another page. The problem is I have changed the form to submit to itself and I can't seem to get it to work. echo ( form method='post' action='$_SERVER[PHP_SELF]' encType='multipart/form-data'); The thing is all my other fields update except for the image. Further, the image does not even show up if I echo the query out. UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test', fav_race = 'Fav Races - test', fav_train = 'Traing -test', photo_name = '' WHERE user_id = '1' Here is the code of the image uploader and my query, perhaps someone could take a look let me know what I'm missing. Thanks - CH input type='file' name='photo' if($_POST[postback_bio]) { include include/dbadmin.php; //image uploader $uploadpath = '/images/clients/'; $source = $HTTP_POST_FILES['photo']['tmp_name']; $photo_name = $HTTP_POST_FILES['photo']['name']; $dest = ''; if (($source != '') ($source != '')) { $dest = $uploadpath.$photo_name; if ($dest = '') { if (move_uploaded_file($source, $dest)) { echo (p id='message'Image and Bio has been successfully stored./p ); } else { echo (p id='message'Image could not be stored./p); } } } else { echo (p id='message'No new image supplied./p); $photo_name = $oldimage; } //declare varibles $user_id = $_POST[user_id]; $name = $_POST[name]; $bio = $_POST[bio]; $goals = $_POST[goals]; $fav_race = $_POST[fav_race]; $fav_train = $_POST[fav_train]; $photo = $_POST[photo_name]; $query = UPDATE users SET bio = '$bio', goals = '$goals', fav_race = '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name' WHERE user_id = '$user_id'; echo $query; $msg = span style='color:red' id='message'Could not update record/span; $result = mysql_query($query, $db); } __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Change to double quotes for the HTML portion. action=\$_SERVER['PHP_SELF']\ When I put single quotes in the PHP_SELF and I get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING and I can't use double quotes because its in an echo statement. What am I missing? echo (form method='post' action='$_SERVER['PHP_SELF']' encType='multipart/form-data' Any more thoughts? CH __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 29, 2004, at 6:49 PM, Daniel Clark wrote: I think you want single quotes around PHP_SELF. $_SERVER['PHP_SELF'] I have a script where it uploads a image to directory. I have used the script several times and it works when I send the form to another page. The problem is I have changed the form to submit to itself and I can't seem to get it to work. echo ( form method='post' action='$_SERVER[PHP_SELF]' encType='multipart/form-data'); The thing is all my other fields update except for the image. Further, the image does not even show up if I echo the query out. UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test', fav_race = 'Fav Races - test', fav_train = 'Traing -test', photo_name = '' WHERE user_id = '1' Here is the code of the image uploader and my query, perhaps someone could take a look let me know what I'm missing. Thanks - CH input type='file' name='photo' if($_POST[postback_bio]) { include include/dbadmin.php; //image uploader $uploadpath = '/images/clients/'; $source = $HTTP_POST_FILES['photo']['tmp_name']; $photo_name = $HTTP_POST_FILES['photo']['name']; $dest = ''; if (($source != '') ($source != '')) { $dest = $uploadpath.$photo_name; if ($dest = '') { if (move_uploaded_file($source, $dest)) { echo (p id='message'Image and Bio has been successfully stored./p ); } else { echo (p id='message'Image could not be stored./p); } } } else { echo (p id='message'No new image supplied./p); $photo_name = $oldimage; } //declare varibles $user_id = $_POST[user_id]; $name = $_POST[name]; $bio = $_POST[bio]; $goals = $_POST[goals]; $fav_race = $_POST[fav_race]; $fav_train = $_POST[fav_train]; $photo = $_POST[photo_name]; $query = UPDATE users SET bio = '$bio', goals = '$goals', fav_race = '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name' WHERE user_id = '$user_id'; echo $query; $msg = span style='color:red' id='message'Could not update record/span; $result = mysql_query($query, $db); } __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Do this: echo ( form method='post' action='.$_SERVER[PHP_SELF].' encType='multipart/form-data'); PHP doesn't handle array's well in echo statements, so you have to stop the echo, concat the array, and then continue the echo. -Micah On Thursday 29 April 2004 04:46 pm, Craig Hoffman wrote: I have a script where it uploads a image to directory. I have used the script several times and it works when I send the form to another page. The problem is I have changed the form to submit to itself and I can't seem to get it to work. echo ( form method='post' action='$_SERVER[PHP_SELF]' encType='multipart/form-data'); The thing is all my other fields update except for the image. Further, the image does not even show up if I echo the query out. UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test', fav_race = 'Fav Races - test', fav_train = 'Traing -test', photo_name = '' WHERE user_id = '1' Here is the code of the image uploader and my query, perhaps someone could take a look let me know what I'm missing. Thanks - CH input type='file' name='photo' if($_POST[postback_bio]) { include include/dbadmin.php; //image uploader $uploadpath = '/images/clients/'; $source = $HTTP_POST_FILES['photo']['tmp_name']; $photo_name = $HTTP_POST_FILES['photo']['name']; $dest = ''; if (($source != '') ($source != '')) { $dest = $uploadpath.$photo_name; if ($dest = '') { if (move_uploaded_file($source, $dest)) { echo (p id='message'Image and Bio has been successfully stored./p ); } else { echo (p id='message'Image could not be stored./p); } } } else { echo (p id='message'No new image supplied./p); $photo_name = $oldimage; } //declare varibles $user_id = $_POST[user_id]; $name = $_POST[name]; $bio = $_POST[bio]; $goals = $_POST[goals]; $fav_race = $_POST[fav_race]; $fav_train = $_POST[fav_train]; $photo = $_POST[photo_name]; $query = UPDATE users SET bio = '$bio', goals = '$goals', fav_race = '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name' WHERE user_id = '$user_id'; echo $query; $msg = span style='color:red' id='message'Could not update record/span; $result = mysql_query($query, $db); } __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Sorry to be a pest but I tried that. It giving me the same error. __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 29, 2004, at 7:10 PM, Daniel Clark wrote: Change to double quotes for the HTML portion. action=\$_SERVER['PHP_SELF']\ When I put single quotes in the PHP_SELF and I get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING and I can't use double quotes because its in an echo statement. What am I missing? echo (form method='post' action='$_SERVER['PHP_SELF']' encType='multipart/form-data' Any more thoughts? CH __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 29, 2004, at 6:49 PM, Daniel Clark wrote: I think you want single quotes around PHP_SELF. $_SERVER['PHP_SELF'] I have a script where it uploads a image to directory. I have used the script several times and it works when I send the form to another page. The problem is I have changed the form to submit to itself and I can't seem to get it to work. echo ( form method='post' action='$_SERVER[PHP_SELF]' encType='multipart/form-data'); The thing is all my other fields update except for the image. Further, the image does not even show up if I echo the query out. UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test', fav_race = 'Fav Races - test', fav_train = 'Traing -test', photo_name = '' WHERE user_id = '1' Here is the code of the image uploader and my query, perhaps someone could take a look let me know what I'm missing. Thanks - CH input type='file' name='photo' if($_POST[postback_bio]) { include include/dbadmin.php; //image uploader $uploadpath = '/images/clients/'; $source = $HTTP_POST_FILES['photo']['tmp_name']; $photo_name = $HTTP_POST_FILES['photo']['name']; $dest = ''; if (($source != '') ($source != '')) { $dest = $uploadpath.$photo_name; if ($dest = '') { if (move_uploaded_file($source, $dest)) { echo (p id='message'Image and Bio has been successfully stored./p ); } else { echo (p id='message'Image could not be stored./p); } } } else { echo (p id='message'No new image supplied./p); $photo_name = $oldimage; } //declare varibles $user_id = $_POST[user_id]; $name = $_POST[name]; $bio = $_POST[bio]; $goals = $_POST[goals]; $fav_race = $_POST[fav_race]; $fav_train = $_POST[fav_train]; $photo = $_POST[photo_name]; $query = UPDATE users SET bio = '$bio', goals = '$goals', fav_race = '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name' WHERE user_id = '$user_id'; echo $query; $msg = span style='color:red' id='message'Could not update record/span; $result = mysql_query($query, $db); } __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Craig Hoffman wrote: Sorry to be a pest but I tried that. It giving me the same error. __ Change to double quotes for the HTML portion. action=\$_SERVER['PHP_SELF']\ You'll find that the ultimate correct form is echo etcetc action=\$_SERVER[PHP_SELF]\ etcetc; When you're using an associative array inside a string, you don't need to put quotes refer to its textual index. Bruno Ferreira --- [This E-mail scanned for viruses by Declude Virus] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Fellows, thanks for helping. But still no luck. The error is gone, but the image / file is still not showing up in the query. What else I can provide to help trouble shoot this? echo (form method='post' action='.$_SERVER[PHP_SELF].' encType='multipart/form-data'); __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Apr 29, 2004, at 7:32 PM, Micah Stevens wrote: Do this: echo ( form method='post' action='.$_SERVER[PHP_SELF].' encType='multipart/form-data'); PHP doesn't handle array's well in echo statements, so you have to stop the echo, concat the array, and then continue the echo. -Micah On Thursday 29 April 2004 04:46 pm, Craig Hoffman wrote: I have a script where it uploads a image to directory. I have used the script several times and it works when I send the form to another page. The problem is I have changed the form to submit to itself and I can't seem to get it to work. echo ( form method='post' action='$_SERVER[PHP_SELF]' encType='multipart/form-data'); The thing is all my other fields update except for the image. Further, the image does not even show up if I echo the query out. UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test', fav_race = 'Fav Races - test', fav_train = 'Traing -test', photo_name = '' WHERE user_id = '1' Here is the code of the image uploader and my query, perhaps someone could take a look let me know what I'm missing. Thanks - CH input type='file' name='photo' if($_POST[postback_bio]) { include include/dbadmin.php; //image uploader $uploadpath = '/images/clients/'; $source = $HTTP_POST_FILES['photo']['tmp_name']; $photo_name = $HTTP_POST_FILES['photo']['name']; $dest = ''; if (($source != '') ($source != '')) { $dest = $uploadpath.$photo_name; if ($dest = '') { if (move_uploaded_file($source, $dest)) { echo (p id='message'Image and Bio has been successfully stored./p ); } else { echo (p id='message'Image could not be stored./p); } } } else { echo (p id='message'No new image supplied./p); $photo_name = $oldimage; } //declare varibles $user_id = $_POST[user_id]; $name = $_POST[name]; $bio = $_POST[bio]; $goals = $_POST[goals]; $fav_race = $_POST[fav_race]; $fav_train = $_POST[fav_train]; $photo = $_POST[photo_name]; $query = UPDATE users SET bio = '$bio', goals = '$goals', fav_race = '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name' WHERE user_id = '$user_id'; echo $query; $msg = span style='color:red' id='message'Could not update record/span; $result = mysql_query($query, $db); } __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php