Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Thumnail Adding


PHP Thumnail Adding

Reply
  #1 (permalink)  
Old 07-01-09, 08:46 PM
SniperTowers SniperTowers is offline
Wannabe Coder
 
Join Date: Dec 2008
Posts: 143
Thanks: 5
Thanked 0 Times in 0 Posts
PHP Thumnail Adding

PHP Code:

<?php

session_start
();
// Admin Section
require ("connect.php");
require(
"functions.php"); 
include(
"template/header.php");
if(
$_SESSION['status'] != 2){
    die(
'You must be an administrator to access this section; please <a href="login.php">login</a>');
}
echo 
"<a href=\"admin.php\">Return to admin section!</a></br><br/><br/>";

echo 
"Here you can add a thumbnail to a layout.<br/><br/>";


echo 
"Add a thumbnail<br/><br/>";
if(!isset(
$_POST['submit'])){
        echo 
"<form action=\"\" method=\"post\" enctype=\"multipart/form-data\">";
    echo 
"<select name=\"title\">";
    
$result mysql_query("SELECT * from layouts WHERE id ORDER BY `title` ASC");
    while(
$list mysql_fetch_array$result )){
    
$title $list['title'];  
    
$cid $list['id'];
    echo 
"<option value=\"$cid\">$title</option>";
    }
    echo 
"</select>";
echo 
"<br/>Display image (100px x 100px): <input id=\"file\" type=\"file\" name=\"file\"/><br />";
        echo 
"<br/><input type=\"submit\" name=\"submit\" value=\"Create layout!\">
        </form>"
;
        }else{
      
$rand rand(0,999999);
      
move_uploaded_file($_FILES["file"]["tmp_name"], "images/" "$rand$_FILES["file"]["name"]);
      
$image "$rand$_FILES["file"]["name"];
      if(empty(
$_FILES["file"]["name"])){
          
$image "none.jpeg";
}
 
        
mysql_query("UPDATE layouts SET thumbnail = '$image' WHERE title='$title'" or die(mysql_error()));
        echo 
"The layout has been created!";
        echo 
"$title";
        }
        include(
"template/footer.php");
?>
Here I'm trying to upload a thumnail image to the database, the image uploads into the folder but I can't get it to update the database. When the layout is added it updates the thumbnail field as '0' but I'm trying to replace it with the filename. What am I doing wrong?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-01-09, 10:26 PM
windows7 windows7 is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
mysql_query("UPDATE layouts SET thumbnail = '$image' WHERE title='$title'" or die(mysql_error()));
Try to change WHERE title LIKE `'$title'` since title's type is string I think
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-01-09, 11:37 PM
=OTS=G-Man =OTS=G-Man is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
for like dont you need some wildcards?

LIKE '%$title%'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] it works on localhost but not on hosting account? myslowquietlife PHP 42 12-19-08 10:31 AM
Adding PHP to HTML dmschenk PHP 6 11-11-04 12:00 AM
Adding PHP to HTML dmschenk PHP 2 11-10-04 04:34 PM
problem adding js with php darkcarnival PHP 3 10-27-04 04:14 PM
Need help in adding php to index.htm PLEAZE :) Nadder PHP 11 03-24-04 04:54 PM


All times are GMT -5. The time now is 09:35 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.