Page 1 of 1

begginers question

Posted: Wed Jan 21, 2009 12:19 am
by bruisedghost
Hi all, I am trying to display the results of a SQL query and for some reason nothing is being returned, this is driving me nuts but as I am fairly new to PHP im sure its something simple

here is my code, I hve omitted the username and password but I know that they are correct.

Code: Select all

<?php
$Host="localhost"; 
$Username=""; 
$Password=""; 
$DBName="welladorned"; 
$TableName="Simplified Spreadsheet"; 
 
$link = mysql_connect ($Host, $Username, $Password) or die('Could not connect: ' . mysql_error());
mysql_select_db($DBName) or die('Could not select database');
 
 
$query="SELECT `Product Code` FROM `Simplified Spreadsheet' GROUP BY `Product Code` ORDER BY `Product Code` LIMIT 0 , 30";
$result=mysql_query($query);
if (!result){
    die ("Could not query the database: <br />". mysql_error());
}
 
array mysql_fetch_row ( resource $result);
 
 
mysql_close();
?>
 

Re: begginers question

Posted: Wed Jan 21, 2009 12:30 am
by requinix

Code: Select all

array mysql_fetch_row ( resource $result);
Looks like you just copied that from the online manual. Have you tried copying from the example instead?

Anyways,

Code: Select all

$row = mysql_fetch_row($result);
print_r($row);
$row is an array, $result is a resource. Make sense?

Re: begginers question

Posted: Wed Jan 21, 2009 12:39 am
by bruisedghost
tasairis wrote:

Code: Select all

array mysql_fetch_row ( resource $result);
Looks like you just copied that from the online manual. Have you tried copying from the example instead?

Anyways,

Code: Select all

$row = mysql_fetch_row($result);
print_r($row);
$row is an array, $result is a resource. Make sense?

I have tried that among other things, the problem is that quite literally nothing is showing up whatsoever even when I change the mysql connection variables to something that I know is not correct I am not getting a cannot connect return. I have tried to restart apache. I even tried to add in a simple echo of text and that is not appearing.

Re: begginers question

Posted: Wed Jan 21, 2009 12:45 am
by requinix
View the HTML source of the page. If you see your PHP code then you haven't installed PHP right.

There are instructions online or you can use something like WAMP.

Re: begginers question

Posted: Wed Jan 21, 2009 12:49 am
by bruisedghost
never mind, computer needed a restart, for some reason apache was being effected


Thanks!