mysql_fetch_array help

Discussion in 'PHP' started by crazyryan, Oct 5, 2007.

  1. #1
    So I'm pulling a bit of info from a database, all is good untill I try this code:
    <input type="file" name="file1" value="'.$row['file'].'" />

    When I go to my page, if I view the source $row['file'] executes, but the value of the box when I'm looking at the box is empty.
    $row['file'] = files/local/test.gif
     
    crazyryan, Oct 5, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Post your actual code.
     
    nico_swd, Oct 5, 2007 IP
  3. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #3
    	if(isset($_POST['edit'])) {
    				$id = $_POST['id'];
    				$q = mysql_query("select * from files where id = '$id'") or die(mysql_error());
    				if(mysql_num_rows($q) == 0) {
    				echo 'Game don\'t exist yo\'';
    				}
    				else {
    				$row = mysql_fetch_array($q);
    			echo '<form name="update" action="'.$_SERVER['REQUEST_URI'].'" enctype="multipart/form-data" method="post">
    			Name:<br />
    			<input type="text" name="name" value="'.$row['name'].'" /><br />
    			Description:<br />
    			<input type="text" name="description" style="width: 300px; height: 100px;" value="'.$row['description'].'" /><br />
    			Movie File:<br />
    			<input type="file" name="file1" value="'.$row['file'].'" /><br />
    			Image File:<br />
    			<input type="file" name="file2" value="'.$row['thumbnail'].'" /><br /><br />
    			<input type="submit" name="update" value="Submit" />
    			';
    				}
    				}
    PHP:
     
    crazyryan, Oct 5, 2007 IP
  4. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #4
    Regardless of what your code is, you cannot set the value of a file input for security reasons.
     
    krt, Oct 5, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    ^^ Good catch, I missed the "file" type.
     
    nico_swd, Oct 6, 2007 IP