Jump to content

garry

Members
  • Posts

    217
  • Joined

  • Last visited

    Never

Everything posted by garry

  1. Does anyone else have any ideas? I can provide any information you might require?
  2. They're definitely the same. I even dumped the sql of my local servers DB and re-imported into the hosting servers one. They're definitely exactly the same
  3. Nope, using that still gives me a result on local but nothing on hosting server. It must be something to do with users table..
  4. Files and databases are the same on both servers. I did break the query by removing the users part, and that made the query work (but with the user part messed up).
  5. So I'm using this query to get review information from a database: $query =" SELECT * FROM artists, albums, reviews, users WHERE reviews.id = '$id' AND reviews.artist_id = artists.id AND albums.id = reviews.album_id AND users.id = albums.user_id "; Now this works fine on my local server but it does not work on my hosting server. It is because the query is not obtaining any results on the hosting server, however it always gets the result on my local. And also, if i remove the "AND users.id = albums.user_id" part from my query, it will show up fine on my hosting server, but the user gets messed up. But apart from this, everything else works. I don't understand why it's doing it :/ Can anyone help?
  6. So what I want to have is a table with the latest reviews from my database and I want to have two results per row on the table. Here's the query I'm using: SELECT reviews.id AS reviewid, reviews.artist_id, reviews.album_id, artists.id AS artistid, artists.artist, albums.id AS albumid, albums.title, albums.thumb FROM artists, reviews, albums WHERE reviews.artist_id = artists.id AND reviews.album_id = albums.id ORDER BY reviews.created_at DESC LIMIT 5 And then I use a while loop to have a new <tr> for each result. How can I change this so I can have the first two results in a <tr> and the next two in another.. and so on.. Thanks!
  7. Hmm.. I don't understand exactly how you are reloading the page with the same data.. Sorry - I'm sorta new at this! I already validate the information on the same page as the form. Here's a general idea of how I do it: if (isset($_POST['submitted2'])) { $something = $_POST['something']; // ect... } else { <form enctype="multipart/form-data" action="<?php $_SERVER['PHP_SELF']; ?>" method="POST"> <table width="615" border="0"> <tr> <td><div align="right">Artist: </div></td> <td><input type="text" name="artist" value="<?php echo $artist; ?>"></td> <td><input type="hidden" name="artistid" value="<?php echo $artistid; ?>"></td> </tr> <tr> <td><div align="right">Description: </div></td> <td colspan="2"><textarea name="description" rows="20" cols="80"><?php echo $description; ?></textarea></td> </tr> <tr> <td><div align="right">Genre: </div></td> <td><select name="genreid" > <? $query = "SELECT * FROM genres "; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { echo "<option name=\"genre\" value=\"" . $row['id'] . "\" "; if ($genre_id == $row['id']){ echo "selected";} echo ">" . $row['genre'] . "</option><br />"; } ?> </select></td> <td></td> </tr> <tr> <td width="96" height="32"><div align="right">Artist Image:</div></td> <td width="298"><input name="image" type="file" /></td> <td width="486"><div class="message">Note: Must be at least 300x300. Leave blank if you don't want to change.</div></td> </tr> <tr> <td height="33"><input name="submitted2" type="hidden" value="1"></td> <td><input name="submit" type="submit" value="Edit" /></td> <td></td> </tr> </table> </form> } That is my actual form in the second part but I didn't put the whole "submitted2" part because it's very long! Can you explain to me exactly how you reload the form with the same user supplied data? Sorry for not understanding!
  8. Surely there's an easier way then that? Because I've seen it done in a lot of places. Hell, even the forums here do it. And I've heard of Smarty as a template system? I don't want to use that, I'm trying do all of it myself.
  9. So I have a form that submits user supplied data which is then checked for a few things and (if successful) added to the database. The only problem is that if something goes wrong with the users input (they forget to fill in a field) the error message will be displayed, they will click "Back" and all of the information they put in is gone! For example, this is how I check the data: if (empty($_POST['artist']) || empty($_POST['description'])) { echo "Oops! Looks like you haven't filled in all of the fields. Go back and try again."; } Then they click on Back and it's all blank. I know this is going to be very frustrating if it happens to anyone as they are inputting reviews and a lot of formatting so they will not be happy if they have to do it again! How can I fix this problem? Thanks!
  10. That did the trick, thanks
  11. So i'm using some user supplied info from a form and the form contains a place where the user can specify an image file to be uploaded. This works fine when the image file is actually chosen, but if they do not select the image file, i don't want the script to use any of the image variables or anything, which is why I have the following code: if (isset($HTTP_POST_FILES['image']) && !empty($HTTP_POST_FILES['image'])) { // Check if image has been uploaded And also, I'm just using <input name="image" type="file" /> inside the actual form. But for some reason, when no file is uploaded, it still tries to do the things inside my if statement Can anyone help?
  12. I got some help from you guys last night with manipulating a user supplied image but now I need some more help with updating it. Here's the script if (isset($HTTP_POST_FILES['image'])) { $artistart = $HTTP_POST_FILES['image']; if (!empty($HTTP_POST_FILES['image']) && $artistart['type'] == 'image/jpeg') { $tempimg = $artistart['tmp_name']; $tempsize = getimagesize($tempimg); $width = $tempsize['0']; $height = $tempsize['1']; $imglocation = $imgrow['img']; $thumblocation = $imgrow['thumb']; $filename = DOCUMENT_ROOT . 'artistart/'.$uniq . '.jpg'; $thumbfile = DOCUMENT_ROOT . 'artistart/thumbs/'.$uniq1 . '.jpg'; $newwidth = 300; $newheight = 300; $thumbwidth = 100; $thumbheight = 100; $simg = imagecreatefromjpeg($tempimg); $timg = imagecreatefromjpeg($tempimg); } } I already have imglocation and thumblocation from the database and that is where the two images are located. What I want to know is how I can use PHP to delete the old images and update them with the new ones. Thanks!!
  13. That works fantastically and uses a lot less code! Thanks a bunch for your help, it is very appreciated
  14. Okay, so now the quality is fine, but the colors are all messed up after using that script. It's mainly black and white now. Here's the code I'm using, I took some of it from Gighalens script: <?php $artistart = $HTTP_POST_FILES['image']; if ($artistart['type'] == 'image/jpeg') { $tempimg = $artistart['tmp_name']; $tempsize = getimagesize($tempimg); $width = $tempsize['0']; $height = $tempsize['1']; $uniq = uniqid(""); $filename = DOCUMENT_ROOT . 'artistart/'.$uniq . '.jpg'; $simg = imagecreatefromjpeg($tempimg); $newwidth = 300; $newheight = 300; $newimage = imagecreate(300, 300); $palsize = imagecolorstotal($simg); for ($i = 0; $i < $palsize; $i++) { $colors = ImageColorsForIndex($simg, $i); // Number Of Colors Used imagecolorallocate($newimage, $colors['red'], $colors['green'], $colors['blue']); } $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($tempimg); imagecopyresampled($newimage, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($newimage,$filename,100); ?>
  15. Thanks, this is the sort of thing I'm looking for! One problem though - the resized image and the thumbnail (thumb especially) are reduced to quite low quality after running this script. I want to have good quality images for my site! How can I improve the quality?
  16. So my users are able to upload a picture when they create a new artist on my site. I don't have any problems storing the picture, I'm only having troubles resizing it to 300x300. Here's the code I'm using: $artistart = $HTTP_POST_FILES['image']; if ($artistart['type'] == 'image/jpeg') { $tempimg = $artistart['tmp_name']; $tempsize = getimagesize($tempimg); $width = $tempsize['0']; $height = $tempsize['1']; $newwidth = 300; $newheight = 300; $uniq = uniqid(""); $filename = DOCUMENT_ROOT . 'artistart/'.$uniq . '.jpg'; $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($tempimg); imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); return imagejpeg($thumb,$filename); } When I do this, I get a bunch of very odd (and long) code appear across the screen instead of the image I want. Can anyone help?? Thanks in advance!
  17. I'd rather use a function but I guess I could do that. If anyone figures out how to do it with a function i'd still like to know! Thanks for your help anyway
  18. anyone? I'm pretty sure this isn't that hard
  19. Nope, you can use ajax in conjunction with PHP and mysql. Do some google searches on it, it is definitely possible. Unfortunately I don't know much more than that (still learning) so I can't help you any further.
  20. Not with PHP and mysql, you'd need ajax
  21. Got another question for the helpful guys here at phpfreaks I've got a function which controls the amount of users online, here it is: function users_online($usersonline) { if (isset($_SESSION['logged_in'])) { $ses = session_id(); $time = time(); $timech=$time-600; $userid = $_SESSION['user_id']; $result = mysql_query("SELECT * FROM usersonline WHERE session='$ses'"); $num = mysql_num_rows($result); if ($num == "0"){ $result1 = mysql_query("INSERT INTO usersonline (session, time, user_id)VALUES('$ses', '$time', $userid)"); } else { $result2 = mysql_query("UPDATE usersonline SET time='$time' WHERE session = '$ses'"); } $result3 = mysql_query("SELECT * FROM usersonline"); $usersonline = mysql_num_rows($result3); mysql_query("DELETE FROM usersonline WHERE time < $timech"); return $usersonline; } } So basically what I want to know is how I can get this variable of $usersonline, outside of the function so I can use it on some pages that I want to. I've done some google and haven't found a whole lot so some help would be gladly appreciated!
  22. Ah dude that worked perfectly. You're a champ 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.