Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query problem 1

Status
Not open for further replies.

frozenpeas

Technical User
Sep 13, 2001
893
CA
Hello,

For the life of me, I cannot get this to work. Can anyone see what is wrong?

Code:
<?php
require_once('connections/connect.php');
mysql_select_db($database_connect,$connect);
$query = "SELECT * FROM hectik ORDER BY date DESC,id";
$myQuery = mysql_query($query) or die("Could not query database. ".mysql_error().'. ('.mysql_errno().')');
while($row = mysql_fetch_assoc($myQuery)){
	echo "test";
}
?>

or

Code:
<?php
require_once('connections/connect.php');
mysql_select_db($database_connect, $connect);
$query = "SELECT * FROM hectik ORDER BY date DESC,id";
$myQuery = mysql_query($query) or die("Could not query database. ".mysql_error().'. ('.mysql_errno().')');
while($row = mysql_fetch_array($myQuery)){
	echo "test";
}
?>

Both of these result in:

Could not query database. No Database Selected. (1046)

Variable values are good, paths are good, database and table are there and contain data.

Any ideas? Thanks.

frozenpeas
--
Micfo.com Affiliate Program
 
Add an "or die" clause on to the mysql_select_db() function:
Code:
mysql_select_db($database_connect,$connect) or die('Could not select database<br>'.mysql_error());
and see what you get.

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top