Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Update

PHP Update

Reply
  #1 (permalink)  
Old 07-05-09, 11:09 AM
SniperTowers SniperTowers is offline
Wannabe Coder
 
Join Date: Dec 2008
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Update

Form:

PHP Code:
<?php
session_start
();
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 thumbnails.";
echo 
"<br/>Add a Thumbnail:<br/><br/>";
    echo 
"<form action=\"thumbnail.php\" 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 thumbnail!\">
        </form>"
;
       
include(
"template/footer.php");
?>
Thumbnail.php:

PHP Code:
<?php
session_start
();
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>');
}
      
$rand rand(0,999999);
      
move_uploaded_file($_FILES["file"]["tmp_name"], "http://www.hotscripts.com/forums/images/" "$rand" $_FILES["file"]["name"]);
      
$thumbnail "$rand" $_FILES["file"]["name"];
      if(empty(
$_FILES["file"]["name"])){
          
$thumbnail "none.jpeg";
}
    
$id mysql_real_escape_string($_GET['id']);
    
$result mysql_query("UPDATE layouts SET thumbnail = '$thumbnail' WHERE id='$id'");
        echo 
"The thumbnail has been added.";
        echo 
"$title";
        
include(
"template/footer.php");
?>
I'm trying to update a database with the image i have uploaded however nothing updates? What am I doing wrong?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-05-09, 04:53 PM
Jcbones Jcbones is offline
Coding Addict
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 269
Thanks: 3
Thanked 3 Times in 3 Posts
You are trying to update a row where the id = NULL.

Your values are being sent by "POST" not "GET".

So change your $id line to:
PHP Code:
$id mysql_real_escape_string($_POST['title']); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-05-09, 06:43 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 499
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:
    $result mysql_query("SELECT * from layouts WHERE id ORDER BY `title` ASC"); 
" WHERE id " doesn't have any value associated with it in your query.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share 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
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 03:22 AM
Database Change, PHP Auto Update?? memphis2k PHP 4 02-22-08 05:47 AM
FYI: Shout goes out over PHP security bugs nugensoftware PHP 0 11-02-05 12:43 AM
PHP: Site/Page View, Edit & Update MikeFairbrother Script Requests 5 10-13-05 12:21 AM
Mouseover with Single PHP page rjwebgraphix PHP 7 09-16-04 06:15 PM


All times are GMT -5. The time now is 06:29 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.