Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Ok I have made the change and added the semicolon after the require_once
statement.
When I run the program, I get the header section of the page, and the
background turns grey. But I never get any output from the rest of the code.
As far as the rest of the changes, I am still up against the wall.
Here is what the code looks like at the moment.
The code is still not pulling anything from the database that I have set up.
If I go into MySQL from the console, connect to the database, I can see the
results. Example below.
Again thanks for all of the help!
Mike
--------------------------------------------------------------------------------------------------------
EMAIL:PROTECTED:~> mysql -p -u sampadm sampdb
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.10a
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select count(*) from member;
+----------+
| count(*) |
+----------+
| 102 |
+----------+
1 row in set (0.05 sec)
mysql>
--------------------------------------------------------------------------------------------------------
<html>
<head>
<title>U.S. Historical League</title>
</head>
<body bgcolor="white">
<p>Welcome to the U.S. Historical League Web Site.</p>
<?php
# USHL home page - version 2
require_once "/usr/share/php/DB.php";
require_once "/home/mike/sampdb/phpapi/sampdb.php";
#@ _DB_CONNECT_
$conn =& DB::connect (sampdb_dsn ());
if (DB::isError ($conn))
exit ();
#@ _DB_CONNECT_
$result =& $conn->query ("SELECT COUNT(*) FROM member");
if (DB::isError ($result))
exit ();
if ($row =& $result->fetchRow ())
print ("<p>The League currently has " . $row[0] . " members.</p>");
$result->free ();
$conn->disconnect ();
?>
</body>
</html>
-------------------------------------------------------------------------------------------------------
I included a file called sampdb.php. Here is that file...
---------------------------------------------------------------------------------------------------------
<?php
#@ _COMMENT_
# sampdb.php - common functions for sampdb PHP scripts
#@ _COMMENT_
#@ _SAMPDB_DSN_
# Retrieve the data source name for connecting to the MySQL server and
# selecting the sampdb database using our top-secret name and password
# To use the original MySQL module, $driver should be "mysql".
# To use the "MySQL improved" module, $driver should be "mysqli".
function sampdb_dsn ()
{
$driver = "mysql";
$host_name = "localhost";
$user_name = "sampadm";
$password = "secret";
$db_name = "sampdb";
return ("$driver://$user_name:EMAIL:PROTECTED");
}
#@ _SAMPDB_DSN_
# Put out initial HTML tags for page. $title and $header, if
# present, are assumed to have any special characters properly
# encoded.
#@ _HTML_BEGIN_
function html_begin ($title, $header)
{
print ("<html>\n");
print ("<head>\n");
if ($title != "")
print ("<title>$title</title>\n");
print ("</head>\n");
print ("<body bgcolor=\"white\">\n");
if ($header != "")
print ("<h2>$header</h2>\n");
}
#@ _HTML_BEGIN_
# put out final HTML tags for page.
#@ _HTML_END_
function html_end ()
{
print ("</body></html>\n");
}
#@ _HTML_END_
# Generate Web form elements. Arguments that become part of the
# content of the element are automatically HTML-encoded.
# Print hidden field
#@ _HIDDEN_FIELD_
function hidden_field ($name, $value)
{
printf ("<input type=\"%s\" name=\"%s\" value=\"%s\" />\n",
"hidden",
htmlspecialchars ($name),
htmlspecialchars ($value));
}
#@ _HIDDEN_FIELD_
# Print editable text entry field
#@ _TEXT_FIELD_
function text_field ($name, $value, $size)
{
printf ("<input type=\"%s\" name=\"%s\" value=\"%s\" size=\"%s\" />\n",
"text",
htmlspecialchars ($name),
htmlspecialchars ($value),
htmlspecialchars ($size));
}
#@ _TEXT_FIELD_
# Print password entry field
function password_field ($name, $value, $size)
{
printf ("<input type=\"%s\" name=\"%s\" value=\"%s\" size=\"%s\" />\n",
"password",
htmlspecialchars ($name),
htmlspecialchars ($value),
htmlspecialchars ($size));
}
# Print radio button. $checked should be true if the box should be
# selected by default.
#@ _RADIO_BUTTON_
function radio_button ($name, $value, $label, $checked)
{
printf ("<input type=\"%s\" name=\"%s\" value=\"%s\"%s />%s\n",
"radio",
htmlspecialchars ($name),
htmlspecialchars ($value),
($checked ? " checked=\"checked\"" : ""),
htmlspecialchars ($label));
}
#@ _RADIO_BUTTON_
# Print form submission button
#@ _SUBMIT_BUTTON_
function submit_button ($name, $value)
{
printf ("<input type=\"%s\" name=\"%s\" value=\"%s\" />\n",
"submit",
htmlspecialchars ($name),
htmlspecialchars ($value));
}
#@ _SUBMIT_BUTTON_
# script_param() extracts an input parameter from the script execution
# environment. It uses the $_GET and $_POST arrays if they are available,
# and the $HTTP_GET_VARS and $HTTP_POST_VARS arrays if they are not.
# If extra backslashes were added due to magic_quotes_gpc being
# enabled, it strips them using the remove_backslashes() function.
# track_vars is assumed to be enabled, but nothing is assumed about
# magic_quotes_gpc, and the function does not require register_globals to
# be enabled.
# remove_backslashes() takes into account whether the value is a scalar or
# an array. It is recursive in case you create a form that takes advantage
# of the ability to created nested input parameters in PHP 4 and up.
#@ _REMOVE_BACKSLASHES_
function remove_backslashes ($val)
{
if (!is_array ($val))
$val = stripslashes ($val);
else
{
reset ($val);
while (list ($k, $v) = each ($val))
$val[$k] = remove_backslashes ($v);
}
return ($val);
}
#@ _REMOVE_BACKSLASHES_
#@ _SCRIPT_PARAM_
function script_param ($name)
{
global $HTTP_GET_VARS, $HTTP_POST_VARS;
unset ($val);
if (isset ($_GET[$name]))
$val = $_GET[$name];
else if (isset ($_POST[$name]))
$val = $_POST[$name];
else if (isset ($HTTP_GET_VARS[$name]))
$val = $HTTP_GET_VARS[$name];
else if (isset ($HTTP_POST_VARS[$name]))
$val = $HTTP_POST_VARS[$name];
if (isset ($val) && get_magic_quotes_gpc ())
$val = remove_backslashes ($val);
# return @$val rather than $val to prevent "undefined value"
# messages in case $val is unset and warnings are enabled
return (@$val);
}
#@ _SCRIPT_PARAM_
# Return the pathname of the current script. The function tries the
# $_SERVER superglobal array and the $HTTP_SERVER_VARS global array.
#@ _SCRIPT_NAME_
function script_name ()
{
global $HTTP_SERVER_VARS;
if (isset ($_SERVER["PHP_SELF"]))
return ($_SERVER["PHP_SELF"]);
return ($HTTP_SERVER_VARS["PHP_SELF"]);
}
#@ _SCRIPT_NAME_
?>
--------------------------------------------------------------------------------------------------------
On Tuesday 28 March 2006 4:56 pm, Scott Hussey wrote:
> I'm not a PHP coder, but a T_Variable seems to be the token for a
> variable in the php grammar. I would guess the $conn is not expected
> because you didn't end the previous line with a semi-colon. But this
> is just a guess.
>
> scott
>
> > The program that I am attempting to run is:
> >
> > <html>
> > <head>
> > <title>U.S. Historical League</title>
> > </head>
> > <body bgcolor="grey">
> > <p>Welsome to the U.S. Historical League Web Site.</p>
> > <?php
> > # USHL home page
> >
> > require_once "/usr/share/php/DB.php"
> >
> > $conn =& DB::connect ("mysql://sampadm:EMAIL:PROTECTED");
> > if (DB::isError ($conn))
> > exit ();
> > $result =& $conn->query ("SELECT COUNT(*) FROM member");
> > if (DB::isError ($result))
> > exit ();
> > if ($row =& $result->fetchrow ())
> > print ("<p>The League currently has " . $row[0] . "
> > members.</p>"); $result->free ();
> > $conn->disconnect ();
> > ?>
> > </body>
> > </html>
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members