begginers question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bruisedghost
Forum Newbie
Posts: 16
Joined: Wed Jan 21, 2009 12:15 am

begginers question

Post 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();
?>
 
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: begginers question

Post 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?
bruisedghost
Forum Newbie
Posts: 16
Joined: Wed Jan 21, 2009 12:15 am

Re: begginers question

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: begginers question

Post 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.
bruisedghost
Forum Newbie
Posts: 16
Joined: Wed Jan 21, 2009 12:15 am

Re: begginers question

Post by bruisedghost »

never mind, computer needed a restart, for some reason apache was being effected


Thanks!
Post Reply