I am building a picture upload application for my website on the page where i choose browse for files on my computer to upload. In this application there has to be a album created before you can upload files so I have a if statement checking to see if there are any rows in the album's table. when i run this page it displays that there are no albums created and tells me to create some but I also get an error:
"Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\main\phpGallery\preupload.php on line 18"
here is the code of my form:
<?php
include("config.inc.php");
// initialization
$photo_upload_fields = "";
$counter = 1;
// default number of fields
$number_of_fields = 5;
// If you want more fields, then the call to this page should be like,
// preupload.php?number_of_fields=20
if( $_GET['number_of_fields'] )
$number_of_fields = (int)($_GET['number_of_fields']);
// Firstly Lets build the Category List
$result = mysql_query( "SELECT * FROM gallery_category", $mysql_link );
$totalcategories = mysql_num_rows ($results);
?>
<html>
<head>
<title>Lets upload Photos</title>
</head>
<body>
<?php
// check for the number of rows returned before doing any further actions.
if ($totalcategories == 0)
{
echo "There are no categories create for you to upload the files too. \nPlease create a category before uploading pictures";
exit;
}
else
{
?>
<form action='deletecategory.php' method='post' name='delete_category'>
<table width='90%' border='0' align='center' style='width: 90%;'>
<tr>
<td>
Delete Category
</td>
</tr>
<select name='category_name'>
<?php while($row = mysql_fetch_array( $result )) { ?>
<option value="<?php $row['category_id'] ?>"><?php $row['category_name'] ?></option>
<?php } //end of while?>
</select>
<tr>
<td>
<input type='submit' name='submit' value='Delete Category' />
</td>
</tr>
</table>
</form>
<form enctype='multipart/form-data' action='upload.php' method='post' name='upload_form'>
<table width='90%' border='0' align='center' style='width: 90%;'>
<tr>
<td>
Select Category
<select name='category'>
<?php while( $row = mysql_fetch_array( $result ) )
{
?>
<option value="<?php echo $row['category_id']; ?>"><?php echo $row['category_name']; ?></option>
<?php } //end of while?>
</select>
</td>
</tr>
<tr>
<td>
<p> </p>
</td>
</tr>
<?php while( $counter <= $number_of_fields) { ?>
<tr>
<td>
Photo {<?php echo $counter; ?>}
<input name="photo_filename[]" type="file" />
</td>
</tr>
<tr>
<td>
Caption:
<textarea name='photo_caption[]' cols='30' rows='1'></textarea>
</td>
</tr>
<?php $counter++; } ?>
<tr>
<td>
<input type='submit' name='submit' value='Add Photos' />
</td>
</tr>
</table>
</form>
<?php } //end of if?>
</body>
</html>
<?php
mysql_free_result( $result );
?>
So if anybody can please help me solve this problem that I keep having
Talguy