Jump to content

Grimloch

Members
  • Posts

    67
  • Joined

  • Last visited

    Never

Everything posted by Grimloch

  1. Well, I don't really understand why but it's obvious to me now that I can no longer expect any help from anyone on this forum system. Thats too bad because I found it to be a valuable resource and may still read posts from time to time. But you won't be bothered by my requests for help anymore as it has become pointless. Thanks to everyone on here who DID help me; I appreciate it. So long.
  2. I am totally absolutely bewildered. Why is it that I can't seem to get any help here with my problem? No suggestions; no comments; no NOTHING! Is this problem too tough for anyone here? Is thing thing I am trying to accomplish an undo-able thing in PHP/MySQL? Since I've made some rather hasty and regrettable comments on previous posts, is it that no one wants to bother with me? Exactly what is the problem here? If no one can help PLEASE at least point me to where I CAN get some help.
  3. ...I am getting closer and closer. After much experimentation I determined that my $img_name and $img_ext 'strtolower' functions were not right and it was never separating the filenames into name,extension. Here is my code now: // ad image upload while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) $imagename = $_FILES['adimg']['name'][$key]; $source = $_FILES['adimg']['tmp_name'][$key]; $img_name = strtolower(substr($imagename, 0, strrpos($imagename, "."))); $img_ext = strtolower(strrchr($imagename,".")); $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; $thumbs = INFUSIONS.'classified_ads_panel/images/ads/thum/'; $img_file = image_exists($target, $img_name.$img_ext); move_uploaded_file($source, $target); $imagefile = @getimagesize($img_file); $thb = image_exists($target, $img_name."_t1".$img_ext); createthumbnail($imagefile[2], $thumbs.$img_file, $thumbs.$thb, $settings['thumb_w'], $settings['thumb_h']); } } // end ad image upload And here is an image of my ftp dir after upload. The thumb function is now writing the correct filename but the files are still empty. Please, if anyone can see what I am doing wrong here I would be most greatful! Then I must solve the db update coding. Thanks in advance.
  4. Hello folks I'm back again. I'm right on the verge of solving the middle third of my 3 part equation for uploading multiple images to a classified ads script in PHP-Fusion7 CMS. The 3 part equation is: 1) Upload and save multiple images - works! 2) Generate and save thumbs for them - almost works. 3) Update db with image/thumb info - not tackled yet, don't know how. Part 2: Here is the code I have in place now that successfully uploads and saves multiple images. function Add($cat, $title, $description, $url, $weeks, $owner, $owner_id) { global $adstext, $locale, $userdata, $settings, $db_prefix; require_once INCLUDES."photo_functions_include.php"; if(isset($_POST[save_ad])) { $postdate = time(); $expiredate = $postdate + (3600 * 24 * $weeks); $url = explode("http://", $url); if ($url[1]=="") { $myurl = ""; } else { $myurl ="$url[1]"; } // Check if Category exist if ($cat=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0041']."<br />"; exit(); } // Check if Title exist if ($title=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0042']."<br />"; exit(); } // Check if ads text exist if ($description=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0043']."<br />"; exit(); } // Check ads text length if (strlen($description) > $adstext) { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0044'].": $adstext characters.<br />"; exit(); } $title = addslashes($title); $description = addslashes($description); // ad image upload while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) $imagename = $_FILES['adimg']['name'][$key]; $source = $_FILES['adimg']['tmp_name'][$key]; $img_pic = $_FILES['imagename']; $img_name = strtolower(substr($img_pic['name'][$key], 0, strrpos($img_pic['name'][$key], "."))); $img_ext = strtolower(strrchr($img_pic['name'][$key],".")); $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; $thumbs = INFUSIONS.'classified_ads_panel/images/ads/thum/'.$imagename; $img_file = image_exists($target, $img_name.$img_ext); move_uploaded_file($source, $target); $imagefile = @getimagesize($target.$img_file); $thb = image_exists($target, $img_name."_t1".$img_ext); createthumbnail($imagefile[2], $thumbs.$img_file, $thumbs.$thb, $settings['thumb_w'], $settings['thumb_h']); } } // end ad image upload These are images of my ftp directory after upload: Complete dir is: infusions/classified_ads_panel/images/ads/thum/ images/ads are main images and ads/thum are thumbnails As you can see its writing the thumb filenames but incorrectly and the files are empty. I've racked my brain trying to figure out what I have wrong in the code and just can't seem to get my head around it. Any help appreciated.
  5. I need to close this thread as solved because the actual problem (multi-image upload), is now working although this is only 1/3 of the entire equation I need to solve. I will either start a new thread or seek other resources for help. Thanks to all who have helped me here.
  6. OK this is wrong; the problem was I was uploading images from the same few. I guess I just lost track. The code DOES in fact upload the images consistently now. I just have to figure out how to do proper image type/size checking and generate thumbs. Then I have to figure out how to extract the image names and thumb names for updating the db. And I'm pretty sure this ALL has to be done within the 'while loop' because I tried echoing the image names after the loop/upload and it doesn't work.
  7. Its not really that long and I thought it might be beneficial to anyone trying to help me out, to post the entire code (just the portions that deal with adding a new ad). Here it is: function add_ad() { global $userdata, $mostweeks, $defaultweeks, $adstext, $locale, $max_img, $db_prefix; echo " <table border='0' cellspacing='2' cellpadding='3' width='100%'> <tr><td>"; $mainlink = 1; menu($mainlink); echo " </td></tr> <tr><td colspan='2'></td></tr> <tr><td class='small' colspan='2'><br />"; SearchForm(); echo " </td></tr> <tr><td colspan='2'></td></tr> <tr><td colspan='2'><b>".$locale['CLS_0031']."</b></td></tr> <tr><td colspan='2'></td></tr>"; if (iMEMBER) { echo " <tr><td>".$locale['CLS_0005']." <b>".$userdata['user_name']."</b>, ".$locale['CLS_0032']."</td></tr> <tr><td></td></tr> <tr><td> <form enctype='multipart/form-data' name='inputform' method='post' action='".FUSION_SELF."?op=Add'> <table> <tr><td>".$locale['CLS_0033']."</td> <td><SELECT class='textbox' name='cat'>"; echo "<option value=''>".$locale['CLS_0034']."</option>\n"; $result = dbquery("SELECT cid, title, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' ORDER BY parentid,title"); while(list($cid2, $ctitle2, $parentid2) = dbarraynum($result)) { if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2); echo "<option value='$cid2'>$ctitle2</option>\n"; } echo "</SELECT> </td></tr> <tr><td>".$locale['CLS_0035']."</td><td><input class='textbox' type='text' name='title' size='45' maxlength='100' /></td></tr> <tr><td valign='top'>".$locale['CLS_0036']."</td> <td><textarea class='textbox' name='description' cols='40' rows='15' wrap='virtual'></textarea></td></tr></tr> <tr><td> </td><td>"; class_showbbcode('description'); echo "</td></tr> <tr><td> </td><td>"; class_showbbcodecolor('description'); echo "</td></tr> <tr><td> </td><td>".$locale['CLS_0037']."$adstext characters.</td></tr> <tr><td>".$locale['CLS_0025']."</td><td><input class='textbox' type='text' name='url' size='45' maxlength='100' value='http://' /></td></tr>"; for($i=1; $i<=$max_img; $i++){ echo "<tr><td>".$locale['CLS_0103']."$i:</td><td> <input id='adimg' class='textbox' type='file' name='adimg[]' size='45' maxlength='150'></td></tr>"; } echo "<tr><td>".$locale['CLS_0030'].":</td><td>"; prweek($mostweeks, $defaultweeks); echo " ".$locale['CLS_0040']."</td></tr> <tr><td colspan='2' align='center'> <input type='hidden' name='owner' value='".$userdata['user_name']."' /> <input type='hidden' name='owner_id' value='".$userdata['user_id']."' /> <input type='hidden' name='op' value='Add' /> <input class='button' type='submit' name='submit' value='".$locale['CLS_0038']."' /> </td></tr> </table> </form> </td></tr>"; } else { echo " <tr> <td> <p>".$locale['CLS_0039']."</td> </tr>"; } echo " </table>"; } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ function Add($cat, $title, $description, $url, $weeks, $owner, $owner_id) { global $adstext, $locale, $userdata, $settings, $db_prefix; //require_once INCLUDES."photo_functions_include.php"; $postdate = time(); $expiredate = $postdate + (3600 * 24 * $weeks); $url = explode("http://", $url); if ($url[1]=="") { $myurl = ""; } else { $myurl ="$url[1]"; } // Check if Category exist if ($cat=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0041']."<br />"; exit(); } // Check if Title exist if ($title=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0042']."<br />"; exit(); } // Check if ads text exist if ($description=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0043']."<br />"; exit(); } // Check ads text length if (strlen($description) > $adstext) { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0044'].": $adstext characters.<br />"; exit(); } $title = addslashes($title); $description = addslashes($description); // ad image upload if(isset($_POST[submit])) { while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) $imagename = $_FILES['adimg']['name'][$key]; $source = $_FILES['adimg']['tmp_name'][$key]; $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; move_uploaded_file($source, $target); } } // end ad image upload $result = dbquery("INSERT INTO ".DB_CLASSIFIED." VALUES(NULL, '$cat', '$title', '$description', '$myurl', '$postdate', '$expiredate', '$owner', '$owner_id','0','$img1','$img2','$img3','$img4','$img5','$img6','$thb1','$thb2','$thb3','$thb4','$thb5','$thb6')"); $result = dbquery("delete low_priority FROM ".DB_CLASSIFIED." WHERE(expiredate < '$postdate')"); echo $locale['CLS_0108']; redirect(FUSION_SELF."?op=view_ad&cid=$cat",'2'); } All main script areas(functions) are called from a 'switch' setup at the very end of the main script just to clarify.
  8. OK; I don't quite understand whats happening now... I implemented the code changes and WALLA! the 6 files were uploaded! Seemed great. But then I deleted the files on the server to try again(was trying to implement saving to db; that didn't work); so I deleted that save to db code and now, it WILL NOT upload images again with subsequent test posts. Doesn't make sense to me. I figured maybe cookies/sessions/variables not cleared so I logged on and off my site several times. That has not helped. I don't understand. Here is the code now: // ad image upload if(isset($_POST[submit])) { while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) $imagename = $_FILES['adimg']['name'][$key]; $source = $_FILES['adimg']['tmp_name'][$key]; $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; move_uploaded_file($source, $target); } } // end ad image upload
  9. You were right. I should've been checking for (submit). Thanks! This is what I have in place now: // ad image upload if(isset($_POST[submit])) { while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) { echo $_FILES['adimg']['name'][$key]." | ".$_FILES['adimg']['tmp_name'][$key]."<br /><br />"; } echo "<pre>"; echo "POST:"; print_r($_POST); echo "FILES:"; print_r($_FILES); echo "</pre>"; } // $imagename = $_FILES['adimg']['name']; // $source = $_FILES['adimg']['tmp_name']; // $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; // move_uploaded_file($source, $target); // } } // end ad image upload die; And the above produces the following output: windows.gif | /tmp/phpMnDkur POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) themes.gif | /tmp/phpeM6MNI POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) software.gif | /tmp/phpwLtne0 POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) security.gif | /tmp/phpw51ZCh POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) php-fusion.gif | /tmp/phpSGxXJB POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) network.gif | /tmp/phpC8tUOV POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) I tried uncommenting the upload/save portion and it hangs the server; so my question is still; how do I code it correctly to actually upload and save the images??
  10. I'm trying to get this down to just basics first. Below is the code I am trying to use now to upload 6 images(or less) to my 'save dir'. It does not work; nothing is saved in the upload dir. What am I doing wrong here?? The input portion: for($i=1; $i<=$max_img; $i++){ echo "<tr><td>".$locale['CLS_0103']."$i:</td><td> <input id='adimg' class='textbox' type='file' name='adimg[]' size='45' maxlength='150'></td></tr>";} The upload/save portion: // ad image upload if(isset($_POST[adimg])) { while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) $imagename = $_FILES['adimg']['name']; $source = $_FILES['adimg']['tmp_name']; $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; move_uploaded_file($source, $target); } } // end ad image upload
  11. Good morning mrMarkus (or anyone that may have some time to look at this); OK... tried your code and it gives me the output I was looking for. Let me lay the whole thing out and see if I can explain what I am trying to accomplish here. 1) These are the dbFields where the images and thumbs will be stored: img1 varchar(100) NOT NULL default '', img2 varchar(100) NOT NULL default '', img3 varchar(100) NOT NULL default '', img4 varchar(100) NOT NULL default '', img5 varchar(100) NOT NULL default '', img6 varchar(100) NOT NULL default '', thb1 varchar(100) NOT NULL default '', thb2 varchar(100) NOT NULL default '', thb3 varchar(100) NOT NULL default '', thb4 varchar(100) NOT NULL default '', thb5 varchar(100) NOT NULL default '', thb6 varchar(100) NOT NULL default '', 2) This is your code mrMarkus w/my changes: // ad image upload while (list ($key, $value) = each($_FILES['image']['tmp_name'])) { if (!empty ($value)) { echo $_FILES['image']['name'][$key]."_";echo $_FILES['image']['tmp_name'][$key]."<br /><br />"; } } // end ad image upload 3) These are the images of the input/output produced: OOooppss... img input names are from a different test session; but you get the idea... Input Output 4) This is how I need to store the images in db: $img1 = downloads.gif $img2 = hardware.gif $img3 = members.gif $img4 = network.gif $img5 = software.gif $img6 = graphics.gif ---------- $thb1 = downloads_t1.gif $thb2 = hardware_t1.gif $thb3 = members_t1.gif $thb4 = network_t1.gif $thb5 = software_t1.gif $thb6 = graphics_t1.gif Of course these are just test images; actual uploads will almost always be JPGs. I have no idea how to go about saving those uploads into the specified directory; I'm assuming it ALL has to be done within the (while loop) is that right? As well as the thumb creation and save?? Earlier I had tried a slight variation of the very code that you showed me mrMarkus but I got errors saying that I was trying to save array elements instead of strings. So the array elements which contain the image names must first be converted to strings I think. There again I don't know how to go about that. I know this is long-winded and I apologize. If anyone has the time to take a look at this and help me I will be most appreciative.
  12. You sir, are absolutely right and I apologize for my earlier statement. I'll try what you propose and see if it will help. Thanks
  13. Not really solved but I've come to expect little help here lately for some reason. Plus I discovered a lot more resources on the web that I haven't exhausted yet so; I'll figure it out myself.
  14. The problem is: I get nothing echoed to the screen so my question is am I going about this the right way and is my input routine correct? If I can get the input routine to work right then I can convert the array elements to strings for actual uploading and saving to the upload directory. And THEN I can figure out the db update process.
  15. If you examine the code, I'm looking for '$picture' to be echoed to the screen 6 times showing the 6 images w/local computer urls for upload and then die so it doesn't continue script execution.
  16. Lets see if I can get some help on this one. Can anyone show me what I am doing wrong here. I'm just trying at this point to verify that the form inputs will work right. $max_img is set to 6. Here is the code: <form enctype='multipart/form-data' name='inputform' method='post' action='".FUSION_SELF."?op=Add'> for($i=1; $i<=$max_img; $i++){ echo "<tr><td>".$locale['CLS_0103']."$i:</td><td> <input class='textbox' type='file' name='image[]' size='45' maxlength='150' value='http://'></td></tr>"; } </form> /////////////////////// //image upload handling $array = (isset($_POST['image'])); $list = implode(",",$array); $ad_pic = $list; $list_array = explode(",",$ad_pic); reset($list_array); foreach($list_array AS $picture) { echo $picture."<br />"; } // end upload handling die; After 'die' executes I get no output. Any help appreciated.
  17. Maybe I'm not providing enough info here as no one has responded: Normally in this script all the sub-cats are displayed BELOW the main cats as in the pic but; with 208 sub-cats thats a very LONG page. So I decided to do what I am seeking help with. Now when you click on a main cat the sub-cats for that one ONLY are displayed below the main cats w/the # of posts in each one, which makes better sense. Here is the table that stores the cats info: cid int(11) unsigned NOT NULL auto_increment, title varchar(100) NOT NULL default '', description text NOT NULL, image varchar(100) NOT NULL default '', parentid int(11) unsigned NOT NULL default '0', status enum('0','1') NOT NULL default '0', PRIMARY KEY (cid) ) TYPE=MyISAM;"; Hoping for some help here.
  18. Hello all. I'm hoping to be able to get some help in solving a problem with query/rowcount output. I've been learning PHP and mySQL for about 7 months now and have several successful Mods written/modified for PHP-Fusion CMS version7.00.05. My host is running PHP-5 and MySQL-5. I am converting a Mod from Fusion-ver6 to work on ver-7, called Classified Ads. It has turned out to be a MONSTER to modify and I have run into a snag. There is code that selects ALL the categories and divides them in half displaying half in a table TD and the other half in another TD beside it for a 2 column display. This works just great. What I have is 22 categories and approx. 220 sub-categories. What I am trying to do is display the number of sub-categories below each main category. Here is a pic of the current display with annotations: I tried using the same code (which works for the main cats), to display the # of sub-cats. It works fine for the first TD but fails in the second TD. I will show the pertinent code rather than posting the entire script, unless requested to do so. Here is the code that produces what you see in the pic: echo "<table width='100%' border='0' cellspacing='0' cellpadding='3'><tr>\n"; $result = dbquery("SELECT * FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' AND parentid=0"); $numrows = dbrows($result); if($numrows > 0) { $numrows % 2 ? $numrows += 1 : $numrows; $rows = $numrows / 2; echo "<td valign='top' width='50%'>"; $result = dbquery("SELECT cid, title, description, image, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' AND parentid='0' ORDER BY title LIMIT $rows"); while(list($cid, $title, $description, $image, $parentid) = dbarraynum($result)) { $count1=dbcount("(*)", $db_prefix."classified", " cid='$cid' AND status='1'"); echo "<table cellspacing='2' cellpadding='1' width='100%' border='0'><tr>\n"; echo "<td valign='top' width='100%'>"; if($image) { echo "<a href='".FUSION_SELF."?op=view_ad&cid=".$cid."'><img src='".INFUSIONS."classified_ads_panel/images/cat/".$image."' alt='".$title."' border='0'></a>(<strong>".$count1." "; if($count1>1 || $count1<1) { echo $locale['CLS_0120']; } else { echo $locale['CLS_0119']; } echo "</strong>)"; } else { echo "<a href='".FUSION_SELF."?op=view_ad&cid=".$cid."'><strong>".$title."</strong></a>(<strong>".$count1." "; if($count1>1 || $count1<1) { echo $locale['CLS_0120']; } else { echo $locale['CLS_0119']; } echo "</strong>)<br />"; // start here $subresult = dbquery("SELECT * FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' AND parentid >0"); $myrows = dbrows($subresult); if($myrows > 0) { $myrows % 2 ? $myrows += 1 : $myrows; $subrows = $myrows / 2; $subresult = dbquery("SELECT cid, title, description, image, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE parentid >0 AND parentid=$cid ORDER BY parentid LIMIT $subrows"); $myrows = dbrows($subresult); $subrows = $myrows; } echo $subrows." sub-categories<br />"; // end here } echo "</td>\n"; echo "</tr><tr>\n"; echo "<td>".$description."</td>\n"; echo "</tr></table>\n"; } echo "</td><td valign='top' width='50%'>"; $result1 = dbquery("SELECT cid, title, description, image, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' AND parentid='0' ORDER BY title LIMIT $rows, $rows"); while(list($cid, $title, $description, $image, $parentid) = dbarraynum($result1)) { $count1=dbcount("(*)", $db_prefix."classified", " cid='$cid' AND status='1'"); echo "<table cellspacing='2' cellpadding='1' width='100%' border='0'><tr>\n"; echo "<td valign='top' width='100%'>"; if($image) { echo "<a href='".FUSION_SELF."?op=view_ad&cid=".$cid."'><img src='".INFUSIONS."classified_ads_panel/images/cat/".$image."' alt='".$title."' border='0'></a>(<strong>".$count1." "; if($count1>1 || $count1<1) { echo $locale['CLS_0120']; } else { echo $locale['CLS_0119']; } echo "</strong>)"; } else { echo "<a href='".FUSION_SELF."?op=view_ad&cid=".$cid."'><strong>".$title."</strong></a>(<strong>".$count1." "; if($count1>1 || $count1<1) { echo $locale['CLS_0120']; } else { echo $locale['CLS_0119']; } echo "</strong>)<br />"; // start here $subresult = dbquery("SELECT cid, title, description, image, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE parentid >0 AND parentid=$cid ORDER BY parentid LIMIT $subrows, $subrows"); $myrows = dbrows($subresult); $subrows = $myrows; echo $subrows." sub-categories<br />"; // end here } echo "</td>\n"; echo "</tr><tr>\n"; echo "<td>".$description."</td>\n"; echo "</tr></table>\n"; } echo "</td>\n"; } I'm wondering why my added code works OK for the first part but not the second part. Any and all help/suggestions would be GREATLY appreciated.
  19. Well, I have figured out how to display categories and sub-categories in 2 colums instead of one, so I am making progress. Here is what it looks like now: I 'AM' trying to work this out...
  20. Hello again folks, I need some coding help. I am working with PHP-Fusion ver7 and am converting an old Fusion6 'Classified Ads' mod to work w/Fusion7. I am running MySQL5 and PHP5 on the server. The script displays categories and sub-categories w/ the # of ads in each one. Heres where I am: 1) I want to be able to display sub-cats w/the (parent main cat 'title') displayed ONCE for every group of (sub-cats 'under' that main cat). Here is an image of what it looks like now. And here is the code that produces this output: //Sub categories in new table echo "<table width='100%' border='0' cellspacing='2' cellpadding='1'><tr><br />\n"; echo "<td width='100%' align='center' class='tbl2'><strong><big><u>".$locale['CLS_0020']."</u></big></strong></td>\n"; echo "</tr><tr>\n"; echo "<td valign='top' width='100%'>"; $result1 = dbquery("SELECT cid, title, description, image, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' AND parentid >0 ORDER BY parentid LIMIT $frontcat"); while(list($cid1, $title1, $description1, $image1, $parentid1) = dbarraynum($result1)) { [color RED] $title=getparentMain($parentid1,$title1); echo "<strong><big><u>".$title."</u></big></strong>"; [END COLOR RED] $count2=dbcount("(*)", $db_prefix."classified", " cid='$cid1' AND status='1'"); echo "<table cellspacing='2' cellpadding='2' width='100%' border='0'><tr>\n"; echo "<td valign='middle'>"; if($image1) { echo "<a href='".FUSION_SELF."?op=view_ad&cid=".$cid1."'><img src='".INFUSIONS."classified_ads_panel/images/cat/".$image1."' alt='".$title1."' border='0'></a>(<strong>".$count2." "; if($count2>1 || $count2<1) { echo $locale['CLS_0120']; } else { echo $locale['CLS_0119']; } echo "</strong>)"; } else { echo "<a href='".FUSION_SELF."?op=view_ad&cid=".$cid."'><strong>".$title1."</strong></a>(<strong>".$count2." "; if($count2>1 || $count2<1) { echo $locale['CLS_0120']; } else { echo $locale['CLS_0119']; } echo "</strong>)"; } echo "</td>\n"; echo "</tr><tr>\n"; echo "<td>".$description1."</td>\n"; echo "</tr>\n</table>\n"; } The code in RED is the new code/function I created to GET just the parent/main category 'title' rather than the entire link which would be: Main Cat/Sub-Cat ( # of ads ) This is the 'original function' code: function getparent($parentid,$title) { global $locale, $db_prefix, $userdata; $result = dbquery("SELECT cid, title, parentid from ".DB_CLASSIFIED_CATEGORIES." WHERE cid=$parentid"); list($cid, $ptitle, $pparentid) = mysql_fetch_row($result); mysql_free_result($result); if ($ptitle!="") $title=$ptitle."/".$title; if ($pparentid!=0) { $title=getparent($pparentid,$title); } return $title; } And this is my 'new function' code: function getparentMain($parentid,$title) { global $locale, $db_prefix, $userdata; $result = dbquery("SELECT cid, title, parentid from ".DB_CLASSIFIED_CATEGORIES." WHERE cid=$parentid"); list($cid, $ptitle, $pparentid) = mysql_fetch_row($result); mysql_free_result($result); if ($ptitle!="") $title=$ptitle; if ($pparentid!=0) { $title=getparentMain($title); } return $title; } This new function gives me what I want; just the main-cat 'title' but since the function has to appear inside the 'while loop' it gets that main-cat title every time thru the loop for every sub-cat title. This is what I need to display: MAIN CAT1 TITLE Sub-Cat1 Title( 0 ads ) Sub-Cat2 Title( 5 ads ) Sub-Cat3 Title( 1 ad ) etc.etc.etc..... MAIN CAT2 TITLE Sub-Cat1 Title( 0 ads ) Sub-Cat2 Title( 5 ads ) Sub-Cat3 Title( 1 ad ) etc.etc.etc..... I also need to display the sub-cats in 2 colums instead of only one. I hope this makes sense and that someone can point me in the right direction to go from here. I am fairly new at PHP and am trying to really get into and understand the inner workings of functions and how to handle their output. Thanks...
  21. Yep! That was the problem... in a previous query I had 'if(dbarray($result))' rather than 'if(dbarray($result)>0)' ... Thanks.
  22. Hello again gurus: I am getting a syntax error on this MySQL statement and can't figure out why. $result = dbquery("SELECT cid, title, description, image, parentid FROM ".DB_XXXXXXXXX." WHERE status='1' AND parentid='0' ORDER BY title LIMIT $rows"); while(list($cid, $title, $description, $image, $parentid) = dbarraynum($result)) { This is a new, empty database with table/field names only. After data is populated I do not get the syntax error. I am running MySQL 5 and PHP-5. Status is an 'enum' field that defaults to '0'. Can anyone see a syntax error here?
  23. You know, I don't know if it's the way I put things, the way I ask questions or if people just don't really like to try to deal with mail scripting problems or what. I've noticed that (most people) that pose questions/problems on here get some kind of response within a few hours at the most. So just go ahead and forget about this one. I'll mark it as solved and try to figure it out myself.
  24. System: PHP-Fusion ver7 CMS Hello again. I have a newsletter infusion(mod) that works great as is. But I need to modify it so that each recipient is personalized and they don't see all the other users email addresses in the TO: line of the email. No matter how I configure this puppy it still sends emails with all the addresses showing in the To field. My last attempt shown in the code below, was to put the entire 'db query/mail send' routines in a foreach loop. It doesn't work to personalize each email. This is interfacing to the php_mailer mail send function. Any insight would be very much appreciated. The $_POST['sendto'] is an array of email addresses gathered from my multi-select function. // New mail send routine for single/multiple user(s) require_once INFUSIONS."newsletters/newsletters_include.php"; $error = ""; $subject = stripslash($_POST['subject']); $my_array = ($_POST['sendto']); if ($_POST['format'] == "plain") { $content = stripslash($_POST['content']); } else if ($_POST['format'] == "html") { include INFUSIONS."newsletters/include/html_header_include.php"; $content .= stripslashes($_POST['content'])."\n"; $content .= "</body>\n</html>\n"; } _load_PHPMailer(); $mail = new MyMailer; $mail->Subject = $subject; if ($_POST['format'] == 'plain') { $mail->Body = $content; } else { $mail->AltBody = $locale['nl423']; $mail->Body = $content; } foreach ($my_array AS $emails) { $result = dbquery("SELECT * FROM ".DB_USERS." WHERE user_email='$emails'"); if (dbrows($result)) { $rows = dbrows($result); $bcc_list = ""; while ($data = dbarray($result)) { if ($_POST['delivery'] == "bcc") { $mail->AddBcc($data['user_email']); } else { $mail->AddAddress($data['user_email'], $data['user_name']); if (!$mail->Send()) { $error = $locale['nl417']; } if ($rows > 1) { $mail->ClearAddresses(); } } } } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.