MySQL Error: No Database Selected
Moderator: General Moderators
MySQL Error: No Database Selected
I am new to php, but have been getting the hang of it. That is until today, when it left me heartbroken.
I am building a photogallery to add to a site i have built. The cms component where users upload images seems to work fine.
However, the public page is supposed to work like such,
-- Page check to see if the category variable is set in the query string
-- If yes
-----Select all photo information from the photos table, where its foreign key category matches the variable value in the query string.
-----Show all photos, it sends the file path to phpThumb.php for thumbnailing.
(it has not been set up properly for this yes function yet)
-- If no
-----Select all categories (or events) and show a single thumbnailed photo from each, which is also a link to "zoom" into that category. ie Link back to itself with the category variable set.
(this should be working)
However, when i go to the page its like flipping a coin, heads it will show me the gallery and tails it will read as such:
MySQL Error: No Database Selected
There is a lot of lines of code, and different files so its very hard to know what to display here.
The page in question is http://www.keenan.net.au/hmm.php
Will you get a page, or an error? I have no idea, but if you press f5 a couple of times you will get both instances.
Thanks heaps in advance
I am building a photogallery to add to a site i have built. The cms component where users upload images seems to work fine.
However, the public page is supposed to work like such,
-- Page check to see if the category variable is set in the query string
-- If yes
-----Select all photo information from the photos table, where its foreign key category matches the variable value in the query string.
-----Show all photos, it sends the file path to phpThumb.php for thumbnailing.
(it has not been set up properly for this yes function yet)
-- If no
-----Select all categories (or events) and show a single thumbnailed photo from each, which is also a link to "zoom" into that category. ie Link back to itself with the category variable set.
(this should be working)
However, when i go to the page its like flipping a coin, heads it will show me the gallery and tails it will read as such:
MySQL Error: No Database Selected
There is a lot of lines of code, and different files so its very hard to know what to display here.
The page in question is http://www.keenan.net.au/hmm.php
Will you get a page, or an error? I have no idea, but if you press f5 a couple of times you will get both instances.
Thanks heaps in advance
It's messy, sorry.
Code: Select all
<?php require_once('Connections/keenandb.php'); ?>
<?php include('header.php') ?>
<?php $catp = $_GET['cat']; ?>
<?php if(isset($catp)) { ?>
<?php
mysql_select_db($database_keenandb, $keenandb);
$query_photocat = "SELECT * FROM photocat WHERE pcatid = $catp ";
$photocat = mysql_query($query_photocat, $keenandb) or die(mysql_error());
$row_photocat = mysql_fetch_assoc($photocat);
$totalRows_photocat = mysql_num_rows($photocat);
?>
<?php echo $row_photocat['title']; ?>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<?php $counter = 0; do { ?>
<td><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="phpThumb.php?src=Files/Photo/<?php echo $row_photos['path'] ?>&w=200"></td>
</tr>
</table></td>
<?php $counter = $counter + 1 ; if( $counter == $totalrows_photos) echo "</tr><tr>"; elseif($counter % 3 == 0) echo "</tr><tr>" ; ?>
<?php } while ($row_photocat = mysql_fetch_assoc($photos)); ?>
</table>
<?php } else { ?>
<?php
mysql_select_db($database_keenandb, $keenandb);
$query_photocat = "SELECT * FROM photocat ORDER BY title ASC";
$photocat = mysql_query($query_photocat, $keenandb) or die(mysql_error());
$row_photocat = mysql_fetch_assoc($photocat);
$totalRows_photocat = mysql_num_rows($photocat);
?>
<p class="inthenewssummaries">copy</p>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<?php $counter = 0; do { ?>
<?php
$pcatid = $row_photocat['pcatid'];
mysql_select_db($database_keenandb, $keenandb);
$query_photos = "SELECT * FROM photos WHERE pcatid = $pcatid ORDER BY pid ASC";
$photos = mysql_query($query_photos, $keenandb) or die(mysql_error());
$row_photos = mysql_fetch_assoc($photos);
$totalRows_photos = mysql_num_rows($photos);
?>
<td><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="hmm.php?cat=<?php echo $row_photocat['pcatid'] ?>"><img src="phpThumb.php?src=Files/Photo/<?php echo $row_photos['path'] ?>&w=200" border="0"></a></td>
</tr>
<tr>
<td height="30" bgcolor="#000066"><div align="center" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold"><span style="color: #FFFFFF"><span style="color: #FFFFFF"><?php echo $row_photocat['title'] ?></span></span></div></td>
</tr>
</table></td>
<?php $counter = $counter + 1 ; if( $counter == $totalrows_photocat) echo "</tr><tr>"; elseif($counter % 3 == 0) echo "</tr><tr>" ; ?>
<?php } while ($row_photocat = mysql_fetch_assoc($photocat)); ?>
</table>
<?php } ?>
<?php include('footer.php') ?>definitely remove the mulitple instances of it.
you also might try having it throw an error if it fails:
you also might try having it throw an error if it fails:
Code: Select all
mysql_select_db($database_keenandb, $keenandb)
or die(mysql_error());was it working locally before? Are the databases named / setup exactly the same? Are you sure the user has rights to the db on the server?
I would assume the answer to all of those is yes as it is working sporadically before.
I'm fresh out of ideas, you might try calling your provider and letting them know the scoop, it could be something on their end...
I would assume the answer to all of those is yes as it is working sporadically before.
I'm fresh out of ideas, you might try calling your provider and letting them know the scoop, it could be something on their end...