0

Hi All.

I am having some trouble with a script which allows a user to upload a photo. When the page first loads it checks if the user has reached their maximum photo capacity. If they have then it will redirect them to another page. If they can upload more photos it will keep them on the page. Before I added this the user could select which album the photo goes into by using a drop down box. Now when I load the page, there is nothing in the drop down box. Here is the code and if anyone could help, I would be very grateful.
Thanks in advance.
Cameron

<?php
require("check_session.php");

$id = $_SESSION['id'];

$sql = mysql_query("SELECT * FROM users WHERE username='".$_SESSION['username']."'");
			$sql_fetch = mysql_fetch_assoc($sql);
			$row_max = $sql_fetch['max_photos'];
			$row_id = $sql_fetch['id'];

$check = mysql_query("SELECT * FROM items WHERE userid='$row_id'");
			
			
			$check_num = mysql_num_rows($check);
			
			


if($check_num>$row_max)
{
	echo '<meta http-equiv="Refresh" Content="0; URL=maxphotos.php">';

}




?><form enctype="multipart/form-data" action="upload_picture.php" method="POST"> 
<table width="1019" border="0">
  <tr>
    <td><b>Note: Make sure you check wich album you are inserting the image into by looking at the 'Insert into album' drop down menu.</b></td>
  </tr>
</table>
<table width="1020" border="0">
  <tr>
    <td width="418">Please choose a picture to upload</td>
    <td width="16">:</td>
    <td width="497"><input name="uploaded" type="file" /></td>
    <td width="55">&nbsp;</td>
    <td width="12">&nbsp;</td>
  </tr>
  <tr>
    <td>Image Name</td>
    <td>:</td>
    <td><input type="text" name="imgname" /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>Description</td>
    <td>:</td>
    <td><textarea name="description"></textarea></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>Insert into album</td>
    <td>&nbsp;</td>
    <td><select name="albumid">
      <?php
$id = $_SESSION['id'];

$rs = mysql_query("SELECT * FROM albums WHERE userid='$id'");

while($row = mysql_fetch_array($rs))
{
  echo "<option value=\"".$row['id']."\">".$row['name']."</option>\n  ";
}
?>
    </select></td>
    <td><input name="upload" type="submit" id="upload" value="Upload" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><b>Uploading process may take 1-2 mins depending on file size.</b></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><p>&nbsp;</p>
    <p><b><a href="index.php">Back</a></b></p></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<br />
<?php

		
		include("design/footer.php");
		?>
3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by doctorphp
0

Echo query below and run in sql window.
Does it returning result??

echo "SELECT * FROM albums WHERE userid='".$_SESSION['id']."'";
0

Echo query below and run in sql window.
Does it returning result??

echo "SELECT * FROM albums WHERE userid='".$_SESSION['id']."'";

Yes it is returning the ID of the user currently logged in.

0

remove newline. check are matched with id,name.

echo "<option value=\"".$row['id']."\">".$row['name']."</option>";
0

remove newline. check are matched with id,name.

echo "<option value=\"".$row['id']."\">".$row['name']."</option>";

It works. Thank you so much!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.