Page 1 of 1

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

Posted: Tue Nov 26, 2002 10:05 am
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

Posted: Tue Nov 26, 2002 10:09 am
by twigletmac
Just to check, is the webserver setup to parse .html files as PHP files?

Mac

Posted: Tue Nov 26, 2002 10:22 am
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.

Posted: Tue Nov 26, 2002 3:28 pm
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!

Posted: Wed Nov 27, 2002 5:11 am
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

Posted: Wed Nov 27, 2002 2:54 pm
by unsigned
grr... yeah, I found it. I did manage to get the first part working. Sooo, thanks for all your help!

Posted: Wed Nov 27, 2002 6:53 pm
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: