PHP - Storing An Image Path And Tags Problem
So, I am your typical newbie to php. I am usually doing more design stuff, but now I am diving into PHP. The script in question is made for a user to upload an image to a respective directory. Also the path, category, and 2 tags representing the image will be uploaded to a mySQL database.
My problem is that I have pieced together some freeware scripts that I have found in order to accomplish my ultimate goal. I need the form to be processed on the same page, because I don't want to redirect users. I also need to upload the respective information to the database. Right now, when you upload an image it only seems to be processing a part of the form, and does not upload any of the information at all. Can someone spot the many things that I am doing wrong and provide me with some direction? I have two files in question image_upload.php (Sorry about all of the code) <?php require_once 'upload_config.php'; function VerifyForm(&$values, &$errors) { // Do all necessary form verification if($clear_folder_before_upload){ $mydirectory = myUploadDir(); EmptyDir($mydirectory); } $uploaded_file_counter=0; $UploadLimit = $_POST['counter']; for($i=0;$i<=$UploadLimit;$i++){ $file_tag='filename'.$i; $filename=$_FILES[$file_tag]['name']; if($filename!=null) { $rand=time(); $str="$rand$filename"; // set folder name in here. $filedir= myUploadDir(); //change the string format. $string= $filedir.$str; $patterns[0] = "/ /"; $patterns[1] = "/ /"; $patterns[1] = "/ /"; $replacements[1] = "_"; $dirname=strtolower(preg_replace($patterns, $replacements, $string)); //end of changing string format //checking the permitted file types if($check_file_extentions) { $allowedExtensions = allowedfiles(); foreach ($_FILES as $file) { if ($file['tmp_name'] > '') { if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) { $fileUploadPermission=0; } else { $fileUploadPermission=1; } } } } else{ $fileUploadPermission=1; } //end of checking the permitted file types if($fileUploadPermission){ if(move_uploaded_file($_FILES[$file_tag]['tmp_name'],$dirname)) { echo "<img src='$dirname'>"; $uploaded_file_counter+=1; } } } } if($uploaded_file_counter==0){ echo "<br /> <b style='font-weight:bold;color:red'>Oops! Please select an image file</b>"; }else{ echo "<br /> <b>You requested ".$i." image files to upload and ".$uploaded_file_counter." files uploaded sucessfully</b>"; echo $filename0; $contentdiv = 'Upload succesful! Upload Again'; } } function DisplayForm($values, $errors) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JayGilford.com :: Name form example</title> <script type="text/javascript" src="js/jquery-1.4.2.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.custom.min.js"></script> <style type="text/css"> div#upload_box_wrapper{width:350px;text-align:center; float: left;font-family: verdana; font-size: 12px;padding: 5px 5px 5px 5px; color: black;} div#upload_box_wrapper #upload_title_text{text-align:left;width: 100%;display: block;border: 0px solid green; margin-bottom: 5px;} div#upload_box_wrapper #FileUploadDiv{display: block;width: 98%;border: 0px solid green; text-align: left;padding: 0px 0px 0px 0px;} div#upload_box_wrapper p.add-new-upload-box{float: left;width: 100%;text-align: left;} div#upload_box_wrapper a.add-new-upload-link{font-weight: bold;font-size: 13px;padding-right: 3px;text-decoration: none; color: black;} div#upload_box_wrapper .upload-button{border: 0px solid lightgreen;height:30px; width:120px;cursor: pointer;background:url(./images/upload_button.png) no-repeat center left; color: white;} </style> </head> <body> <form method='post' action='' enctype='multipart/form-data'> <div id="upload_box_wrapper"> <div id="upload_title_text">Image Upload:</div> <div id="FileUploadDiv" DivValue="0"> <input name='filename0' type='file' id='filename'> <select name="img_category"> <option value="Vacation">Vacation</option> <option value="Holiday">Holiday</option> </select> <input name="tag1" type="text" id="tag1"> <input name="tag2" type="text" id="tag2"> </div> <input type="hidden" value="0" id="counter" name="counter"> <div align='left'> <input type='submit' name='submit' value='Upload Now!' class="upload-button"> </div> </div> </form> </body> </html> <?php } function ProcessForm($values) { $filename0 = $_POST['filename']; $filetype = $_POST['']; $img_category = $_POST['img_category']; $tag1 = $_POST['tag1']; $tag2 = $_POST['tag2']; //////// //figure out the image?? ///// session_start(); $img = $_POST[ 'imglink' ]; $filetypes = array( 'gif','jpg','jpeg','png' ); ++$filetypes; $filetype = strstr( $img, '.' ); if( $filetype != $filetypes ) { echo 'not supported'; } session_register( 'Image' ); $Img = $_SESSION[ 'Image' ]; mysql_query( "INSERT into `images` ( `image_id`, `filename`, `filetype`, `url`, `img_category`, `tag1`, `tag2` ) VALUES ( '', '$filename0', '$filetype', '$Img', '$img_category', '$tag1', '$tag2' )" ); session_destroy(); mysql_close( $DB ); // Replace with actual page or redirect :P } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $formValues = $_POST; $formErrors = array(); if (!VerifyForm($formValues, $formErrors)) DisplayForm($formValues, $formErrors); else ProcessForm($formValues); } else DisplayForm(null, null); ?> and the upload_config.php file <?php /////////////////////////////////////////////////////////////////////////// //establish mysql connection (I have this set correctly on the original file) /////////////////////////////////////////////////////////////////////////// $db = mysql_connect('RESPECTIVE', 'MYSQL', IDANDPW'); if (!$db) { echo "Unable to establish connection to database server"; exit; } if (!mysql_select_db('chad_images', $db)) { echo "Unable to connect to database"; exit; } /////////////////////////////////////////////////////////////////////////// // set your upload directory name in here. /////////////////////////////////////////////////////////////////////////// function myUploadDir(){ $myUploadDir = "./upload/"; return $myUploadDir; } /////////////////////////////////////////////////////////////////////////// // if you want to imposs file type rescriction then // $check_file_extentions=1 or if you want to off this option then // $check_file_extentions=0 /////////////////////////////////////////////////////////////////////////// $check_file_extentions = 1; //////////////////////////////////////////////////////////////////////////// // set your allowed type in the array. // examples: zip, pdf, psd and many more. // //////////////////////////////////////////////////////////////////////////// function allowedfiles() { $allowed_file_extensions=array("png","jpg","gif","bmp"); return $allowed_file_extensions; } /////////////////////////////////////////////////////////////////////////// // if you want to delete all the files in uploaded directory // $clear_folder_before_upload = 1 or if you want to off this option then // $clear_folder_before_upload = 0 /////////////////////////////////////////////////////////////////////////// $clear_folder_before_upload = 1; function EmptyDir($dir) { $handle=opendir($dir); while (($file = readdir($handle))!==false) { @unlink($dir.'/'.$file); } closedir($handle); } ?> Any help would be greatly appreciated! Similar TutorialsHi! So I'm working for someone, and they want me to fix this error in a PHP file.. Here is the code: <?php include_once('config.php'); $online = mysql_query("SELECT * FROM bots WHERE status LIKE 'Online'"); $offline = mysql_query("SELECT * FROM bots WHERE status LIKE 'Offline'"); $dead = mysql_query("SELECT * FROM bots WHERE status LIKE 'Dead'"); $admintrue = mysql_query("SELECT * FROM bots WHERE admin LIKE 'True'"); $adminfalse = mysql_query("SELECT * FROM bots WHERE admin LIKE 'False'"); $windows8 = mysql_query("SELECT * FROM bots WHERE so LIKE '%8%'"); $windows7 = mysql_query("SELECT * FROM bots WHERE so LIKE '%7%'"); $windowsvista = mysql_query("SELECT * FROM bots WHERE so LIKE '%vista%'"); $windowsxp = mysql_query("SELECT * FROM bots WHERE so LIKE '%xp%'"); $unknown = mysql_query("SELECT * FROM bots WHERE so LIKE 'Unknown'"); $totalbots = mysql_num_rows(mysql_query("SELECT * FROM bots")); $onlinecount = 0; $offlinecount = 0; $deadcount = 0; $admintruecount = 0; $adminfalsecount = 0; $windows8count = 0; $windows7count = 0; $windowsvistacount = 0; $windowsxpcount = 0; $unknowncount = 0; while($row = mysql_fetch_array($online)){ $onlinecount++; } while($row = mysql_fetch_array($offline)){ $offlinecount++; } while($row = mysql_fetch_array($dead)){ $deadcount++; } while($row = mysql_fetch_array($admintrue)){ $admintruecount++; } while($row = mysql_fetch_array($adminfalse)){ $adminfalsecount++; } while($row = mysql_fetch_array($windows8)){ $windows8count++; } while($row = mysql_fetch_array($windows7)){ $windows7count++; } while($row = mysql_fetch_array($windowsvista)){ $windowsvistacount++; } while($row = mysql_fetch_array($windowsxp)){ $windowsxpcount++; } while($row = mysql_fetch_array($unknown)){ $unknowncount++; } $statustotal = $onlinecount + $offlinecount + $deadcount; $admintotal = $admintruecount + $adminfalsecount; $sototal = $windows7count + $windowsvistacount + $windowsxpcount + $unknowncount; ?> Can anyone tell me the error here, can how to fix it? Hi, I've read a lot of places that it's not recommended to store binary files in my db. So instead I'm supposed to upload the image to a directory, and store the link to that directory in database. First, how would I make a form that uploads the picture to the directory (And what kinda directories are we talking?). Secondly, how would I retrieve that link? And I guess I should rename the picture.. I'd appreciate any help, or a good tutorial (Haven't found any myself). This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=351137.0 Hi, How can i show image using absolute path instead of virtual path?? Help please I have the folder structure like:
root
application
system
assets
uploads
folder assets contains all css, img, and js.
uploads contains user uploaded file.
I set a "helper/assets_helper.php" file to define:
define ('ASSETS_PATH', base_url().'assets/'); define ('UPLOAD_URL', base_url().'uploads/');For all the css, img, and js, it works well like href="<?php echo ASSETS_PATH; ?>css/mycss.css"But when I display the uploaded images, it couldn't display image with <a href="<?php echo UPLOAD_URL;?>images/myupload01.jpg" ><img src="<?php echo UPLOAD_URL;?>images/myupload01.jpg" /></a>This uploaded image actually works fine with my localhost with the link like: http://localhost:900.../myupload01.jpg. But it couldn't display on my hosting server with like: http://users.mywebsi.../myupload01.jpg Can anyone shed some light on it. Thanks! Edited by TFT2012, 20 October 2014 - 10:43 AM. Hey Everyone, I have these 3 scripts to upload an image but I'm having an issue because the images uploaded are going to the same directory as the pages. What do I need to change to make the uploaded images go to a folder path called "pictures". Thanks in advance for the help. Script 1 <form name="form1" method="post" action="adminpicturebrowse.php"> <p align="center">How many pictures for this dog? Max is 9</p> <p align="center"> <input name="uploadNeed" type="text" id="uploadNeed" maxlength="1"> <input type="submit" name="Submit" value="Submit"> </p> </form> Script 2 <form name="form1" enctype="multipart/form-data" method="post" action="adminaddupload.php"> <p align="center"> <? // start of dynamic form $uploadNeed = $_POST['uploadNeed']; for($x=0;$x<$uploadNeed;$x++){ ?> <input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>"> </p> <div align="center"> <? // end of for loop } ?> </div> <p align="center"><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>"> <input type="submit" name="Submit" value="Submit"> </p> </form> Script 3 <? $uploadNeed = $_POST['uploadNeed']; // start for loop for($x=0;$x<$uploadNeed;$x++){ $file_name = $_FILES['uploadFile'. $x]['name']; // strip file_name of slashes $file_name = stripslashes($file_name); $file_name = str_replace("'","",$file_name); $copy = copy($_FILES['uploadFile'. $x]['tmp_name'],$file_name); // check if successfully copied if($copy){ echo "$file_name<br>"; }else{ echo "$file_name<br>"; } } // end of loop ?> How can I make the image path not have the starting slash for the $path? Currently this... Code: [Select] function getUserAvatar($username) { if (file_exists("{$GLOBALS['path']}/img/${username}.png")) { return "/assets/img/${username}.png"; } else { return "/assets/img/defaultuser.jpg"; } } When path is executed I need it to make /assets/ be assets/ I need to remove the first character from the $path variable. if ($type === 'image/png'){ imagepng($this->img, $path); } hi i want to store url to images in database for logged in users (where id = $id) and recall the image hopefully using --------------------- <img src="<?php echo row['link']; ?>" /> or similar and need help with the sql update string any ideas please help i been stuck with this for some time and now decided to ask around in this forum for help, please help if you can. Hey, i need help storing an image in my database via the URL(image location) at the moment my php code is storing the image in a folder on the directory called upload. here is the code: <?php // Where the file is going to be placed $target_path = "upload /"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $target_path = "upload/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> Click <a href="products.php">HERE</a> to go back to form if someone could help me i'd be very grateful Hi, wondering if somebody can tell me where I'm going wrong (I'm new to all of this). I have the following php code which uploads an image file into my database: Code: [Select] //Connect to database include 'Resources/Include/db.inc.php'; $tmp=$_FILES['image']['tmp_name']; //get users IP $ip=$_SERVER['REMOTE_ADDR']; //Don't do anything if file wasn't selected if (!empty($tmp)) { //Copy file to temporary folder copy($tmp, "./temporary/".$ip.""); //open the copied image, ready to encode into text to go into the database $filename1 = "./temporary/".$ip; $fp1 = fopen($filename1, "rb"); //record the image contents into a variable $contents1 = fread($fp1, filesize($filename1)); $contents1 = addslashes($contents1); //close the file fclose($fp1); $ftype = $_FILES['image']['type']; //insert information into the database if(!mysql_query("INSERT INTO LetterImages (Data,Type,LetterID,Page)"." VALUES ( '$contents1', '$ftype',1,1)")){ echo mysql_error(); } //delete the temporary file we made unlink($filename1); } This seems to work ok, as when I go to the LetterImages table there is now an additional row with a file in the blob field. I then have the following code which is supposed to display the image: Code: [Select] $result=mysql_query("SELECT * FROM LetterImages WHERE LetterID=1 AND Page=1"); //fetch data from database $sqldata=mysql_fetch_array($result); $encoded=stripslashes($sqldata['Data']); $ftype=$sqldata['Type']; //tell the browser what type of image to display header("Content-type: $ftype"); //decode and echo the image data echo $encoded; Instead of displaying an image, however, this just displays pages and pages of incomprehensible data. Can anybody tell me where I'm going horribly wrong? Hello freaks! Im new to this forum, but im not all that new to PHP and MySQL. Although there's been some years since the last time I used it, so don't go all freaky on me if I dont do this right Let's go on-topic: Im in progress of making an internal web-page for me and my colleagues to make things a bit easier for us. I am making an database of our different projects, and I need some help with the input form - as I need to upload an image to the server, and store the path in the MySQL database. In my input form, I need to store information from text fields, and I need to upload an image to the server and store the path in the database. Before I can even start to code this (although I have coded the input forum without the upload), I need to know what would be the best way to do this. I guess there are several ways.. What would the expert do (That's you right?)? Should I have the information input, and image upload in the same form, or should I make a second form (maybe on a different page) for the upload? Is it necessary with two tables, one for the info and one for the image path, and then tie them together with the imageID, or is it fine to use just one table? Any thoughts would be appreciated! <!-- TechThat --> I have a PHP script that uploads images to a folder on my server (attachments folder). Currently the folder sits within my webroot and is publicly accessible (I have to use chmod 777 due to permissions issue). So, I created the "attachments" folder outside of my webroot (so that it is not publicly accessible), but I do not know how to set the path in the PHP code to upload it to that "attachments" folder outside of the webroot. As you see in the snippet of PHP code below, the code currently uploads the the "attachments" folder within the www (webroot) directory. How do I make it upload to the "attachments" folder OUTSIDE of the www (webroot) directory? foreach($files[$form] as $file){ $str = $file[1]; if (eval("if($str){return true;}")) { $_values[$file[0]] = $_FILES[$file[0]]["name"]; $dirs = explode("/","attachments//"); $cur_dir ="."; foreach($dirs as $dir){ $cur_dir = $cur_dir."/".$dir; if (!@opendir($cur_dir)) { mkdir($cur_dir, 0777);}} $_values[$file[0]."_real-name"] = "attachments/".date("YmdHis")."_".$_FILES[$file[0]]["name"]."_secure"; copy($_FILES[$file[0]]["tmp_name"],$_values[$file[0]."_real-name"]); @unlink($_FILES[$file[0]]["tmp_name"]); }else{ $flag=true; if ($_isdisplay) { //$ExtFltr = $file[2]; //$FileSize = $file[4]; if (!eval("if($file[2]){return true;}")){echo $file[3];} if (!eval("if($file[4]){return true;}")){echo $file[5];} $_ErrorList[] = $file[0]; } } } In NetBeans - in what I think is the Web Root - I have... config.inc.php secure/checkout.php In "checkout.php", when I use this code it works... Code: [Select] <?php require_once "../config.inc.php"; ?> but when I try to use an Absolute Path, it errors out... Code: [Select] <?php require_once "/config.inc.php"; ?> I thought "/" moved you up to the Web Root and then you drill down from there? So the second example should also work in my mind?! What is wrong? Debbie Im having a strange path problem. The problem is that in the base directory, i have some php files. These goes well. I also have two folders: one for my function library, and other for some type of webpages. My problem is that if i changue to a webpage in that folder through the menu in the base directory the path itself it also changues, so it became that directory. Base dir: tr Library directory: lib Category dir: categorias (these two are in tr, and tr in www of wamp) If i echo a link like this in some page that is in the tr directory: <li><a href="categorias/listar_memoria_ram.php">List RAM Memory</a></li> And i go to that web, the include path changues, so it became categorias. I use functions to echo the menu each time, so, it dont work because it uses the relative path, so, if i echo this again: <li><a href="categorias/listar_memoria_ram.php">List RAM Memory</a></li> the url thas is finally called in the web explorer is: http://localhost/tr/categorias/categorias/listar_Memoria_Ram.php That dont exist. Note also that all my web functions are in a file that exists in the lib library and thats included each time using this: include_once '/../lib/lib_inventario.php'; That file have a impMenu function that is used each time, and all the others. What i was seeking if a plain way of controlling the path so it became more simplier and i could just use a single path, without exceptions. Or at least an explanation that why these happens. Ask for whatever any extra information you need. I need help making the uploaded image file name, that's chosen to be uploaded, be displayed on the html page with the path /upload/ added to the beginning of the displayed file name like so: ../upload/test.png Any help/improvements will be appreciated. <html> <head> <title>PHP Test</title> </head> <body> <?php if ($form_submitted == 'yes') { $allowedExts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_FILES["file"]["name"]); $extension = strtolower( end($temp) ); if ( $_FILES["file"]["size"] < 200000 && in_array($extension, $allowedExts) ) { if ($_FILES["file"]["error"]!= 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else { $length = 20; move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename ); $file_location = '<a href="http://../upload/' . $newfilename . '">' . $newfilename . '</a>'; } } else { echo "Invalid upload file"; } ?> <label for="file">Filename:</label> <input type="file" name="file" id="file"> </body> </html> I have a script.. it works fine on my localhost.. now i am trying to work it with on my remote server.. the script reads the folder in my c drive and shows me the file on display here is the code <?php $main_dir ="C:\\xampp\\htdocs\\xtrajam"; $main_open = opendir($main_dir); while(($main_file = readdir($main_open)) != FALSE) { echo $main_file."<br />"; } closedir($main_open); ?> Now the thing is this works fine on local host as it can easy access the path C:\\xampp\\htdocs\\xtrajam Now i want this path to be accessed sumhow wen i try it on my remote server.. how should i do that like when i run the script online it reads the contents from my c drive directory..? is it sumhow possible? Hi guys, hoping for some help here. I've a database created with a website. I recently got help here off Muddy Funster who was a MASSIVE help to me on this thread - http://www.phpfreaks.com/forums/index.php?topic=357580.new;topicseen#new I've another slight problem with what I am trying to do. At the moment the user can search for an ID and it brings up the relevant information. What I am doing now is that the user has entered the ID, their taken to the results where they can be viewed. What I have added is a form at the bottom of the results page, which has to be filled in and saved. I thought this would be relatively easy. I have the form storing in the database, but there is one problem, its being added as another document! So instead of clicking save and the information being added to the ID that is already associated with it, it is incrementing the ID in the database and being stored separately to the ID that was searched. Could anyone give any help as to why this might be happening? I have on the button 'Save' click, it goes to another php file and inserts the data to the relevant fields, I'm not sure why it is incrementing the ID separately instead of just saving to the ID that it is associated with I don't no if I'm making it clear enough but what I wanted to do was save the form they filled out with the ID that was searched if you get me? Thanks for any help Hi there, i follow a tutorial from www.phpwebcommerce.com and i'm having path problem for 'add to cart' button. Demo from phpwebcommerce: http://www.phpwebcommerce.com/plaincart/index.php I have modified some changes, i'm putting the 'add to cart' button to 1st level instead of 2nd level. Example, under all category (car & manga) i choose car, then inside car category list there is a 'add to cart' button under all car product instead of clicking inside and show 'add to cart' button. productDetail.php: Code: [Select] <?php if (!defined('WEB_ROOT')) { exit; } $product = getProductDetail($pdId, $catId); // we have $pd_name, $pd_price, $pd_description, $pd_image, $cart_url extract($product); ?> <table width="100%" border="0" cellspacing="0" cellpadding="10"> <tr> <td align="center"><img src="<?php echo $pd_image; ?>" border="0" alt="<?php echo $pd_name; ?>" width="230" height="170"></td> <td valign="middle"> <strong><?php echo $pd_name; ?></strong><br> Price : <?php echo displayAmount($pd_price); ?><br> <?php // if we still have this product in stock // show the 'Add to cart' button if ($pd_qty > 0) { ?> <input type="button" name="btnAddToCart" value="Add To Cart >" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton"> <?php } else { echo 'Out Of Stock'; } ?> </td> </tr> <tr align="left"> <td colspan="2"><?php echo $pd_description; ?></td> </tr> </table> I copy this code out from productDetail.php: Code: [Select] <input type="button" name="btnAddToCart" value="Add To Cart >" onClick="window.location.href='<?php echo $cart_url; ?>';"> productList.php: Code: [Select] <?php if (!defined('WEB_ROOT')) { exit; } $productsPerRow = 2; $productsPerPage = 8; //$productList = getProductList($catId); $children = array_merge(array($catId), getChildCategories(NULL, $catId)); $children = ' (' . implode(', ', $children) . ')'; $sql = "SELECT pd_id, pd_name, pd_price, pd_thumbnail, pd_qty, c.cat_id FROM tbl_product pd, tbl_category c WHERE pd.cat_id = c.cat_id AND pd.cat_id IN $children ORDER BY pd_name"; $result = dbQuery(getPagingQuery($sql, $productsPerPage)); $pagingLink = getPagingLink($sql, $productsPerPage, "c=$catId"); $numProduct = dbNumRows($result); // the product images are arranged in a table. to make sure // each image gets equal space set the cell width here $columnWidth = (int)(100 / $productsPerRow); ?> <table width="100%" border="0" cellspacing="0" cellpadding="20"> <?php if ($numProduct > 0 ) { $i = 0; while ($row = dbFetchAssoc($result)) { extract($row); if ($pd_thumbnail) { $pd_thumbnail = WEB_ROOT . 'images/product/' . $pd_thumbnail; } else { $pd_thumbnail = WEB_ROOT . 'images/no-image-small.png'; } if ($i % $productsPerRow == 0) { echo '<tr>'; } // format how we display the price $pd_price = displayAmount($pd_price); echo "<td width=\"$columnWidth%\" align=\"center\"><a href=\"" . $_SERVER['PHP_SELF'] . "?c=$catId&p=$pd_id" . "\"><img src=\"$pd_thumbnail\" border=\"0\" width=\"230\" height=\"170\"><br>$pd_name</a><br>Price : $pd_price<br> <input type=\"button\" name=\"btnAddToCart\" value=\"Add To Cart >\" onClick=\"window.location.href='<?php echo $cart_url; ?>';\" >"; // if the product is no longer in stock, tell the customer if ($pd_qty <= 0) { echo "<br>Out Of Stock"; } echo "</td>\r\n"; if ($i % $productsPerRow == $productsPerRow - 1) { echo '</tr>'; } $i += 1; } if ($i % $productsPerRow > 0) { echo '<td colspan="' . ($productsPerRow - ($i % $productsPerRow)) . '"> </td>'; } } else { ?> <tr><td width="100%" align="center" valign="center">No products in this category</td></tr> <?php } ?> </table> <p align="center"><?php echo $pagingLink; ?></p> The code i copy from productDetail.php i paste in productList.php at line48, it show the 'add to cart' button but when i click on it, it cant add to my shopping cart and it show error: Notice: Undefined variable: cart_url in C:\Domains\xxxxxxxx\wwwroot\xxxxxxxx\plaincart\include\productList.php on line 48 Notice: Undefined variable: cart_url in C:\Domains\xxxxxxxx\wwwroot\xxxxxxxx\plaincart\include\productList.php on line 48 Notice: Undefined variable: cart_url in C:\Domains\xxxxxxxx\wwwroot\xxxxxxxx\plaincart\include\productList.php on line 48 Notice: Undefined variable: cart_url in C:\Domains\xxxxxxxx\wwwroot\xxxxxxxx\plaincart\include\productList.php on line 48 Will Appreciate For Any Help....Thank you in advanced & sorry for the bad English. Hello. My question for majority is very simple but not for me...
I would like to change photo for other at the top on the subpage in this link http://www.grimlord.eu/index_pl.php?src=gallery&sub=koncertowe Here is good http://www.grimlord.eu/index_pl.php?src=galeria What I can do? I used index.pl.php file
|