Jump to content

rhs49010

Members
  • Posts

    21
  • Joined

  • Last visited

rhs49010's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Maybe I should clarify, inside the banner directory the file name is 0 without the extension and I need the FILE array for validation after I fix this issue. and if I manually change the name to the corresponding image name it works, so that tells me the file is in the directory after the move function puts it there but the name some how gets lost in the shuffle. Thanks
  2. image extension png, gif, jpg. It doesn't matter which I use I get the same name 0 the file is in the banner directory but the name isn't
  3. I'm testing this form before adding validation and I can't figure out why the file name comes through as 0 in the banner directory. And it says text/x-generic instead of image/x-generic in the type column, if I highlight the file and click view the image shows. everything in the database is correct and the form is set to enctype=multipart/form-data. Need a set of fresh eyes to look at it, Thanks! <?php $form_complete = FALSE; $imageDirectory = "banners/"; $records = array(); if (isset($_POST['url'], $_FILES ['images'] ['name'], $_POST['expires'])) { $images = $_FILES ['images'] ['name']; $type = $_FILES ['images'] ['type']; $size = $_FILES ['images'] ['size']; $temp = $_FILES ['images'] ['temp_name']; $error = $_FILES ['images'] ['error']; $url = 'url'; $url = preg_match("/\b(??:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $url); $expires = date('M d Y', strtotime('+ $expires days')); $expires = 'expires'; move_uploaded_file($temp,$imageDirectory .$images); //the path to the image file $imagePath = $imageDirectory.$images; $expires = $_POST ['expires']; $url = $_POST['url']; $images = 'banners/'.$_FILES['images']['name']; echo "<p><br /><a href='$url'><img src='$imagePath'/></a><br /> Expires: $expires </p>"; $insert = $db_conn->prepare("INSERT INTO adverts (images,url,expires) VALUES (?,?,?)"); $insert->bind_param('sss', $images, $url, $expires); $insert->execute(); } $form_complete = TRUE; ?>
  4. The following is a simple ad rotation script it works fine until it gets to the 'if' statement. I need to check if the 'shown column data is set to 0. obviously I can find an answer anywhere on the web. <?php include 'test_db_conn.php'; $ads = mysqli_query($conn,"SELECT `advert_id`,`images` FROM `adverts` WHERE `shown` = 0 ORDER BY `advert_id` ASC LIMIT 1")or die("SQL Error line ".__LINE__ . mysqli_errno()); while ($row = mysqli_fetch_assoc($ads)) { $advert_id = $row ['advert_id']; $images = $row ['images']; echo '<a href="go.php?advert_id=' .$advert_id. '"target="_blank"><img src="'.$images.'" /></a>'; $result = mysqli_query ($conn,"UPDATE `adverts` SET `shown`=1, `impressions`=`impressions` +1 WHERE `advert_id`= $advert_id"); $shown = mysqli_query($conn,"SELECT COUNT(`advert_id`) FROM `adverts` WHERE 'shown' =0"); // This was originally written with a mysql_result function How can I get the same functionality the a mysqli procedural function. if (mysqli_? ($shown,0) == 0) { mysqli_query($conn,"UPDATE `adverts` SET `shown`=0"); } } ?> Thanks for your time!
  5. $the_file = 'uploads/108'; // dump this result to be sure that everything is fine echo '<img src='.$the_file. ' />'; exit; That displays the image in the browser
  6. Well This was a learning experience for me. it wasn't a total waste of time for me at least Jazzman1 and mac_gyver you guys are probably going to ignore me If I come back with my next headache. I'll give this a try for grins Jazzman1 $the_file = 'uploads/108'; // dump this result to be sure that everything is fine echo '<img src='.$the_file. ' />'; exit; I'll be back
  7. Oh by the way download the daffy.jpg That's about how I was feeling about the download file.
  8. Your not going to believe this but It WORKS!!!!!!! I deleted... if (!is_dir('/upload')) { echo "True"; } else { echo "False"; } and the var dump ($uid) and voile it now sends a download window! So what? was it the var dump? try it for yourself http://www.lrn.computerizedgraphics.com/view_files.php I'll be dammed Now I can finally move on to the next headache. Thank you Thank you Thank you
  9. does this need output buffering?
  10. Trueint(108) Warning: Cannot modify header information - headers already sent by (output started at /home1/ecosolu1/public_html/lrn/download_file.php:34) in /home1/ecosolu1/public_html/lrn/download_file.php on line 41 Plus a load of gibberish
  11. I added echo '<img src='.$the_file. '/>'; exit; no more error. now it's back to the black square with an X
  12. Okay check this out modified script with error message <?php # download_file.php // This page handles file downloads through headers. // Check for an upload_id. error_reporting(-1); if (!empty($_GET['uid'])) { $uid = intval($_GET['uid']); } else { // Big problem! $uid = 0; } if ($uid > 0) { // OK to proceed! require_once ('mysql_connect.php'); // Connect to the dataabase. $sql = "SELECT `upload_id`,`file_name`, `file_size`, `file_type` FROM `uploads` WHERE upload_id = $uid"; // the result of the query $result = mysql_query($sql) or die("Invalid query: " . mysql_error()); $row = mysql_fetch_assoc($result) or die(mysql_error()); $the_file = 'uploads'.'/'.$row[$uid]; // dump this result to be sure that everything is fine ini_set("display_errors", "1"); if (!is_dir('/uploads')) { echo "True"; } else { echo "False"; } if (file_exists ($the_file)) { var_dump($uid); //header ('content-type: application/octet-stream'); header('Content-Description: File Transfer'); header("Content-type: " . $row['file_type']); header('Content-Disposition: attachment; filename=' . basename($the_file)); header('Content-Length: ' . $row['file_size']); readfile($the_file); // mysql_close($link); //close connection }else { // File doesn't exist. $page_title = 'File Download'; include ('include/header.html'); echo '<p><font color="red">The file could not be located on the server. We apologize for any inconvenience.</font></p>'; include ('include/footer.html'); } } else { // No valid upload ID. $page_title = 'File Download'; include ('include/header.html'); echo '<p><font color="red">Please select a valid file to download. </font></p>'; include ('include/footer.html'); } ?> I moved the ini set now I'm getting this error message... Trueint(108) Warning: Cannot modify header information - headers already sent by (output started at /home1/ecosolu1/public_html/lrn/download_file.php:33) in /home1/ecosolu1/public_html/lrn/download_file.php on line 40 WHAT?
  13. Can you give an example that might work? maybe... $the_file = 'uploads'.'/'.$row[$uid]; I'll try this for grins
  14. I added the echo to the script and now the only thing on the page is a small black square with an X The var dump displays the ID assigned at upload and all the gibberish after that. EXAMPLE... True (the var dump int(108) ) ‰PNG IHDR Xšv‚psRGB®ÎégAMA±üaÿºIDATx^ì½ ^U™îÿìþµó}§·œôJ !=ôÐ¥( ˆ`/ˆýÎXÆ23Nsœ{gu¼3÷ªÿ™±_u,£"*(ˆ H -!õôþõÝÿo‡C˜ )¼¿Ãf·µ×^kí}ržg¯AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA„ç Õׂ ‚ €¥K—v.\¸0†¡7cÆŒOÌ The tutorial is an online training course I login to www.e-careers.com " support pretty much non existent" you get what you pay for I guess. (Groupon deal)
×
×
  • 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.