Jump to content

Skipjackrick

Members
  • Posts

    196
  • Joined

  • Last visited

    Never

Everything posted by Skipjackrick

  1. No, I am not using that above.... I see what you mean.
  2. Is there something wrong here? I can't figure this out. Looks perfectly normal to me? <?php if ( $results['team_id'] == 0 ) { $team .= 'Not Specified'; } else { $queryteam = "SELECT * FROM team WHERE team_id={$results['team_id']} "; $result = mysql_query($queryteam) or die(mysql_error()); $team = mysql_fetch_assoc($result) } ?>
  3. Well it turns out that if you allow "image/pjpeg" OR "image/jpeg" it will work in both FF and IE. Here is how I got it working. <?php // verify image type if (!($_FILES['file']['type'] == 'image/jpeg' OR $_FILES['file']['type'] == 'image/pjpeg' )) { echo "You have encountered an error"; } ?>
  4. Yeah, I checked that. The field shows the .jpg extension...... Its very strange.. I just don't get it.
  5. I've got a photo upload script where I verify the file type. For some reason it sends me to my error message when I upload the correct file using IE. It works fine in Firefox. Any clues? Maybe you guys have a better way of verifying file type. But I only want jpg files. <?php // name of the fieldname used for the file in the HTML form $fieldname = 'file'; // Now let's deal with the upload // possible PHP upload errors if (($_FILES["file"]["type"] == "image/jpeg")) { $errors = array(1 => 'php.ini max file size exceeded', 2 => 'html form max file size exceeded', 3 => 'file upload was only partial', 4 => 'no file was attached'); // check the upload form was actually submitted else print form isset($_POST['submit']) or error('the upload form is neaded', $uploadForm); // check for standard uploading errors ($_FILES[$fieldname]['error'] == 0) or error($errors[$_FILES[$fieldname]['error']], $uploadForm); // check that the file we are working on really was an HTTP upload @is_uploaded_file($_FILES[$fieldname]['tmp_name']) or error('not an HTTP upload', $uploadForm); // validation... since this is an image upload script we // should run a check to make sure the upload is an image @getimagesize($_FILES[$fieldname]['tmp_name']) or error('only image uploads are allowed', $uploadForm); // make a unique filename for the uploaded file $uploadFilename = $uploadsDirectory.$anglerId.'avatar.jpg'; // now let's move the file to its final and allocate it with the new filename @move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename) or error('receiving directory insuffiecient permission', $uploadForm); $image_name = $anglerId.'avatar.jpg'; $q = "UPDATE anglers SET avatar='$image_name', avatar_active=1 WHERE anglerId=$anglerId"; $s = mysql_query($q, $db); //if an error echo(mysql_error()); // If you got this far, everything has worked and the file has been successfully saved. // We are now going to redirect the client to the success page. header('Location: ' . $uploadSuccess); } else { header("Refresh: 5; URL=addaprofile_photos.php"); echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n". '"http://www.w3.org/TR/html4/strict.dtd">'."\n\n". '<html lang="en">'."\n". ' <head>'."\n". ' <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n". ' <link rel="stylesheet" type="text/css" href="stylesheet.css">'."\n\n". ' <title>Upload error</title>'."\n\n". ' </head>'."\n\n". ' <body>'."\n\n". ' <div id="Upload">'."\n\n". ' <h1>Apologies, but only JPG Files are accepted.</h1>'."\n\n". ' <p>The upload form will reload in 5 seconds</p>'."\n\n". ' </div>'."\n\n". '</html>'; exit; } ?>
  6. Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /public_html/addaprofile_photos_submit.php on line 16 I can't seem to find it. Where's Waldo? <?php // addaprofile_photos_submit.php session_start(); if( !isset($_SESSION['addId']) ) { // error - need session to be here header("Location: addaprofile_error.php"); exit(); } else { // session active // // define save image function function SaveImage( $id, $label ) { $filenameNew = getcwd() . '\avatars\' . $id . $label . '.jpg'; if( is_file($filenameNew) ) { @unlink($filenameNew); } $_SESSION['avatar_size'] = '0'; $filename = $_FILES['prfFilename']['tmp_name']; if( $filename == '' ) { return 'No file uploaded'; } switch( $_FILES['prfFilename']['type'] ) { case 'image/gif': case 'image/png': case 'image/jpeg': case 'image/pjpeg': // good image types break; default: return 'Unsupported image type: ' . $_FILES['prfFilename']['type']; } if ($_FILES['prfFilename']['error'] > 0) { // error trying to read file switch( $_FILES['prfFilename']['error'] ) { case 1: return 'File size exceeds limit of ' . ini_get(upload_max_filesize); break; case 2: return 'File size exceeds 1MB limit'; break; case 3: return 'File was only partially loaded'; break; case 4: return 'No file was uploaded'; break; case 6: return 'Missing temporary folder'; break; case 7: return 'File failed to write to disk'; break; case 8: return 'File upload stopped by extension'; break; default: return 'Unknown errorcode: ' . $_FILES['prfFilename']['error']; } } list($width, $height, $type) = getimagesize($filename); // Get new dimensions $widthMax = 1024; $heightMax = 1024; if( $width > $widthMax ) { $widthNew = $widthMax; // limit width to 1024 } else { $widthNew = $width; } if( $height > $heightMax ) { $heightNew = $heightMax; // limit height to 1024 } else { $heightNew = $height; } if( $widthNew/$width < $heightNew/$height ) { $heightNew = floor($height*$widthNew/$width); // use width ratio } else { $widthNew = floor($width*$heightNew/$height); // use height ratio } // Scale image in memory $imageNew = imagecreatetruecolor($widthNew, $heightNew); if( !imageNew ) { return 'Memory error creating image'; } switch( $type ) { case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($filename); break; case IMAGETYPE_GIF: $image = imagecreatefromgif($filename); break; case IMAGETYPE_BMP: $image = imagecreatefrompng($filename); break; default: return 'Invalid image format:' . $type; } if( !$image ) { return 'Error reading image' . $type; } if( !imagecopyresampled($imageNew, $image, 0, 0, 0, 0, $widthNew, $heightNew, $width, $height) ) { return 'Error copying and scaling image'; } // Output to upload location, 75 is quality scale 1 - 100 if( !imagejpeg($imageNew, $filenameNew, 75) ) { return 'Error storing image'; } imagedestroy($image); imagedestroy($imageNew); $_SESSION['avatar_size'] = strval(filesize($filenameNew)); return 'Upload Successful'; } // // process photos $anglerId = $_SESSION['anglerId']; // get current angler profile id $prfLabel = $_POST['prfLabel']; // get picture label ex. avatar $_SESSION['errorUpload'] = ''; // clear error message $results = ''; $results = SaveImage( $anglerId, $prfLabel ); if( $results != 'Upload Successful' ) { // upload error $_SESSION['errorUpload'] = $prfLabel .': ' . $results; } else { // no error, let's go prep data for db $_SESSION['signature'] = stripslashes($_POST['signature']); include 'db_connect.php'; // include database connection $prfCaption = mysql_real_escape_string($_SESSION['signature']); $sql = "UPDATE anglers SET avatar_size = {$_SESSION['avatar_size']}, signature = '$prfCaption' "; $sql .= "WHERE anglerId = $anglerId"; $result = mysql_query($sql) or die(mysql_error()); } // header('Location: addaprofile_photos.php'); exit(); } ?>
  7. Aye, thanks. So simple. I would usually catch that but I am tired. Need sleep...Do you happen to know if my solution is cross browser friendly? It seems to work in IE8 and Firefox just fine.
  8. OK, I am getting closer. I have played around with it and now I've got this kind of working.... Problem is, the word "Submit" is displayed over my background. However, the image rollover works well. <input type="submit" value="Submit" class="button" /> .button { border: none; width: 123px; height: 30px; background: url(images/buttons/register.png) no-repeat top left; } .button:hover { background-position: -123px 0; }
  9. I have searched and tried editing the code and just can't seem to figure out how to get image rollovers to work with an "input" or "submit" button. Does anybody know how to get this to work for an "input" button? I've done this a thousand times for menu buttons that are links. But never an input? <input name="submit" type="image" src="layout/images/buttons/register.png" alt="register" />
  10. I just can't seem to get the page numbers to align properly on the right side of the page. I want the image on the far left and the page numbers on the far right. But I can't get it to position correctly with my current CSS. Can you guys give me a little help? When I set the float to "right" the page numbers flip around the opposite way!!!! Here is what is looks like so far. http://www.watermansvideo.com/wof/wof.php?currentpage=2 The code I am in reference too. <img src="http://www.watermansvideo.com/wof/mostrecent.jpg" alt="watermansvideo.com"> <ul class="pagination"> <li class="next"><a href="/wof/wof.php?currentpage=1">First <<</a></li> <li><a href="/wof/wof.php?currentpage=1"><</a></li> <li><a href="/wof/wof.php?currentpage=1">1</a></li> <li class="active"><b>2</b></li> <li><a href="/wof/wof.php?currentpage=3">3</a></li> <li><a href="/wof/wof.php?currentpage=3">></a></li> <li class="next"><a href="/wof/wof.php?currentpage=3">Last >></a></li> </ul> And of course my css /* Pagination ---------------------------------------- */ ul { border:0; margin:0; padding:0; } .pagination li { border:0; margin:0; padding:0; font-size:11px; list-style:none; margin-right:2px; } .pagination a { border:solid 1px #9aafe5; margin-right:2px; } .pagination .previous-off, .pagination .next-off { border:solid 1px #DEDEDE; color:#888888; display:block; float:left; font-weight:bold; margin-right:2px; padding:3px 4px; } .pagination .next a, .pagination .previous a { font-weight:bold; } .pagination .active { background:#2e6ab1; color:#FFFFFF; font-weight:bold; display:block; float:left; padding:4px 6px; } .pagination a:link, .pagination a:visited { color:#9aafe5; display:block; float:left; padding:3px 6px; text-decoration:none; } .pagination a:hover { border:solid 1px #0e509e; background:#2e6ab1; color:#FFFFFF; } Can you guys give me a little help? When I set the float to "right" the page numbers flip around the opposite way!!!!
  11. This is my favorite part of the tutorial. Cause its my case exactly. Just had to share.......no more I promise.
  12. Ah, see....this is why I come here. Thanks fellas. I had never heard of pagination. Solved!
  13. I've got a challenge and I can't come up with a solution. I have a photo gallery where I query and display the last 12 images using the code below. (This is only a portion) <?php //Query the database for the image information $query_image = "SELECT * FROM image ORDER BY image_id DESC LIMIT 12"; $image_result = mysql_query($query_image) or die(mysql_error()); ?> Well, this only shows the last 12 images. I want to put a link that will re-load the page with the next 12 images. How would I run my query? Basically I need something like this.....LOL <?php //Query the database for the image information $query_image = "SELECT * FROM image ORDER BY image_id (subtract 12) LIMIT 12"; $image_result = mysql_query($query_image) or die(mysql_error()); ?> Or do you guys have a better way of doing this action?
  14. Ah, thanks....working now. Sometimes its so easy its stupid.
  15. Yeah, that's what I need. I've been trying to install phpmyadmin. I believe mysql is working properly because I can pull it up in a command prompt. what would be the command to create a db? Same as Php? mysql_create_db("sharkathon") or die(mysql_error()); Nope apparently not.
  16. So, I installed MySQL version 5.1, Apache 2.2, and php 5 on Windows XP. I am trying to use phpmyadmin and it doesn't work. I dropped the phpmyadmin files in my root directory and opened up the phpmyadmin/index.php file and I get this error. phpMyAdmin - Error Cannot load mysql extension. Please check your PHP configuration. Here are a few questions. How do I know my MySQL is working properly? Is there a way to test it? I tested php and it works fine using a test program. Next, I need to create a database and define users, and passwords, tables etc in MySQL but I have no idea how to do this using mysql. I have always done it using phpmyadmin through the web. I am trying to install this locally on my computer so I can test things faster. What do I edit in my PHP configuration? Can anybody help me out?
  17. Ok, so I am still a beginner with php but I'd like to know if there is a better way to do this. Currently, I am setting the following variables throughout my code. <?php $month=5; $month_name=May; $year=2009; ?> Is there a way that this could be done automatically? Each month I have to change the variables to the current month. Its a freaking pain in the ass. There has got to be a way to do this automatically.
  18. Does anyone know if there is a thumbnail generator script out there that uses the URL for the image instead of the filename? Most of the scripts I find out there require the filename of the image. Well, in my database I store the actual URL to the image and not the filename. Just hoping maybe someone came across a different type of snippet before?
  19. That's a good idea! Do you know of a good site for formatting code?
  20. AH DARN!!! THANK YOU SO MUCH!! WORKS PERFECT! That's not the first time a comma has got me before...
×
×
  • 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.