-
Posts
902 -
Joined
-
Last visited
-
Days Won
9
Everything posted by doddsey_65
-
Hi, I have a rating system in place on my site. The problem is i have a section called tutorials, which pulls all the results from the database. I would then click on a result to bring that tutorial up. I have gone with this because the rating system depends on things being on different pages. But at the minute i have 50 tutorials and loads more to input. I dont want to have to create a seperate page for every tutorial but the way my rating system is, i would have to. is there anyway to display the tutorial once clicked, without having to create a page for each one and for the rating system to work within this setup. Heres an example of my current setup HOME>>TUTORIALS>>TUTORIAL1 list of tuts the tut vid
-
Cheers for the replies. I am not getting any errors now but it will let mepost more than one within an hour. Here is the full code: Db table last is set as datetime. $last = ("SELECT * FROM users WHERE username='{$_POST['username']}' AND last < NOW() - INTERVAL 1 HOUR"); if (mysql_query($last)) { $sql="INSERT INTO publicgallery (path, name, username, description, thumbpath) VALUES ('$filePath','{$_POST['rendername']}','{$_POST['username']}','{$_POST['description']}', '$thumbpath')"; $result = mysql_query($sql, $db); echo '<br><br><div id="page"><div id="content"><div class="post"> <p class="meta">Your image has been successfully uploaded <img src="images/img08.png" alt="bullet"></p><div class="entry">'; echo 'Your new image will now be visible on the Public Gallery. Click <a href=public_gallery.php>here</a> to go back.'; echo '</div></div></div>'; $sql=("UPDATE users SET points=points + 1, last=NOW() WHERE username='{$_POST['username']}'"); $res=mysql_query($sql); } else { echo '<br><br><div id="page"><div id="content"><div class="post"> <p class="meta">Your image has not been uploaded <img src="images/img08.png" alt="bullet"></p><div class="entry">'; echo 'You can only upload 1 render per hour.'; echo '</div></div></div>'; }
-
ok i have now changed it to this: $time = time(); $interval = 3600; $last = ("SELECT * FROM users WHERE username='{$_POST['username']}' AND last<$time-$interval"); in my db the table 'last' is currently set to TIME which isnt working, what do i need to set it to? when i echo time i get: 1259249644 and interval is: 1259246044 and in the db it is - 00:00:00
-
Okay i have worked it out now, i didnt have an else statement if the query was false. I do now but i dont know why it keeps coming back as false, the db table int is currently 0 and i echoed time to get 09. but my query is if 0<09 which is true but it returns false. Does anyone know why this is?
-
here is what should appear when succesful: echo '<br><br><div id="page"><div id="content"><div class="post"><p class="meta">Your image has been successfully uploaded <img src="images/img08.png" alt="bullet"></p><div class="entry">'; echo 'Your new image will now be visible on the Public Gallery. Click <a href=public_gallery.php>here</a> to go back.';echo '</div></div></div>'; Also the table is Int(2)
-
cheers mate that fixed the 500 but now the screen doesnt display anything when i upload. heres the full code, there may be more errors that you couldnt see before. As for the code to do the time is that right? if i get these errors sorted would tht work? <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $uploadDir = 'public/'; if(isset($_POST['upload2'])){ $fileName = $_FILES['userfile2']['name']; $tmpName = $_FILES['userfile2']['tmp_name']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) {echo "Error uploading file";exit;} if(!get_magic_quotes_gpc()){$filePath = addslashes($filePath);} include('resize.php'); $image = new SimpleImage(); $image->load('public/' .$fileName); $image->resize(100,100); $image->save('public/thumbs/' .$fileName); $thumbpath= 'public/thumbs/' .$fileName; $time = date("H"); $last = ("SELECT * FROM users WHERE username='{$_POST['username']}' AND last<$time"); if (mysql_num_rows($last)) { $sql="INSERT INTO publicgallery (path, name, username, description, thumbpath, last) VALUES ('$filePath','{$_POST['rendername']}','{$_POST['username']}','{$_POST ['description']}', '$thumbpath', '$time')"; $result = mysql_query($sql, $db); echo '<br><br><div id="page"><div id="content"><div class="post"> <p class="meta">Your image has been successfully uploaded <img src="images/img08.png" alt="bullet"></p><div class="entry">'; echo 'Your new image will now be visible on the Public Gallery. Click <a href=public_gallery.php>here</a> to go back.'; echo '</div></div></div>'; $sql=("UPDATE users SET points=points + 1 WHERE username='{$_POST['username']}'"); $res=mysql_query($sql); include('footer.php'); } } ob_flush(); ?>
-
Okay this is what i am trying but i keep getting a 500 error. Can anyone see what is wrong? $time = date("H"); $last = ("SELECT * FROM users WHERE username='$_POST['username']' AND last<$time"); if (mysql_num_rows($last)) { $sql="INSERT INTO publicgallery (path, name, username, description, thumbpath, last) VALUES ('$filePath','$_POST['rendername']','$_POST['username']','$_POST['description']', '$thumbpath', '$time')"; $result = mysql_query($sql, $db); echo '<br><br><div id="page"><div id="content"><div class="post"> <p class="meta">Your image has been successfully uploaded <img src="images/img08.png" alt="bullet"></p><div class="entry">'; echo 'Your new image will now be visible on the Public Gallery. Click <a href=public_gallery.php>here</a> to go back.'; echo '</div></div></div>'; $sql=("UPDATE users SET points=points + 1 WHERE username='$_POST['username']'"); $res=mysql_query($sql); include('footer.php'); }
-
i tried that but i keep getting a 500 error.
-
am i right in thinking i need to insert the date and time into the database when they upload an image, and when they go to add anotherone i would need to pull the date of their last one from the database and see if it was atleast an hour before this one? Soething like $current= date("H:i:s"); $last=("SELECT last FROM users WHERE username='$_POST['username']"); $res=mysql_query($last); Then i get stuck with the if and thats what i need help with.
-
okay cheers mate, also i wanted to add a new feature since users could just add images all the time to increase their points, i was wondering about a 1 hour time delay whereby they could only upload 1 image per hour. Is this possible?
-
Hi, i have a database which houses all of the users of my site. One of the columns is for points which is default 0. What I would like to do is add 1 to this number each time they upload an image. What code would i use for this? I have an idea but i dont think it would work. My idea is something like: $add= +1 $sql ("update users set points=$add") Something like that?
-
Hi, I currently have an image upload system in place which works fine but what i want is for the user to upload an image then the image is copied, one of them is sent to uploads/ and the other is resized and sent to uploads/thumb. Is this possible? Heres my code at the moment: <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $uploadDir = 'public/thumbs/'; if(isset($_POST['upload2'])) { $fileName = $_FILES['userfile2']['name']; $tmpName = $_FILES['userfile2']['tmp_name']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $filePath = addslashes($filePath); } $link= $fileName. '.php'; $sql="INSERT INTO publicgallery (path, paththumb, name, username, description, link) VALUES ('$filePath','$_POST[rendername]','$_POST[username]','$_POST[description]', '$link')"; $result = mysql_query($sql, $db); echo '<br><br> <div id="page"> <div id="content"> <div class="post"> <p class="meta">Your image has been successfully uploaded <img src="images/img08.png" alt="bullet"></p> <div class="entry">'; echo 'Your new image will now be visible on the Public Gallery. Click <a href=public_gallery.php>here</a> to go back. </div></div></div>'; include('footer.php'); } ob_flush(); ?>
-
so basically change all of the variables in upload2.php so they are dif from the other upload form(upload.php) and the same in the forms. When i got rid of the upload.php and sed this one(upload2.php) it did work but i will try them both. Oh and when i say it did work it wasnt uploading or inserting the image details. I echoed the sql and it didnt display the filepath, so i echoed the $filepath and came up with nothing. Since the first upload script is gone i know this is nothing to do with it. When i set about doing this thing i thought it would be easy lol, just insert a few things in the db and recall them. How wrong was I. Anyway have ou any idea why $filepath is returning nothing? It worked fine in the first upload.php. <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $uploadDir = 'public/'; if(isset($_POST['upload2'])) { $fileName = $_FILES['userfile2']['name']; $tmpName = $_FILES['userfile2']['tmp_name']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $filePath = addslashes($filePath); } $sql="INSERT INTO publicgallery (path, name, username, description) VALUES ('$filepath','$_POST[rendername]','$_POST[username]','$_POST[description]')"; $result = mysql_query($sql, $db); echo 'FILEPATH:(' .$filepath. ')'; echo $sql; echo '<br><br> <div id="page"> <div id="content"> <div class="post"> <p class="meta">Your image has been successfully uploaded <img src="images/img08.png" alt="bullet"></p> <div class="entry">'; echo 'Your new image will now be visible on the Public Gallery. Click <a href=public_gallery.php>here</a> to go back. </div></div></div>'; include('footer.php'); } ob_flush(); ?>
-
yeh i always refresh the page after editing files, but i understand what you mean now. is there anything else that could cause this? could it be due to the form type(multipart/form-data) or because there is another form(on a dif page) with the same names(eg userfile)
-
okay im confused lol. The form i am using has a submit button like so: <input type="submit" value="Upload Render" name="upload2" id="upload2" /> and the code in upload2 for it is if(isset($_POST['upload2'])) which i thought was right
-
cheers for the reply, heres what i came out with: POST:Array ( [MAX_FILE_SIZE] => 200000 [username] => doddsey_65 [rendername] => cell [upload] => Upload Render ) FILES:Array ( [userfile] => Array ( [name] => cell.jpg [type] => image/pjpeg [tmp_name] => /tmp/phpseGNuN [error] => 0 [size] => 4499 ) ) All looks ok to me here, can you see anything wrong?
-
the echo follows on to the lines below for the div and closes at the end of them
-
I have an image upload script that works fine, but i decided to make another one for a dif section of the site. This time though i needed to include things like name and description aswell as the image to upload. So i copied the upload.php file and added a few more things in but when i click uppload it goes straight to a blank screen and does nothing. Is there something wrong wih my code? Form echo '<form enctype="multipart/form-data" action="uploader2.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="200000" /> <table border="0"> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="60"><font color=#ff0000 size=1> * required</font> </td></tr> <tr><td>Render Name:</td><td> <input type="text" name="rendername" maxlength="50"><font color=#ff0000 size=1> * required</font> </td></tr> <tr><td>Description:</td><td> <input type="text" name="description" maxlength="50"><font color=#ff0000 size=1> * required</font> </td></tr> <br><br> <tr><td>Choose an Image:</td><td> <input name="userfile" type="file" id="userfile" /><br /> <input type="submit" value="Upload Render" name="upload2" id="upload2" /> </td></tr></table></form></p>'; echo '</div>'; upload2.php <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $uploadDir = 'uploads/'; if(isset($_POST['upload2'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $username = $_POST['username']; $render = $_POST['rendername']; $description = $_POST['description']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $filePath = addslashes($filePath); } $sql = ("UPDATE publicgallery SET path='$filePath', username='$username', name='$rendername', description='$description', link='$filePath'") or die (mysql_error()); $result = mysql_query($sql, $db); echo '<br><br> <div id="page"> <div id="content"> <div class="post"> <p class="meta">Your image has been successfully uploaded <img src="images/img08.png" alt="bullet"></p> <div class="entry">'; echo 'Your new image will now be visible on the Public Gallery. Click <a href=public_gallery.php>here</a> to go back. </div></div></div>'; include('footer.php'); } ob_flush(); ?>
-
i have an image resizing script: <?php class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if( $this->image_type == IMAGETYPE_JPEG ) { $this->image = imagecreatefromjpeg($filename); } elseif( $this->image_type == IMAGETYPE_GIF ) { $this->image = imagecreatefromgif($filename); } elseif( $this->image_type == IMAGETYPE_PNG ) { $this->image = imagecreatefrompng($filename); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image,$filename,$compression); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image,$filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image,$filename); } if( $permissions != null) { chmod($filename,$permissions); } } function output($image_type=IMAGETYPE_JPEG) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image); } } function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); } function resizeToHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height); } function resizeToWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width,$height); } function scale($scale) { $width = $this->getWidth() * $scale/100; $height = $this->getheight() * $scale/100; $this->resize($width,$height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } } ?> <?php include('resize.php'); $image = new SimpleImage(); $image->load('path/image.png'); $image->resize(400,300); $image->save('path/image.png'); ?> Is there any way i can incoroprate this into the upload form?
-
sorry but i dont understand any of that?
-
When a user uploads their image i want to be able to get the dimensions and resize accordingly before the image is uploaded. I want the images to be only 100x100. how would i go about this? I already have an upload function just need these things added to it.
-
Sorry for the triple post but i cant or rather dont want to move onto another part of my site without this working.
-
Okay i got the format to work but when i click next page it just shows up the same results not the next ones. <?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); if (!(isset($pagenum))) { $pagenum = 1; } $data = mysql_query("SELECT * FROM tutorials") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = 3; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; echo '<div id="page">'; echo '<div id="content"><br />'; echo '<h2 class="title">Tutorials By Hamish Hill</h2><br />'; $sql = "SELECT name, fullname, description, link, path FROM tutorials WHERE username='hamsterhill' $max"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { echo '<div class="post">'; echo '<p class="meta">' .$row["fullname"]. ' | ' .$row["name"]. '<img src="images/img08.png" alt="bullet"></p>'; echo '<div class="entry">'; echo '<p><img src=' .$row['path']. ' hspace=10 align=left>'; echo $row['description']. '</p>'; echo '</div>'; echo '</div>'; } echo "<p> Page $pagenum of $last </p>"; if ($pagenum == 1) { } else { echo " <p><a href='{$_SERVER['PHP_SELF']}?pagenum=1' class=links> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous' class=links> <-Previous</a> </p>"; } if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <p><a href='{$_SERVER['PHP_SELF']}?pagenum=$next' class=links>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last' class=links>Last ->></a></p> "; } echo '</div>'; include('footer.php'); ob_flush(); ?>
-
do you mean you want to use the same hex color to specify background or something? if so something like PSP or GIMP tells you what the hex color is