newbie2php Posted September 23, 2008 Share Posted September 23, 2008 I want to print my error messages to a certain part of my page and created a div tag called upload here is a piece of my code for an example if (move_uploaded_file ($_FILES['thefile']['tmp_name'], "../uploads/{$_FILES['thefile']['name']}")) { print '<div id="upload"><p>Your file has been uploaded.</p>'; ?> <img src="../uploads/<?=$_FILES['thefile']['name']?>" /> Anyway when the page is loded everything looks great when I upload my img file it messes up the look of the page and goes to the top of the page. You can see here what i mean. http://www.sngportfolio.com/EducationalBooks/sell.php (Please know this site is for learning purposes only) Anyway my question is am I wrong in my thinking do I print to the div by print<div id="upload"? Why is it not printing there? Thank you in advance Link to comment https://forums.phpfreaks.com/topic/125511-solved-print-to-div/ Share on other sites More sharing options...
aebstract Posted September 23, 2008 Share Posted September 23, 2008 To wrap code tags, use [ ] instead of < >. I got a 404 error for that link. Link to comment https://forums.phpfreaks.com/topic/125511-solved-print-to-div/#findComment-648914 Share on other sites More sharing options...
newbie2php Posted September 23, 2008 Author Share Posted September 23, 2008 Oh sorry you might have to go here login http://www.sngportfolio.com/EducationalBooks user name test password test Link to comment https://forums.phpfreaks.com/topic/125511-solved-print-to-div/#findComment-648919 Share on other sites More sharing options...
DarkWater Posted September 23, 2008 Share Posted September 23, 2008 You forgot to close the DIV. Link to comment https://forums.phpfreaks.com/topic/125511-solved-print-to-div/#findComment-648942 Share on other sites More sharing options...
newbie2php Posted September 23, 2008 Author Share Posted September 23, 2008 do you mean change my code to print '<div id="upload"><p>Your file has been uploaded.</p></div>'; I tried that it didn't work Link to comment https://forums.phpfreaks.com/topic/125511-solved-print-to-div/#findComment-649002 Share on other sites More sharing options...
kenrbnsn Posted September 23, 2008 Share Posted September 23, 2008 What else do you send to the screen in this chunk of code? Look at the generated source to see where the code is occurring. Ken Link to comment https://forums.phpfreaks.com/topic/125511-solved-print-to-div/#findComment-649010 Share on other sites More sharing options...
newbie2php Posted September 23, 2008 Author Share Posted September 23, 2008 Here is all my code. Sorry I have not learned how to indent the code better for you to view. <?php //Begin Session session_start(); define ('TITLE', 'Sell your old books '); // Address error handling. ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); if (isset($_POST['submit'])) { //Handle form. //Try to moce the uploaded file. if (move_uploaded_file ($_FILES['thefile']['tmp_name'], "../uploads/{$_FILES['thefile']['name']}")) { print '<div id="upload"><p>Your file has been uploaded.</p></div>'; ?> <img src="../uploads/<?=$_FILES['thefile']['name']?>" /> <?php $_SESSION[filename]="../uploads/".$_FILES['thefile']['name']; } else {//Problem print '<div id="upload"><p>Your file could not be uploaded because<b></div>'; //Print a message based upon the ettor. switch($_FILES['thefile']['error']) { case 1: print '<div id="upload">The file exceeds the upload_max_filesize setting in php.ini</div>'; break; case 2: print '<div id="upload">The file exceeds the MAX_FILE_SIZE setting in the HTML form</div>'; break; case 3: print '<div id="upload">The file was only partially uploaded</div>'; break; case 4: print '<div id="upload">No file was uploaded</div>'; break; } print '</b>.</p>'; } } //End of the SUBMIT IF. Leace php and display form ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="stylesheet.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style9 {color: #616161; font-weight: bold; } .style13 {color: #616161; font-weight: bold; font-size: 12px; } .style14 { font-size: 14px; font-weight: bold; } .style16 { font-size: 13px } --> </style> <!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable --> </head> <body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0"> <table width="776" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td rowspan="6" background="images/linebgleft.jpg"><img src="images/linebgleft.jpg" width="28" height="27" /></td> <td><table width="776" border="0" cellspacing="0" cellpadding="0"> <tr> <td><?php require ('header.php'); //header file inputs here ?></td> </tr> </table></td> <td width="27" rowspan="6" background="images/linebgright.jpg"><img src="images/linebgright.jpg" width="27" height="24" /></td> </tr> <tr> <td><table width="776" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="776" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" background="images/leftmenu.gif" bgcolor="#F1F1F3"><?php require ('menu.html'); //header file inputs here ?> </td> </tr> </table></td> </tr> </table> </td> </tr> <tr> <td><table width="776" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#004A67"><img src="images/leftbbar.gif" width="614" height="27" alt="" /></td> <td width="161" bgcolor="#004A67"><img src="images/rightbbar.gif" width="161" height="27" alt="" /></td> </tr> </table></td> </tr> <tr> <td><table width="776" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td width="11" valign="top"><p> </p></td> <td width="515" valign="top"><?php //Script 8.14 -welcome.php ?> <p><br /> <?php //Print a greeting print '<div id="greeting"><h3>Upload the image of the book you would like to sell, ' . ucfirst($_SESSION['username']) . '!</h3>'; ?></p> <div id="upload"></div> <h1 class="text"> </h1> <form action ="sell.php" enctype="multipart/form-data" method="post"> <p><br /> <input type ="hidden" name="MAX_FILE_SIZE" value="30000" /> <input type = "file" name="thefile" /><br /><br /> <input type="submit" name ="submit" value ="Upload This File" /> </form> <p> </p></td> <td width="15" valign="top"> </td> <td width="235" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table cellspacing="0" cellpadding="0"> <tr> <td><table cellspacing="0" cellpadding="0" width="94%" border="0"> <tbody> <tr> <td><p><br /><div class="roundedcornr_box_373935"> <div class="roundedcornr_top_373935"><div></div></div> <div class="roundedcornr_content_373935"> <p class="style13"> </p> <p class="style13"><span class="heading"></p> <p class="style13"> </p> </div> <div class="roundedcornr_bottom_373935"><div></div></div> </div></p> </td> </tr> <tr> <td><div class="roundedcornr_box_373935"> <div class="roundedcornr_top_373935"> <div></div> </div> <div class="roundedcornr_content_373935"> <p class="style13"><strong>Educational Books By Garrett</strong></p> <p class="style13">Phone 1800-222-2222 <br /> Fax 1-800-222-2223<br /> <br /> info@booksbygarrett</p> </div> <div class="roundedcornr_bottom_373935"> <div></div> </div> </div></td> </tr> </tbody> </table> <p> </p></td> </tr> </table> </td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td><table width="776" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="401"><a href="#"><img src="images/featured.jpg" width="401" height="87" border="0" alt="" /></a></td> <td><img src="images/index_48.gif" width="3" height="88" alt="" /></td> <td><a href="#"><img src="images/Arthistory.jpg" width="370" height="87" border="0" alt="" /></a></td> </tr> </table></td> </tr> <tr> <td><?php require ('footer.html'); //header file inputs here ?></td> </tr> </table> </body> </html> Thank you for any help you can offer Link to comment https://forums.phpfreaks.com/topic/125511-solved-print-to-div/#findComment-649013 Share on other sites More sharing options...
newbie2php Posted September 23, 2008 Author Share Posted September 23, 2008 I figured out my problem thank you for all who helped Link to comment https://forums.phpfreaks.com/topic/125511-solved-print-to-div/#findComment-649097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.