/    Sign up×
Community /Pin to ProfileBookmark

What’s wrong with this code……

Hi there,

I’m going over PHP and MYSQL for dummies, and I’m relative new to this server language, anyway, please see below the code, it’s not displaying the results, I would really appreciate any help regarding this matter…….

[quote]

<?php
/*Program: Victory Health display.php
*
/
?>
<html>
<head><title>Victory</title></head>
<body>
<?php
$user=””;
$host=””;
$password=””;
$database=”test”;
$connection = mysql_connect($host,$user,$password)
or die (“couldn’t connect to server”);
$db = mysql_selectdb($database,$connection)
or die (“Couldn’t connect to server”);
$query = “SELECT * FROM tblWebData LIMIT 0, 30″;
$result = mysql_query($query)
or die(“Couldn’t execute query.”);
/*
Display results in a table */
echo “<table cellspacing=’11’>”;
echo “<tr><td colspan=’1′><hr></td></tr>”;
while ($row = mysql_fetch_array($result))
{
extract($row);
echo “<tr>n
<td>$AgencyName</td>n
<td>$DescriptionofAgency</td>n
<td align=’right’></td>n
</tr>n”;
echo “<tr><td colspan=’1′><hr></td></tr>n”;

}
echo “</table>n”;
?>
</body></html>

[/quote]

Thanks and God Bless…..

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 24.2007 — Do you get any error messages at all? If not, you might try adding the following lines at the start of your script, so that all run-time errors, warnings and notices are displayed:
[code=php]
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
[/code]
Copy linkTweet thisAlerts:
@tcaMar 24.2007 — [code=php]
<?php
/*Program: Victory Health display.php
*/
?>
<html>
<head><title>Victory</title></head>
<body>
<?php
$user="";
$host="";
$password="";
$database="test";
$connection = mysql_connect($host,$user,$password) or die ("couldn't connect to server");
$db = mysql_selectdb($database,$connection) or die ("Couldn't connect to server");
$query = "SELECT * FROM tblWebData LIMIT 0, 30";
$result = mysql_query($query) or die("Couldn't execute query.");
/*Display results in a table */
echo "<table cellspacing='11'>";
echo "<tr><td><hr></td></tr>";
while ($row = mysql_fetch_array($result))
{

echo "<tr><br /><td>{$row['AgencyName']}</td><br />";
echo "<td>{$row['DescriptionofAgency']}</td><br />";
echo "<td align='right'></td><br /></tr><br />";
echo "<tr><td ><hr></td></tr><br />";

}
echo "</table><br />";
?>
</body></html>
[/code]
Copy linkTweet thisAlerts:
@luke2125authorMar 24.2007 — tca and nogdog,

I get the following error, after placing the code from tca....

Notice: Undefined index: AgencyName in /var/www/html/samples.php on line 25



Notice: Undefined index: DescriptionofAgency in /var/www/html/samples.php on line 26
[/quote]


Thanks for the help and God Bless....
Copy linkTweet thisAlerts:
@NogDogMar 24.2007 — Make sure those array indexes exactly match the column names in the table being queried (including upper-/lower-case letters).
Copy linkTweet thisAlerts:
@luke2125authorMar 24.2007 — Yes I checked those indexes against my column names, but they are the same.....Any thoughts? Thanks and God Bless...
Copy linkTweet thisAlerts:
@luke2125authorMar 24.2007 — Crazy me, I had to scroll lower....Thanks folks and God Bless....
×

Success!

Help @luke2125 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...