Jump to content

Richzilla

Members
  • Posts

    61
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Richzilla's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks chaps. Worked perfectly. You work fast!!
  2. Hi All, i'm kinda new to javascript and have avoided it for my much prefered php. I'm trying to write a very simple script to rotate our shopping surveys. i want Shopzilla and pricegrabber to appear on different days. I'm getting errors on the following code - <script type="text/javascript"> <!-- var d=new Date(); theDay=d.getDay(); shopzilla="<script language="JavaScript" src="https://evaleu.shopzilla.com/js/pos_xxxxx.js" type="text/javascript"></script>"; pricegrabber="<script type="text/javascript" src="https://www.pricegrabber.com/rating_merchrevpopjs.php?retid=xxxx"></script> <noscript><a href="https://www.pricegrabber.com/rating_merchrev.php?retid=xxxx" target=_blank><img src="https://images.pricegrabber.com/images/mr_noprize.jpg" border="0" width="272" height="238" alt="Merchant Evaluation"></a></noscript>"; switch (theDay) { case 1: document.write(shopzilla) break case 2: document.write(pricegrabber) break case 3: document.write(shopzilla) break case 4: document.write(pricegrabber) break case 5: document.write(shopzilla) break case 6: document.write(pricegrabber) break case 0: document.write(shopzilla) break } //--> </script>
  3. I do have GSD installed after all!! SO the questions is what's the best way to resize my images? ANy good sites with tutorials?
  4. http://www.jungletekno.co.uk/phpinfo.php
  5. I have MySql version 5.0 How do i find out if GD has been installed?
  6. Hey all, I'm uisng PHP to upload image files to my site through a form. The filename is added to my database so i can refference the image. I now need to be able to keep this file and also resize it to a uniform size. I have been looking around for hours trying to find a script that works, but no luck yet. I don't have access to my server so I can't install GD. I can see that there are other tools in PHP that allows me to do what I want to do. Anyone got any good scripts that I can use please?
  7. Bump. All i need to do is work out a way of resizing images that are on my server and then reuploading them. Anyone know how to do this?
  8. Yes it does seem pointless as many residential internet users don't have fixed IP addreses
  9. Hi All, Back again. This time I'm really stuck. So, I'm currently uploading an image from a forms page along with the information to my server and also adding the filename etc to my sql database. I'm checking that the files are only jpg and gif files and that they are less than 3MB in size. I'd like to now resize this image and upload alsoto the same location as the large image but with the extension _small. e.g - largeimage_small.gif So essentially I'd like to add the large image to the server and also the small resized image (max 150 pixel width). I can find a way of resizing the image by opening it as is below. So far the script for upload the image is working really well. Now I need to have the smaller image version added also. Any help would be greatly apprecaited. You're all such wizards and I'm still a mear novice. Here's the code - [code <? $event = $_POST['event']; $date = @$_POST['date']; $flyer = @$_POST['uploaded']; $user="xxxx"; $pass="xxxx"; $host = "xxxx"; $dbase="xxxx"; $table = "events"; mysql_connect($host,$user,$pass); mysql_select_db($dbase) or die("Unable to select database"); $query = "SELECT * FROM events WHERE event ='$event'"; if ($result = mysql_query($query) or die(mysql_error()) > 0) { if (mysql_num_rows($result)) { echo "Error : This event is already in the database"; } else { $filename = basename($_FILES['uploaded']['name']); if((!empty($_FILES["uploaded"])) && ($_FILES['uploaded']['error'] == 0)) { $tag = "events"; $ext = substr($filename, strrpos($filename, '.') + 1); $goback = "<a href=\"http://www.mysite.co.uk/add_event.php\">back</a>"; if (($ext == "jpg") || ($ext == "gif") && ($_FILES["uploaded"]["size"] < 3000000)) { $newname = dirname(events).'/upload/'.$filename; if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded']['tmp_name'],$newname))) { echo "You have successfully entered the following information into the database - <br> <br> Event : $event <br>Date : $date <br>Flyer : "; $query = "INSERT INTO events VALUES ('','$event','$date','','$tag$newname')"; $result = mysql_query($query) or die(mysql_error()); // How do I now open the image to resize it??? $image = open_image('$tag$newname'); $width = imagesx($image); $height = imagesy($image); $new_width = 150; $new_height = $height * ($new_width/$width); $image_resized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); //How do I now move the file to my server and also add the filename to my database?? mysql_close(); } else { echo "Error: A problem occurred during file upload! Please go $goback and try again"; } } else { echo "Error: File ".$_FILES["uploaded"]["name"]." already exists. Please rename and go $goback and try again"; } } else { echo "Error: Only jpg and gif files under 3MB are accepted for upload. <br> Go $goback and try again"; } } else { $query = "INSERT INTO events VALUES ('','$event','$date','','')"; $result = mysql_query($query) or die(mysql_error()); echo "You have successfully entered the following information into the database - <br> <br> Event : $event <br>Date : $date <br>"; mysql_close(); } }} ?> code]
  10. sorry my bad. i must have somehow cahnged the GET to POST and hence it wasn't pulling in the right ID number. What a plonker!!
  11. sorry, yes I've changed that. however, now nothing is gettig echoed in the result, nor is it giving me any errors. anything else you can see?
  12. Over night having changed nothing on my server and my php page I cannot add anything through scripts to my database. The script I was using to great success is below. For absolutely no apparent reason I can no longer update anything to the mySQL databse. Nothing has changed on the working page. I don't even get any error messages, such as cannot connect etc. Is there anything in the setup or admin of mySQL that can be causing this? Essentially, the script below is updating data on the database from a form on the previous page. I'm then echoing out the new result which is correct. However, when going back to the previous page the old data is still there and the database remains unchanged!! What is going wrong??? [code<? $id = $_POST['id']; $event = $_POST['event']; $date = $_POST['date']; $user="xxxx"; $pass="xxxx"; $host = "xxxx"; $dbase="xxxx"; mysql_connect($host,$user,$pass); @mysql_select_db($dbase) or die("Unable to select database"); $query = "UPDATE events SET event='$event' , date='$date' WHERE id='$id'"; $result = mysql_query($query) or die(mysql_error()); $query = "SELECT * FROM events WHERE id='$id'"; $result=mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $event = $row['event']; $date = $row['date']; } mysql_close(); ?> <? $page = $_GET['id']; $link = "<a href=http://www.mysite.co.uk/update_event.php?id="; $goback = ">go back</a>"; ?> <br> <table width="900" border="0" align="center"> <tr><td> <span class="trk_list_headers">You have updated the following information on the database : <br /></span>: </td> <table width="900" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="30%" align="left"><span class="time_main_text">Event : </span></td> <td width="70%" align="left"><span class="style1"><? echo $event ?></span> <br></td> </tr> <tr> <td width="30%" align="left"><span class="time_main_text">Date : </span></td> <td width="70%" align="left"><span class="style1"><? echo $date ?> </span><br><br /></td> </tr> <tr> </td> <table width="900" align="center"><span class="time_main_text">If this information was incorrect please <? echo "$link$page$goback" ?> and correct the error. </span></td> </table>
  13. Here's a script that took me about a week to write. It's a method of uploading images through php into my webserver and adding the file names and locations to the sql database - <? $event = $_POST['event']; $date = @$_POST['date']; $flyer = @$_POST['uploaded']; $user="xxxx"; $pass="xxxx"; $host = "xxxx"; $dbase="xxxx"; $table = "events"; mysql_connect($host,$user,$pass); @mysql_select_db($dbase) or die("Unable to select database"); $query = "SELECT * FROM $table WHERE event ='$event'"; if ($result = mysql_query($query) or die(mysql_error()) > 0) { if (mysql_num_rows($result)) { echo "Error : This event is already in the database"; } else { $filename = basename($_FILES['uploaded']['name']); if((!empty($_FILES["uploaded"])) && ($_FILES['uploaded']['error'] == 0)) { $tag = "events"; $ext = substr($filename, strrpos($filename, '.') + 1); $goback = "<a href=\"http://www.mysite.com/add_event.php\">back</a>"; if (($ext == "jpg") || ($ext == "gif") && ($_FILES["uploaded"]["size"] < 3000000)) { $newname = dirname(events).'/upload/'.$filename; if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded']['tmp_name'],$newname))) { echo "You have successfully entered the following information into the database - <br> <br> Event : $event <br>Date : $date <br>Flyer : "; $query = "INSERT INTO events VALUES ('','$event','$date','','$tag$newname')"; $result = mysql_query($query) or die(mysql_error()); mysql_close(); } else { echo "Error: A problem occurred during file upload! Please go $goback and try again"; } } else { echo "Error: File ".$_FILES["uploaded"]["name"]." already exists. Please rename and go $goback and try again"; } } else { echo "Error: Only jpg and gif files under 3MB are accepted for upload. <br> Go $goback and try again"; } } else { echo "You have successfully entered the following information into the database - <br> <br> Event : $event <br>Date : $date"; } }} ?> form page before - <form enctype="multipart/form-data" action="/events/event_ul.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="3000000" /> <tr> <td width="30%" align="left"><span class="time_main_text">Rave : </span></td> <td width="70%" align="left"><span class="style1"><input type="text" name="event" /><br> </tr> <tr> <td width="30%" align="left"><span class="time_main_text">Date : </span></td> <td width="70%" align="left"><span class="style1"><input type="text" name="date" /><br> </tr> <tr> <td width="30%" align="left"><span class="time_main_text">Flyer Image : </span></td> <td width="70%" align="left"><span class="style1"><input name="uploaded" type="file" /><br /></span></td> </tr> <br /> <tr> <td width ="30%" valign="top" align="center"><input name="UPDATE" type="submit" class="trk_list_main" id="UPDATE" value="Submit"/><input name="Clear" type="reset" class="trk_list_main" id="Clear" value="Reset"/></td> </form> Please don't ask me to descibe all this. I hope it's quite self explanatory. I have no idea about AJAX so I'll leave that one alone.
  14. thanks for the quick responses, sadly the first response has a syntax error where there's a missing } closing the first statement. The second code causes this error - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
×
×
  • 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.