n00b here, I'm having trouble with this code fragment...

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
unsigned
Forum Newbie
Posts: 3
Joined: Tue Nov 26, 2002 10:05 am

n00b here, I'm having trouble with this code fragment...

Post by unsigned »

I think I'm trying to run before I walk, but here goes...

I'm querying a MySQL DB via an .html page. I can connect, and the query is good, but the form drop downs are filled with the query code. It's like I'm missing a parens somewhere. Here is the code:

MYSQL_CONNECT(x.x.x.x, somename, somepass) OR DIE("Unable to connect to the database");
@mysql_select_db("syslogd") or die("Unable to select database");

<table>
<tr>

<?
echo "<td><b>Router</b> <select name=host>;
$xxx = "no data!";

$val = mysql_query("SELECT DISTINCT MsgHostname from syslogd");
echo "<option>*\n";
while ($row = mysql_fetch_array($val))

{
$host=$ow["MsgHostname"];
echo "<option>".$host."\n";
}
echo "</select>\n";
?>

</tr>
---------------

The drop downs are filled with the code starting here:*\n";while ($row = mysql_fetch....



Thanks!!!!!


R
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Just to check, is the webserver setup to parse .html files as PHP files?

Mac
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post by oldtimer »

If they are set up to take html files as php then should appear with the correct values. However if they are not then you would see what you see. Try renameing the page as a .php and see what happens. That is the quickest way.
unsigned
Forum Newbie
Posts: 3
Joined: Tue Nov 26, 2002 10:05 am

Post by unsigned »

Wow, you guys are good! I was "sure" that it was configured properly. I needed to do a few more steps.

But... Now, it is giving me this:

Parse error: parse error, expecting `','' or `';'' in /home/httpd/html/syslogstat/index.html on line 17


Line 17 is this one: $xxx = "no data!";


I've tried sever things, and cannot seem to locate it in the docs. Can you guys work you magic one more time? What do I need to do?

THANKS!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

The error is actually occuring on the line above:

Code: Select all

echo "&lt;td&gt;&lt;b&gt;Router&lt;/b&gt; &lt;select name=host&gt;;
You're missing a closing quote on the string, try:

Code: Select all

echo '&lt;td&gt;&lt;b&gt;Router&lt;/b&gt; &lt;select name="host"&gt;';
Mac
unsigned
Forum Newbie
Posts: 3
Joined: Tue Nov 26, 2002 10:05 am

Post by unsigned »

grr... yeah, I found it. I did manage to get the first part working. Sooo, thanks for all your help!
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I hated that when i was a newbie. PHP would pick up the parsing error a few lines or so after it happened so you go crazy seeing what you did wrong when it was just a few lines up. How frustrating. :wink:
Post Reply