Jump to content

jonw118

Members
  • Posts

    77
  • Joined

  • Last visited

    Never

Everything posted by jonw118

  1. I'm hoping someone would be kind enough to help me here. First I want to know if I can accomplish this. If so, I am by no means asking you to write my code, but if you could steer me the direction, or give me some pointers I'd really appreciate! Basically I have a script the shows multiple results on the page pulled from the database. The code for the link: <a href="full_desc.php?id=<? echo $row['id'];?>"><? echo $row['subject'];?></a> Then, for each link displayed it has a photo that displays: <? if(!empty($row['thumb'])){?> <img src="admin/<? echo $row['thumb']?>" width="120" height="60" border="1"> <? }?> Now what I want to do is have one main image, so that when you rollover a link that is populated it changes the photo (associated with that link) in the one main image. I'd really, really appreciate any help at all! Thanks.
  2. Have a very simple question, and my attempts haven't worked... what do I need to add to this code to make it not display an image if there isn't one uploaded? Right now it shows a broken image. <? $sql="select image from inputinfo where id='$id'"; $rez=mysql_query($sql,$dblnk); $row=mysql_fetch_array($rez); echo "<img src='admin/{$row['image']}' />"; ?> Thanks for any help!
  3. Awesome! Thank you so much, I really appreciate it... going to try that out in a second.
  4. I'd appreciate any help someone could lend! Basically I have a script that shows 1 image. Under it is a remove button. Here is the remove code for it on the page: <? if(!empty($row2['image'])) { ?> <img src="<? echo $row2['thumb'];?>"> <a href="remove_image.php?id=<? echo $row2['id'];?>">Remove Image</a> <? } else { ?> <input type="file" name="photo1"> <? }?> So, when you remove an image it calls remove_image.php: <? include ("define.php"); $sql="update inputinfo set image='',thumb='' where id='$id'"; $rez=mysql_query($sql,$dblnk); header('location: edit.php?id='.$id); ?> Simple enough. But, here's my problem. I added two more pics into the database. For the new images that are uploaded to the database I am using the following (which displays fine): <? if(!empty($row2['image2'])) { ?> <img src="<? echo $row2['thumb2'];?>"> <a href="remove_image.php?id=<? echo $row2['id'];?>">Remove Image</a> <? } else { ?> <input type="file" name="photo2"> <? }?> and <? if(!empty($row2['image3])) { ?> <img src="<? echo $row2['thumb3'];?>"> <a href="remove_image.php?id=<? echo $row2['id'];?>">Remove Image</a> <? } else { ?> <input type="file" name="photo3"> <? }?> But #2 & #3 will not delete correctly. Sometimes they do, sometimes they don't. Depends if previous images and such are deleted. That remove_image.php was updated to (and I know my problem is in here). Seems like it stalls out on this script for some reason: <? include ("define.php"); $sql="update inputinfo set image='',thumb='' where id='$id'"; $sql="update inputinfo set image2='',thumb2='' where id='$id'"; $sql="update inputinfo set image3='',thumb3='' where id='$id'"; $rez=mysql_query($sql,$dblnk); header('location: edit.php?id='.$id); ?> Is there something I am missing that should inserted in between each line of $sql? Again, I'd really appreciate some advise!
  5. Hi there, currently my script has: <? $sql="select thumb from inputinfo where id='$id'"; $rez=mysql_query($sql,$dblnk); $row=mysql_fetch_array($rez); echo $row['thumb']; ?> But that just prints out the URL to the image. I want it to display the image. Here's what I tried, but no-go. I'd appreciate any help... <? $sql="select thumb from inputinfo where id='$id'"; $rez=mysql_query($sql,$dblnk); $row=mysql_fetch_array($rez); echo $row[admin/<? echo $row[thumb];?>]; ?>
  6. So I have a script that uploads 1 image. I changed the script to upload 2 images. When I try to upload 2 of them, I get: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 525 bytes) SO... I did the typical solution and contacted my host and they changed the memory limit to 16M and issued this comman /etc/init.d/httpd restart. Now, I can upload two images that are very small. But anything of a little size (ex, I tried to upload two 1mb images) and it erred. Is there anything crazy in my code that could be doing this. I'd appreciate any help: The input page: <? include ("define.php"); include ("func.php"); $subject=addslashes($subject); $date=date("Y-m-d H:i:s"); $ph=date("his").$_FILES['photo1']['name']; $fileName=$_FILES['photo1']['name']; $ext = substr($fileName, strrpos($fileName, '.') + 1); if(($ext!="php") and ($ext!="html") and ($ext!="htm")) @move_uploaded_file($_FILES['photo1']['tmp_name'], "./photos/".$ph); if(!empty($_FILES['photo1']['name'])) { $image="./photos/".$ph ; $newfilename="./photos/".$ph; $thumbname="./photos/thumb_".$ph; switch($_FILES["photo1"]['type']) { case 'image/jpeg': case 'image/pjpeg': createthumbnailjpg($newfilename,$thumbname,175,0); break; case 'image/png': case 'image/x-png': createthumbnailpng($newfilename,$thumbname, 175,0); break; case 'image/gif': createthumbnailgif($newfilename,$thumbname, 175,0); break; } } $ph2=date("his").$_FILES['photo2']['name']; $fileName2=$_FILES['photo2']['name']; $ext = substr($fileName, strrpos($fileName2, '.') + 1); if(($ext!="php") and ($ext!="html") and ($ext!="htm")) @move_uploaded_file($_FILES['photo2']['tmp_name'], "./photos/".$ph2); if(!empty($_FILES['photo2']['name'])) { $image2="./photos/".$ph2 ; $newfilename2="./photos/".$ph2; $thumbname2="./photos/thumb_".$ph2; switch($_FILES["photo2"]['type']) { case 'image/jpeg': case 'image/pjpeg': createthumbnailjpg($newfilename2,$thumbname2,175,0); break; case 'image/png': case 'image/x-png': createthumbnailpng($newfilename2,$thumbname2, 175,0); break; case 'image/gif': createthumbnailgif($newfilename2,$thumbname2, 175,0); break; } } $ph=date("his").$_FILES['doc1']['name']; $fileName=$_FILES['doc1']['name']; $ext = substr($fileName, strrpos($fileName, '.') + 1); if(($ext!="php") ) @move_uploaded_file($_FILES['doc1']['tmp_name'], "./docs/".$ph); if(!empty($_FILES['doc1']['name'])) $doc="./docs/".$ph ; $sql="select id from inputinfo"; $rez=mysql_query($sql,$dblnk); $nr=mysql_num_rows($rez); $nr++; $sql="insert into inputinfo(subject,`description`,document,image,image2,date_submitted,thumb,thumb2,category,rank) values('$subject','$area2','$doc','$image','$image','$date','$thumbname','$thumbname2','$category','$nr')"; $rez=mysql_query($sql,$dblnk); header('location: output.php'); ?> The function code: <? function resizeCreatedImage(&$src_img,$outWidth,$outHeight) { $srcWidth=imagesx($src_img); $srcHeight=imagesy($src_img); // if(!$outHeight || $outHeight=='') $outHeight=$outWidth; $outHeight=($outWidth*$srcHeight)/$srcWidth; $imgOut=imagecreatetruecolor($outWidth,$outHeight); $xoffset = 0; $yoffset = 0; if ($srcWidth*$outHeight > $srcHeight*$outWidth) { $xtmp = $srcWidth; $xratio = 1-((($srcWidth/$srcHeight)-($outWidth/$outHeight))/2); $srcWidth = $srcWidth * $xratio; $xoffset = ($xtmp - $srcWidth)/2; } elseif ($srcHeight/ $outHeight > $srcWidth / $outWidth) { $ytmp = $srcHeight; $yratio = 1-((($outWidth/$outHeight)-($srcWidth/$srcHeight))/2); $srcHeight = $srcHeight * $yratio; $yoffset = ($ytmp - $srcHeight)/2; } imagecopyresampled($imgOut, $src_img, 0, 0, $xoffset, $yoffset, $outWidth, $outHeight, $srcWidth, $srcHeight); return $imgOut; } function createthumbnailjpg($image_path,$thumb_path,$thumb_width,$thumb_height=0) { $src_img = imagecreatefromjpeg($image_path); $dst_img = resizeCreatedImage($src_img,$thumb_width,$thumb_height); imagejpeg($dst_img, $thumb_path); return true; } function createthumbnailpng($image_path,$thumb_path,$thumb_width,$thumb_height=0) { $src_img = imagecreatefrompng($image_path); $dst_img = resizeCreatedImage($src_img,$thumb_width,$thumb_height); imagepng($dst_img, $thumb_path); return true; } function createthumbnailgif($image_path,$thumb_path,$thumb_width,$thumb_height=0) { $src_img = imagecreatefromgif($image_path); $dst_img = resizeCreatedImage($src_img,$thumb_width,$thumb_height); imagepng($dst_img, $thumb_path); return true; } ?>
  7. Crayon... thank you, it makes sense. But unfortunately, it isn't working. Here's the URL I'm using: xxxxx.com/page.php?cat=1&loc=1 No matter what number I put in the "&loc=" it doesn't make a difference.
  8. That was the original code... I altered it to this, but didn't work: <? if(!empty($cat)) $sql="select * from `inputinfo` where category='$cat' order by rank asc"; $sql="select * from `inputinfo` where location='$loc' order by rank asc"; else $sql="select * from `inputinfo` order by rank asc"; $rez=mysql_query($sql,$dblnk); while($row=mysql_fetch_array($rez)){ $id=$row['id']; ?>
  9. Hey there- Quick (I'm sure very easy question)... I have a script where it pulls where in the URL if you say xxxxxxx.com/page.php?cat=3 and it pulls records only with a category id of "3". I want to add one more variable to the string. Basically I want the url to pull only items from category 3 that have a location of "1". So, essentially I want: http://xxxxxx.com/page.php?cat=3&location=1 Everything I'm trying to make this happen with this code below is not working. Any advice would be very appreciated: <? if(!empty($cat)) $sql="select * from `inputinfo` where category='$cat' order by rank asc"; else $sql="select * from `inputinfo` order by rank asc"; $rez=mysql_query($sql,$dblnk); while($row=mysql_fetch_array($rez)){ $id=$row['id']; ?>
  10. Do you (or anyone) know of a resource I could check to learn how to include a hidden field like "redirect" and URL as a value... then in the processing code what I need to put in there to code the redirect? Thanks again for the assistance, much appreciated!
  11. Awesome! Thanks for the help. I am trying to read up on this now how to do it. One other thought, I'm trying to find a tutorial on inserting a "redirect" into the form, where it could just redirect them back to the page I specify.
  12. No... there are a lot of different pages that have forms on them that all use this same (single) php script to process. After that script processes them I want them to go back where they came from.
  13. Hello! I made post yesterday about wanting a php file with the header(Location... to go back 2 pages. But doesn't sound like that can happen. SO- my new resolution is this. When someone fills out a form and it calls the PHP file to redirect them to a page, I created a "Thank You Page" of sorts. On that page I am placing a link "Go Back". Basically I want them to go back to a certain page (2 pages back). BUT, when they go back, I need that page to auto refresh to show the content they provided updated. Right now I'm using window.history. It's taking them back, but it is not refreshing the page to show what they just posted. I've tried all sort of js methods, to no avail. I'm curious if this can be accomplished in php? THANKS so much for any advise.
  14. Unfortunately Scott, that didn't do it... here's what I used: header('Location: <a href="javascript:window.history.go(-2)">GO back</a>');
  15. This would do the trick for me if I only wanted to go back one page, but I need to go back 2. header("Location: " . $_SERVER['HTTP_REFERER']); Is it possible to make that go back 2?
  16. Studgate... the problem is the page I need it to send back to varies. Basically there are multiple pages that all access one php file. Once they perform the action I want them sent back 2 pages... and that will vary based on where they came from. Ratcateme... it's not that I'm opposed to JS, I just can't make it work. When I put that in, it just stalls on the php file it calls (but does perform that action). Here's my code, it's late, am I missing something: edit, I meant to post this is what I have: header('Location: <script language="JavaScript">window.history.go(-2)</script>');
  17. Ok, I have a script that if you perform an action, it calls a php file to perform the action... then that php file that is called sends the user to the page specified in the file with the: header('Location: X.php'); What I really need it to do is send it back 2 pages... is this possible? I tried using javascript to get it to go back... but that didn't do the trick, just stalled out. Any ideas would be greatly appreciated!
  18. When I do that or die to get the exact error I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Line 1 is: <?php ----------------------------------------- The full query is: function allowed_user_category($mID){ $rs=mysql_query("select mem_ID,cat_ID FROM tbl_member WHERE mem_ID=$mID"); $row=mysql_fetch_array($rs) or die(mysql_error()); return $row["cat_ID"]; }
  19. I am getting an error: "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/***/public_html/projects/***/admin/inc/admin_info_class.php on line 180" ...that line's code is: $row=mysql_fetch_array($rs); It works fine on one of my other servers. Any thoughts would be greatly appreciated!
  20. NEVERMIND - I'm an idiot... That worked! Again, thank you for taking the time to help me.
  21. Thanks so much for trying to help me... I really appreciate it! Unfortunately it gives this error: Parse error: syntax error, unexpected T_STRING in /home/mercant/public_html/legendsrecognition/includes/modules/new_products.php on line 34 (Line 34, btw, is that line I changed). Any thoughts?
  22. I think this should be pretty easy... I have a line in my code that currently reads: "where p.products_id = p2c.products_id and products_status = '1' and p2c.categories_id = 50 " . That 50 is a category number. What I need is for it to pull multiple categories from the database (ie: 48, 49, 50, etc). I tried using commas, and that didn't cut it. How can I join serveral different categories? THANKS SO MUCH FOR ANY HELP!!
  23. Oh wow, so right now the cell reads: W90” x D39” x H31” In the CSV file what would I change that to read??? Is this what you are saying? W90string = preg_replace('/[\x91\x92]/u', "'", $string); $string = preg_replace('/[\x93\x94]/u', '"', $string); x D39string = preg_replace('/[\x91\x92]/u', "'", $string); $string = preg_replace('/[\x93\x94]/u', '"', $string); x H31string = preg_replace('/[\x91\x92]/u', "'", $string); $string = preg_replace('/[\x93\x94]/u', '"', $string);
  24. Hello all- I thank you greatly in advance for any help... I have a CSV file I am importing into my MySQL database and have a problem: One of the cells I am importing uses quotations marks in the description (they need to be there!), but unfortunately, when I import it changes the quatations mark to a ? mark sign. I changed "Fields terminated by" to a "+" and changed "fields enclosed by" to a ","... but this did nothing for me. Again, I'd appreciate any help. Thanks!
×
×
  • 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.