Jump to content

benji87

Members
  • Posts

    136
  • Joined

  • Last visited

    Never

Everything posted by benji87

  1. Thanks mate thats great! Ive got two error's. On displayimage.php it doesnt show an image just a broken image. Also in showall.php it says unexpected t_string on line 12 but ive tried putting bits here and there but it still comes up with the same error!  :-[ sorry to be a pain!
  2. Hi all ive got this code to display uploaded images from a database but at the moment it will only display one image. Here is my code: [code] $gotten = @mysql_query("SELECT * FROM pix ORDER BY pid DESC"); if ($row = @mysql_fetch_assoc($gotten)) {         $title = htmlspecialchars($row[title]);         $bytes = $row[imgdata]; } else {         $errmsg = "MySql Error!"; } if ($_REQUEST[gim] == 1) {         header("Content-type: image/jpeg");         print $bytes;         exit ();         } ?> <img src=?gim=1 width=80>[/code] Now i know its controlled by the 'gim' variable but im not sure on how to modify this to made it display all the images contained in the database. Any help would be great! Thanks
  3. Hi all im currently working on a fixtures form for rugby games. What im trying to do is when the user selects the team from the drop down list it will show the selected teams badge above. I am really a novice when it comes to javascript but as far as im aware javascript is the most practical way to do what i want. I know you can do a basic onchange script in dreamweaver behaviors but it will only change to one image on any selection. If someone could point me in the driection of a tutorial or script that does exactly that it would be great thanks!
  4. Thank you my good friend that worked a treat and i learnt something new cheers!
  5. Hi all im trying to display some records from my database using $_GET id as the unique variable. Trouble is it seems to display the id on all of my variables. It will only work if i choose to select a certain field from the database. Here is the problem code: [code] <? include 'includes/db.php'; $query=("SELECT * FROM ssrfc_noticeboard  WHERE id = '{$_GET['id']}'"); $result=mysql_query($query); $date_posted=mysql_result($result,"date_posted"); $title=mysql_result($result,"title"); $message=mysql_result($result,"message"); [/code] Could someone please correct me where im going wrong because this one is above me! Thanks
  6. Thanks! Its always the obvious things! It worked fine trouble is now it wont display any data!  >:(
  7. Thanks for the help. I did not post code coz its basicly what barand sent me the link to: [code]<table cellspacing="3" cellpadding="3"> <?php include ("db.php"); $query = "SELECT img_thumb FROM deck_imgs ORDER BY img_name"; $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if($result && mysql_num_rows($result) > 0) {     $i = 0;     $max_columns = 3;     while($row = mssql_fetch_array($result))           {        // make the variables easy to deal with        extract($row);        // open row if counter is zero        if($i == 0)           echo "<tr>";        // make sure we have a valid product        if($img_thumb != "" && $img_thumb != null)           echo "<td>$img_name</td>";            // increment counter - if counter = max columns, reset counter and close row        if(++$i == $max_columns)        {            echo "</tr>";            $i=0;        }  // end if    } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) {     for($j=$i; $j<$max_columns;$j++)         echo "<td>&nbsp;</td>"; } ?> </tr> </table>[/code]
  8. Easy for who? Its only easy if you already know it. Why bother posting if your not willing to help. Dont reply as i dont want to flame
  9. Thanks for the link that was really useful but its telling the that the msql_fetch_array() is an undefined function??
  10. Hi all. Im looking for a bit of script that will display some sql results over three columns instead of down rows. For image thumbnails. I know someone has already put up a topic about this i tried to use the script but it was all too much for what im wanting i just want a bare bones script. Any help would be great!
  11. Hi all. Im currently working on a CMS for a small school website so they can post their own newsletters. They also want to have the ability to upload images with the newsletter if they wish. Uploading the image to a directory on the webspace is fine i have that sorted but i also need a link to be inserted into the database where the newsletters are stored so the image will be displayed with it when retrieved. What ive decided to do is let the user to compose the newsletter first and insert it into the database they then have an option later on to add an image. I am trying to do this using the $_GET function using id as the unique variable. Thing is the code seems to exicute but it just wont go into the database i have tried for hours and just can seem to find the solution to the problem. Here is my code: actions.php [code] case 'addimg': $id = $_GET['id']; echo ("$id"); if(isset($_POST['Submit'])) { $size = 500; // the thumbnail height $filedir = '../images/uploaded/'; // the directory for the original image $thumbdir = '../images/uploaded/thumbnails/'; // the directory for the thumbnail image $prefix = 'small_'; // the prefix to be added to the original name $maxfile = '2000000'; $mode = '0666'; $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_size = $_FILES['image']['size']; $userfile_type = $_FILES['image']['type']; $sql = mysql_query("UPDATE copnornews SET image = '$userfile_name' WHERE id = '{$_GET['id']}'") or die (mysql_error()); if(!$sql){ echo 'There has been an error while trying to submit your post.'; } else { $id = mysql_insert_id(); } if (isset($_FILES['image']['name'])) { $prod_img = $filedir.$userfile_name; $prod_img_thumb = $thumbdir.$prefix.$userfile_name; move_uploaded_file($userfile_tmp, $prod_img); chmod ($prod_img, octdec($mode)); $sizes = getimagesize($prod_img); $aspect_ratio = $sizes[1]/$sizes[0]; if ($sizes[1] <= $size) { $new_width = $sizes[0]; $new_height = $sizes[1]; }else{ $new_height = $size; $new_width = abs($new_height/$aspect_ratio); } $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image'); if(function_exists('imagecopyresampled')) { imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing'); }else{ Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing'); } ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving'); imagedestroy($destimg); } echo ' <a href="'.$prod_img.'"> <img src="'.$prod_img_thumb.'" width="'.$new_width.'" heigt="'.$new_height.'"> </a>'; }else{ echo $id = $_GET['id']; echo ("$id"); echo '<a href=actions.php?id=$id>ADD IMAGE</a>'; echo ' <form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data"> <input type="file" name="image"><p> <input type="Submit" name="Submit" value="Submit"> </form>'; }[/code] Now i know the get variable is working so i cant see why it is not working, any help or suggestions on a better way to do it would be great! Thanks
  12. i dont really know what you're getting at but i think your need to use sessions. Why dont you post the coding you've got so far then it might be a little clearer
  13. Then you dont use sql for that you use javascript like so: [code] <script language="Javascript"> function autofillin(frm) {      if("North" == frm.region.value)      {           frm.type.value = "123";           frm.type.value = "456";      }      if("South" == frm.region.value)      {           frm.type.value = "abc";           frm.type.value = "def";      }      } </script> <body> <form name="frm" method="post" action=""> <td>Region</td> <td><select onchange="autofillin(this.form)" name="region"> <option value="North">North</option> <option value="South">South</option> </select> <td>Type</td> <td><select name="type" id="type"> </select> </form> [/code]
  14. So your wanting to autofil a field with values from a database based on what the user selects in the previous box? i.e North or South??
  15. The $_post function willonly work if you place it in the file that is you're form action. Here is a basic example: form.php [code] <form name="form1" method="post" action="showname.php"> <input name="firstname" type="text" id="firstname"> <input name="lastname" type="text" id="lastname"> <input name="rc" type="hidden" id="rc" value="<? echo '$rcid' ?>"> <input type="submit" name="Submit" value="Submit"> </form> [/code] showname.php [code] <?php $firstname = $_post['firstname']; $lastname = $_post['lastname']; $rcid = $_post['rc']; echo '$firstname, $lastname'; echo ' the hidden value in the form is $rcid'; ?>[/code] That is the basic way but it all depends where your getting the $rcid from. Are u getting it from a database?
  16. I dont know as im not expert in sessions varibles. But the only was i could see it working is if the domains route was in the same place??
  17. As far as im aware it is impossible to carry sessions over to another domain. That could cause all kind of problems for people if you think about it.
  18. I dont really understand what you're trying to say. But if it works fine with date then why change it to varchar?
  19. Well that depends on how you are using the hidden field. Are you using the hidden field in a form to post? If so its quite simple [code] <? $hiddenvalue = $_POST['rc']; echo '$hiddenvalue'; ?> [/code] Also take the '=' out of your php hidden value
  20. It doesnt delete the record from the database it just refreshes the page to display.php same with the approve it doesnt update the field to 1. Thanks.
  21. Ok ive got the update working finally! Now its just the delete function that wont work!
  22. Right this is my complete code although it still does not work although i dont get any syntax errors! [code] <?php session_start(); include ('db.php');   if (isset($_GET['action'])) {     switch ($_GET['action']) {       case 'edit':      $query=("SELECT message FROM postapproval WHERE id = '{$_GET['id']}'"); $message=mysql_query($query); mysql_close(); break;     case 'delete': $query=("DELETE FROM postapproval WHERE id = '{$_GET['id']}'"); mysql_close(); header("Location: display.php"); break;     case 'approve': $query=("UPDATE postapproval SET postlevel = 1 WHERE id = '{$_GET['id']}'"); mysql_close(); header("location: index.php"); }; }; ?> <body> <form action="update.php" method="post" name="editarticle" id="editarticle"> <p>   <textarea name="edited" id="edited"><?php echo ("$message") ?></textarea> </p> <p>   <input name="Update" type="submit" id="Update" value="Update"> </p> </form> </body> </html> [/code] As i said when i click update to carryon over to this code it fills the text box with text saying 'Resource id #3' i dont have a clue what that is all about. Ive also tried delete and that does absolutly nothing! Please help me i really need to get this sorted! 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.