PHP - Images Dont Get Uploaded To Db At All
I have this script where it uploads the file name to a database plus a few more things.
Main Upload form. (img_add.php) <form enctype="multipart/form-data" action="img_add.php" method="POST"> Name: <input type="text" name="name"><br> E-mail: <input type="text" name = "email"><br> Phone: <input type="text" name = "phone"><br> Photo: <input type="file" name="photo"><br> <input type="submit" value="Add"> </form> Uploader. (img_add.php) <?php //This is the directory where images will be saved $target = "mainnewsimg/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("chat") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `images` VALUES ('$name', '$email', '$phone', '$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> And the one that views it. (img_view.php) It uses a get function so do it with img_view.php?img=2 <?php mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("chat") or die(mysql_error()) ; //Retrieves data from MySQL $newsid = $_GET['img']; $data = mysql_query("SELECT * FROM `images` WHERE id ='$newsid'") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=mainnewsimg/".$info['photo'] ."> <br>"; } ?> And my database sql. CREATE TABLE IF NOT EXISTS `images` ( `name` varchar(30) DEFAULT NULL, `email` varchar(30) DEFAULT NULL, `phone` varchar(30) DEFAULT NULL, `photo` varchar(30) DEFAULT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table `images` -- INSERT INTO `images` (`name`, `email`, `phone`, `photo`, `id`) VALUES ('sdf', 'sdfdsdsf', 'dsffsfsdf', 'arrow_forward_last.gif', 1), ('sadd', 'sadd', 'adsadasdad', 'artbottomshadr.png', 2); The values inside I had to put in manually to test if it worked for the img_view.php Anyways, It doesnt want to upload the images at all, even tho it says it did and gives the message The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory I would greatly appreciate some help, I also provided everything so you can try it on your own server too. Similar Tutorialshi everyone i am currently making my website with an uploadform. The upload function is working, but now i am trying to make the site remember the last 5 uploads. The filenames should appear in an array: $aotf[0] $aotf[1] $aotf[2] $aotf[3] $aotf[4] and since all files that can be/are uploaded are images, i want them to be drawed next to each other, each 128x128. THAT is working, but the fetch for images doesn't. When an image is uploaded, i execute this code: $readhandle=fopen("uploaddb.log","r"); $aotf=fread($handle,filesize("uploaddb.log")); fclose($readhandle); $writehandle=fopen("uploaddb.log","w"); fwrite($writehandle,"$aotf\r\n" . "uploadform/gebruikers/" . $naam); fclose($writehandle); then,there is some html code, and then there is this code: $aotf=explode("/n",$aotf); for($i = count($aotf) - 5; $i <= count($aotf); $i++) { echo ' <img src="'. $aotf[$i] . '" width="128" height="128"> '; } when i open the page, all img src's are empty. The writing works, and the folder of the image is 7777 chmod and the images draw on the screen, but not as the last uploaded. Does anyone know how to make this work? maybe even without a fwrite? Thank you, masterens EDIT: i cannot use mysql Hi Everyone, I've been studying the topics at this site and others on ways to count uploaded images; and what I've tried hasn't worked. I have seen this question posed and answered many times and most of the answers are something akin to this: Code: [Select] $count = count($_FILES['userfile'] ['name']); echo "the number of photos is ".$count; The explanation usually states that "count($_FILES['userfile'])" will simply count the number of elements in the array and return 5. But including ['name'] will return the number of files (images) uploaded. I will allow up to five photos to be uploaded (less is OK too) and want to count them in order to iterate through the proper number of loops to filter and process the photos. I've tested both of the above and get 5 (elements) when I count the ['userfile']; but get 0 (zero) when I test "['userfile'] ['name']". Here's the html code: Code: [Select] <!-- html here to input form data --> <label></label><input type="hidden" name="MAX_FILE_SIZE" value="500000000" /><br /> <label for="userfile">Upload photo 1</label> <input type="file" name="userfile1" id="userfile1" /><br /> <label for="userfile">Upload photo 2</label> <input type="file" name="userfile2" id="userfile2" /><br /> <label for="userfile">Upload photo 3</label> <input type="file" name="userfile3" id="userfile3" /><br /> <label for="userfile">Upload photo 4</label> <input type="file" name="userfile4" id="userfile4" /><br /> <label for="userfile">Upload photo 5</label> <input type="file" name="userfile5" id="userfile5" /><br /><br /> <label></label><input type="submit" name="userfile" value="Send Ad" /> </form> I've been testing the uploads with two files (jpg) and have tried to come up with an alternative that can iterate through the file arrays and determine how many photos I have. The code I've been testing is as follows: Code: [Select] $num = 1; $count = 0; while ($num <=5) { foreach ($_FILES['userfile'.$num] as $upload){ if ($upload ['error'] != 4){ } $count ++; } $num++; } echo "the number of photos is ".$count; I'm using "['error'] !=4" because some times people won't have 5 photos to upload. The result I get is 25 or 5 (files) x 5 (elements) for a total of 25. Does anyone know the proper way of doing this? Thanks for you input! Cheers, Rick Please, I need help with resizing uploaded images. Copied below is the code for image upload ( which I tagged "upload.php") Code: [Select] <?php // define a constant for the maximum upload size define ('MAX_FILE_SIZE', 51200); if (array_key_exists('upload', $_POST)) { // define constant for upload folder define('UPLOAD_DIR', 'C:/upload_test/'); // convert the maximum size to KB $max = number_format(MAX_FILE_SIZE/1024, 1).'KB'; // create an array of permitted MIME types $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'); foreach ($_FILES['image']['name'] as $number => $file) { // replace any spaces in the filename with underscores $file = str_replace(' ', '_', $file); // begin by assuming the file is unacceptable $sizeOK = false; $typeOK = false; // check that file is within the permitted size if ($_FILES['image']['size'][$number] > 0 || $_FILES['image']['size'][$number] <= MAX_FILE_SIZE) { $sizeOK = true; } // check that file is of an permitted MIME type foreach ($permitted as $type) { if ($type == $_FILES['image']['type'][$number]) { $typeOK = true; break; } } if ($sizeOK && $typeOK) { switch($_FILES['image']['error'][$number]) { case 0: // check if a file of the same name has been uploaded // if (!file_exists(UPLOAD_DIR.$file)) { // move the file to the upload folder and rename it $success = move_uploaded_file($_FILES['image']['tmp_name'][$number], UPLOAD_DIR.$file); // } /* else { // get the date and time ini_set('date.timezone', 'Europe/London'); $now = date('Y-m-d-His'); $success = move_uploaded_file($_FILES['image']['tmp_name'][$number], UPLOAD_DIR.$now.$file); }*/ if ($success) { $result[] = "$file uploaded successfully"; } else { $result[] = "Error uploading $file. Please try again."; } break; case 3: $result[] = "Error uploading $file. Please try again."; default: $result[] = "System error uploading $file. Contact webmaster."; } } elseif ($_FILES['image']['error'][$number] == 4) { $result[] = 'No file selected'; } else { $result[] = "$file cannot be uploaded. Maximum size: $max. Acceptable file types: gif, jpg, png."; } } } ?> <!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=iso-8859-1" /> <title>Multiple file upload</title> </head> <body> <?php // if the form has been submitted, display result if (isset($result)) { echo '<ol>'; foreach ($result as $item) { echo "<strong><li>$item</li></strong>"; } echo '</ol>'; } ?> <form action="" method="post" enctype="multipart/form-data" name="multiUpload" id="multiUpload"> <p> <label for="image1">File 1:</label> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MAX_FILE_SIZE; ?>" /> <input type="file" name="image[]" id="image1" /> </p> <p> <label for="image2">File 2:</label> <input type="file" name="image[]" id="image2" /> </p> <p> <input name="upload" type="submit" id="upload" value="Upload files" /> </p> </form> </body> </html> This works fine , except that it only uploads to C:/upload_test instead of the images folder (../img/) Can you please help with the codes for creating thumbnails while retaining the original upload. Thanks Hi everyone, I am after a scrpit/function that will get information of an uploaded image, resize it, then display the manipulated image. in my "upload" script, there will be a size limit and a file extension/type limit to: 600 x 200px / jpg, gif, jpeg... this is to keep the script i'm after more simple. As using vector images i'm told is such a complicated problem for me at this time. So... to get the size info/dimensions its like this: Code: [Select] <?php list($width, $height, $type, $attr) = getimagesize("image_name.jpg"); echo "Image width " .$width; echo "<BR>"; echo "Image height " .$height; echo "<BR>"; echo "Image type " .$type; echo "<BR>"; echo "Attribute " .$attr; ?> and..... resize something like this: Code: [Select] function get_image_sizes($sourceImageFilePath, $maxResizeWidth, $maxResizeHeight) { // Get width and height of original image $size = getimagesize($sourceImageFilePath); if($size === FALSE) return FALSE; // Error $origWidth = $size[0]; $origHeight = $size[1]; // Change dimensions to fit maximum width and height $resizedWidth = $origWidth; $resizedHeight = $origHeight; if($resizedWidth > $maxResizeWidth) { $aspectRatio = $maxResizeWidth / $resizedWidth; $resizedWidth = round($aspectRatio * $resizedWidth); $resizedHeight = round($aspectRatio * $resizedHeight); } if($resizedHeight > $maxResizeHeight) { $aspectRatio = $maxResizeHeight / $resizedHeight; $resizedWidth = round($aspectRatio * $resizedWidth); $resizedHeight = round($aspectRatio * $resizedHeight); } // Return an array with the original and resized dimensions return array($origWidth, $origHeight, $resizedWidth, $resizedHeight); } // Get dimensions $sizes = get_image_sizes($sourceImageFilePath, $maxResizeWidth, $maxResizeHeight); $origWidth = $sizes[0]; $origHeight = $sizes[1]; $resizedWidth = $sizes[2]; $resizedHeight = $sizes[3]; // Create the resized image $imageOutput = imagecreatetruecolor($resizedWidth, $resizedHeight); if($imageOutput === FALSE) return FALSE; // Error condition // Load the source image $imageSource = imagecreatefromjpeg($sourceImageFilePath); if($imageSource === FALSE) return FALSE; // Error condition $result = imagecopyresampled($imageOutput, $imageSource, 0, 0, 0, 0, $resizedWidth, $resizedHeight, $origWidth, $origHeight); if($result === FALSE) return false; // Error condition // Write out the JPEG file with the highest quality value $result = imagejpeg($imageOutput, $outputPath, 100); if($result === FALSE) return false; // Error condition And.... display is this: Code: [Select] <?php $database="***"; mysql_connect ("***", "***", "***"); @mysql_select_db($database) or die( "Unable to select database"); $result = mysql_query( "SELECT company_name, location, postcode, basicpackage_description, premiumuser_description, upload FROM Companies" ) or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); print "\n\n\nThere are $num_rows records.<P>"; echo "<table><tr><th>Comppany Name</th><th>Location</th><th>Postcode</th><th>Basic Members</th><th>Upgraded Users</th><th>Company Logo</th></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>";// store the records into $row array and loop through while ( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ) { // Print out the contents of the entry echo "<tr><td>{$row['company_name']}</td>"; echo "<td>{$row['location']}</td>"; echo "<td>{$row['postcode']}</td>"; echo "<td>{$row['basicpackage_description']}</td>"; echo "<td>{$row['premiumuser_description']}</td>"; echo "<td><img src=\"http://www.removalspace.com/images/COMPANIES{$row['upload']}\" alt=\"logo\" /></td></tr>";} echo "</table>"; ?> How will all these fit together in one script? any help i'd love it! many thanks in advance Hi everyone!! I have looked into how the upload script works and this is what i have: Code: [Select] <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> Which is un-tested at the moment, but let's just say for talking sake it worked 100% what elements of this script would i be looking at to display the files uploaded on to another page, in my case my homepage? ive found as to yet, that the uploads have to be stored on a file somewhere on my server, which i've set up. But i thought it would be just as easy to have a field in my table named upload and display it within the table next to the other results? instead i just get whatever the file name is named.jpg. Any help in looking towards the answer? many thanks in advance guys! Is it better to store uploaded images as 'content' in the database? (like he http://www.techsupportforum.com/forums/f49/tutorial-upload-files-to-database-176804.html).. Or just as a regular file which is referenced in the database..? Upload images - Thumbnail sizes? Hi all I haven't used php for a while now and I'm really stuck on some code I wrote and now I can't work how to change it. I have this function to upload images and create thumbnails. The thumbnails can be either landscape or portrait and I want them to have the same height. At the moment the portrait thumbnails height is equal to the landscape thumbnail width. The dimensions of the thumbnails are the same but the portrait images are portrait. How can I size the thumbnails so they all have the same height. Thanks in advance for any help or advice on this. Code: [Select] function upload_images(){ $photo_types = array('image/pjpeg'=>'.jpeg','image/jpeg'=>'.jpg','image/gif'=>'.gif','image/.bmp'=>'bmp','image/x-png'=>'.png'); //$number_of_uploads = 5; $image_Dir = "images_1/"; $image_thumb_Dir = $image_Dir . "thumbs/"; $photo_id_arr = array(); $photo_ext_arr = array(); $photo_id_ext_arr = array(); // if(isset($_FILES['images'])){ $image_uploaded = $_FILES['images']; for($i=0; $i<=count($_FILES['images']['name']);$i++){ if(!empty($image_uploaded['name'][$i])){ if(array_key_exists($image_uploaded['type'][$i], $photo_types)){ $file_temp = mysql_prep($image_uploaded['name'][$i]); // $query = "INSERT INTO photos (filename) VALUES ('{$file_temp}')"; $result = mysql_query($query); confirm_query($result); if($result){ $photo_id = mysql_insert_id(); array_push($photo_id_arr, $photo_id); } // $filetype = $image_uploaded['type'][$i]; $ext = $photo_types[$filetype]; array_push($photo_ext_arr, $ext); $dbfile_name = $photo_id . $ext; // $query = "UPDATE photos SET filename = '{$dbfile_name}' WHERE photo_id = '{$photo_id}'"; $result = mysql_query($query); confirm_query($result); // // $stored_image = $image_Dir . $dbfile_name; $stored_thumb = $image_thumb_Dir . $dbfile_name; move_uploaded_file($image_uploaded['tmp_name'][$i], $stored_image ); // $src_image = imagecreatefromjpeg($stored_image); // $src_width = imagesx($src_image); $src_height = imagesy($src_image); $new_width = 900; $new_height = 900; // if($src_width > $src_height){ $img_w = $new_width; $img_h = $src_height*($new_height/$src_width); } if($src_width < $src_height){ $img_w = $src_width*($new_width/$src_height); $img_h = $new_height; } if($src_width == $src_height){ $img_w = $new_width; $img_h = $new_height; } // $mainImg = imagecreatetruecolor($img_w, $img_h); imagecopyresampled($mainImg, $src_image,0,0,0,0,$img_w, $img_h, $src_width, $src_height); imagejpeg($mainImg, $stored_image, 100); imagedestroy($src_image); imagedestroy($mainImg); //*************************** // // // //*************************** $src_image = imagecreatefromjpeg($stored_image); // $src_width = imagesx($src_image); $src_height = imagesy($src_image); $new_width = 85; $new_height = 85; // if($src_width > $src_height){ $thumb_w = $new_width; $thumb_h = $src_height*($new_height/$src_width); } if($src_width < $src_height){ $thumb_w = $src_width*($new_width/$src_height); $thumb_h = $new_height; } if($src_width == $src_height){ $thumb_w = $new_width; $thumb_h = $new_height; } // $thumb = imagecreatetruecolor($thumb_w, $thumb_h); imagecopyresampled($thumb, $src_image,0,0,0,0,$thumb_w, $thumb_h, $src_width, $src_height); imagejpeg($thumb, $stored_thumb, 100); imagedestroy($src_image); imagedestroy($thumb); }else{ //echo "File format not supported."; } } } array_push($photo_id_ext_arr, $photo_id_arr); array_push($photo_id_ext_arr, $photo_ext_arr); return $photo_id_ext_arr; } } Right now users log in and upload an image to the website. I want every image that is uploaded to be watermarked with a particular logo. Is this possible? Any hints or tips will be appreciated. Thank you. Hi all, Could someone help me add a thumbnail script to the below that works on scaling it down to 200px x 133px. I guess it is not that hard. <?php $destination='aircraft/'.$reg."1.jpg"; $temp_file = $_FILES['image']['tmp_name']; move_uploaded_file($temp_file,$destination); ?> Thanks Hi, this is what I want to get working: each time I add an entry, it is displayed in a nice html table, and each entry listed in this html table has an UPDATE link that allows the user to update the Price and Description field of the corresponding table in my database. I have also included an upload element which whenever a user chooses an image, it will replace the default fileUploadIcon.jpg with this. Please see the index.php and bellUpdateForm.php below respectively Code: [Select] //index.php <table border="border"> <?php require 'bellConnect.inc.php'; $curImage; $imgIndx=-1;//iniitally $result=mysql_query("SELECT ID, Name, Manufacturer, Price, Description, SimSupport FROM bellProducts"); $indx=0;//***HOW DO I MAKE THIS SHARED SO THAT EACH ENTRY ADDED HAS AN INCREMENTED index appended to end of its name attribute //phpinfo(); //print "Val of \$counter so far: ".$counter; //NB: print table headings if(mysql_num_rows($result))//if there is at least one entry in bellProducts, make a table { //$counter+=1; print "<table border='border'>"; print "<tr> <th>ID</th> <th>Image</th> <th>Name</th> <th>Manufacturer</th> <th>Price</th> <th>Description</th> <th>SimSupport</th> <th colspan=2 align='center'>Modify</th> </tr>"; //NB: now output each row of records while($row=mysql_fetch_assoc($result)) { //extract($row); //if($indx<sizeof($bellProductsArray)) //{ "<tr align='center'> <td>$row[ID]</td> <td>"; if($_POST['upload']) print "<img src=".$_FILES['image']['name'].">"; else print "<img src='fileUploadIcon.jpg' name='image' /> </td> <td> $row[Name] </td> <td> $row[Manufacturer] </td> <td> $$row[Price]</td> <td align='left'>$row[Description]</td> <td>$row[SimSupport]</td> <td><a href='bellUpdateForm.php?ID=$row[ID]'>UPDATE</a></td> <td><a href='bellDeleteForm.php?ID=$row[ID]' name='delete'>DELETE</a></td> </tr>"; //}//END INNER IF $indx++; }//END WHILE }//END BIG IF ?> </table> </body> </html> Code: [Select] //bellUpdateForm.php <?php require 'bellConnect.inc.php'; if($_GET && !$_POST)//this is to make sure that the current entry is selected BUT the updated info NOT submitted yet { if(isset($_GET['ID'])) { $ID=$_GET['ID']; $result=mysql_query("SELECT * FROM bellProducts WHERE ID=$ID"); $row=mysql_fetch_assoc($result); //store the one entry that will be updated print "You are currently updating item: <strong>$row[Manufacturer] $row[Name] </strong> <br /><br />"; "<form action='bellUpdate.php' method='post'> <label> Price:<input type='text' value='$row[Price]' name='price' id='price'></input> </label> <label> Description: <textarea cols='60' rows='3' name='description' id='description'> $row[Description] </textarea> </label> <div> <input type='submit' value='Update entry' name='update' id='update' /> <input type='hidden' value=$row[ID] name='id' /> </div> <input type='reset' value='Reset entry' />"; print "</form>"; }//END INNER IF }//END BIG IF ?> <form method='post' action='index.php' enctype='multipart/form-data' name='uploadImage' id='uploadImage'> <p> <label>Upload image</label> <input type='file' name='image' id='image' /> </p> <p> <input type='submit' value='Upload this' name='upload' id='upload' /> </p> </form> <?php if(array_key_exists('upload', $_POST)) { // define constant for upload folder define('UPLOAD_DIR', 'C:\wamp\www'); // move the file to the upload folder and rename it move_uploaded_file($_FILES['image']['tmp_name'], ! UPLOAD_DIR.$_FILES['image']['name']); } ?> </body> </html> ok say I have a file that has something like 123456 abcde 654321 edcba in a file.. how would I go about having the script pull "123456" and make it a variable in the script.. and "abcde" a variable? and then "654321" a variable but is set in an array so that 123456 and 654321 are both the same variable but like $variable[0] and abcde and edcba would be $variable[1] what do I have to do? maybe some wiz kid out their can help me figure out whats going on here. What suppose to happen is a random site suppose to load into a iframe When the frameset code below is inside the <body> tags only the menubar shows up and not the iframe with a random site. Now when i take the code and put it oustide the <body> tag the menubar goes away and only the iframe with a random site is shown . The goal of course is to get the menubar to be visible and to have a iframe with a random site loaded into it. For some reason i can only get one of the two the happen. I do hope i explained this well enough Code: [Select] <frameset rows="80,*" BORDERCOLOR="#222222" BORDER="3"> <frame src="explore.php" name="surfbar" marginwidth="O" marginheight="0" NORESIZE SCROLLING="no" /> <frame src="<?php while ($row = mysql_fetch_array($result)){ print $row["url"];}?> " name="random" marginwidth="O" marginheight="0" noresize scrolling="auto" /> </frameset>-------------------------------------------------------------------------------------------------- Code: [Select] <?php /** * @author Brent Moeller * @copyright 2011 */ include ('functions.php'); db_connect(); $result = mysql_query("SELECT * FROM slinks where approval='1' ORDER BY RAND() LIMIT 1") or die(mysql_error()); ?> <html> <head> <title>DizzyUrl Discovery Engine</title> <link rel="stylesheet" type="text/css" href="mouseovertabs.css" /> <script src="mouseovertabs.js" type="text/javascript"> /*********************************************** * Mouseover Tabs Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more ***********************************************/ </script> </head> <body> <frameset rows="80,*" BORDERCOLOR="#222222" BORDER="3"> <frame src="explore.php" name="surfbar" marginwidth="O" marginheight="0" NORESIZE SCROLLING="no" /> <frame src="<?php while ($row = mysql_fetch_array($result)){ print $row["url"];}?> " name="random" marginwidth="O" marginheight="0" noresize scrolling="auto" /> </frameset> <div id="mytabsmenu" class="tabsmenuclass"> <ul> <li><a href="http://www.javascriptkit.com" rel="gotsubmenu[selected]">JavaScript Kit</a></li> <li><a href="http://www.cssdrive.com" rel="gotsubmenu">CSS Drive</a></li> <li><a href="http://www.codingforums.com">No Sub Menu</a></li> </ul> </div> <div id="mysubmenuarea" class="tabsmenucontentclass"> <!--1st link within submenu container should point to the external submenu contents file--> <a href="submenucontents.htm" style="visibility:hidden">Sub Menu contents</a> </div> <script type="text/javascript"> //mouseovertabsmenu.init("tabs_container_id", "submenu_container_id", "bool_hidecontentsmouseout") mouseovertabsmenu.init("mytabsmenu", "mysubmenuarea", true) </script> <noframes> <p>This Browser does not support Frames.</p> </noframes> </body> </html> hi, im getting the error Quote Fatal error: Call to undefined function notification() in C:\xampp\htdocs\xampp\index.php on line 21 after including the functions.php file i wrote. It does include it but the data isnt being recognised from it. If i copy/paste the notification() function into index.php it works. Can someone tell me why so i can fix it? i am a beginerr in php.. and here is my code..which shows error in the querry line.. erro goes like this Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\restafinal\process_edit_page.php on line 56 and code goes like this.. echo part works well...that query line is the error line..please tell me whats the problem... Code: [Select] <?php //$id=$_GET["id"]; $id= $_GET['id']; $menu_name= $_POST['menu_name']; $position= $_POST['position']; $visible= $_POST['visible']; $note= $_POST['note']; $content= $_POST['content']; //echo part works well.. echo "menu_name"; echo $menu_name; echo "<br/>"; echo "position"; echo $position; echo "<br/>"; echo "visible"; echo $visible; echo "<br/>"; echo "note"; echo $note; echo "<br/>"; echo "id"; echo $id; echo $content; [b]$result = mysql_query(UPDATE page SET note =$note, nevigation = $menu_name WHERE id = $id,$connection)[/b] // test to see if the update occurred if (mysql_affected_rows() == 1) { // Success! } else { $message = "The page could not be updated."; $message .= "<br />" . mysql_error(); } ?> Hi, im using colorbox(basically like lightbox) for some links on my site. When a user clicks the link it opens this lightbox. But if they type the link into the address bar manually it takes them to the actual page(which isnt formatted properly). Is there a way to open up the lightbox when they enter the address manually? or a work around? although im using nl2br, and \r\n in the code below, my results are still displaying; result1,result2,result2 opposed to result1 result2 result3 How can i change to this format? $code = $_GET['postcode']; $message = $_GET['message']; $shortcode = substr($code,0,2); $subject = "subject here"; $result = mysql_query("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3") or die(mysql_error()); echo "<h2>Business Names:</h2>"; $number_of_results = mysql_num_rows($result); $results_counter = 0; if ($number_of_results != 0) {while ($array = mysql_fetch_array($result)) {$email = $array['email']; $results_counter++; if ($results_counter >= $number_of_results) {$to .= $email;} else {$to .= $email . ',';}}} $headers = 'From: me@me.com' . "\r\n" . 'Reply-To: me@me.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $message .= "\r\n". $to ; echo nl2br ($message); mail( "$to", "$subject","$message", "$headers"); echo "<br>" . "Thank you for using our mail form."; ?></body></html> Hello! i am new to php. I need help to get all the displayed information in the mail, see below. I dont get the phone information. Thanks in adwansed <?php // anger en variabel som kan lagra de eventuella felaktigheterna $errors = array(); // kontrollera om ett Förnamn angivits if (!$_POST["namn"]) $errors[] = "- NAMN"; // kontrollera om ett TELEFONNUMMER angivits if (!$_POST["phone"]) $errors[] = "- TELEFONNUMMER"; // kontrollera om ett TELEFONNUMMER angivits $emailcheck = $_POST["email"]; if(!preg_match("/^[a-z0-9\å\ä\ö._-]+@[a-z0-9\å\ä\ö.-]+\.[a-z]{2,6}$/i", $emailcheck)) $errors[] = "- din E-POSTADRESS saknas eller är felaktig"; // kontrollera om ett Meddelande angivits if (!$_POST["message"]) $errors[] = "- inget MEDDELANDE har skrivits!"; if (count($errors)>0){ echo "<h1>Felmeddelande:</h1> <strong>Följande information måste anges innan du kan skicka formuläret:</strong><br /><br> "; foreach($errors as $fel) echo "$fel <br />"; echo "<br />Ange den information som saknas och skicka formuläret igen. Tack! <br />"; echo "<a href='javascript:history.go(-1)'>klicka här för att komma tillbaka till formuläret</a>"; } else { // formuläret är korrekt ifyllt och informationen bearbetas $to = "mailo@mail.com"; $from = $_POST["email"]; $subject = 'Kontakt från webbplatsen!'; $namn = $_POST["namn"]; $phone = $_POST["phone"]; $message = $_POST["message"]; ######################################################################## // HEADERS för innehållstyp och textkodning $headers = "Content-Type: text/plain; charset=utf-8 \r\n"; $headers .= "From:".$namn." <".$from.">"."\r\n"; $headers .= "MIME-Version: 1.0 \r\n"; ######################################################################## // Mailfunktionen som skickar bekräftelsen if (mail($to, $subject, $message, $headers)) echo nl2br("<h2>Tack $namn! Ditt meddelande har skickats!</h2> //###I WANT ALL THIS IN THE MAIL### <b>Mottaga </b> $to <b>Namn:</b> $namn <b>E-Mail:</b> $from <b>Telefonnummer:</b> $phone <b>meddelande:</b> <br/>$message "); else echo "Det gick inte att skicka ditt meddelande"; } ?>
keep gettin error msg Notice: Undefined index: id in C:\wamp\www\profile.php on line 42 dun everything to define the index cud it b the verion of wamp i am using Code: [Select] if ($_GET['id']) { $id = $_GET['id']; } else if (isset($_SESSION['id'])) { $id = $_SESSION['id']; } else { print "important data to render this page is missing"; //include_once "index.php"; //} } //exit(); [code] why this simple code only works on chrome??
function mostrarOcultar(obj) { document.getElementById('seguro').style.visibility = (obj.checked) ? 'hidden' : 'visible'; } |