PDA

View Full Version : I feel so dead. What does this error mean?


Doggonit
08-31-2005, 11:26 PM
I am running the following script:

<HTML>
<HEAD>
<TITLE>Today's Date</TITLE>
</HEAD>

<BODY>

<P>Edit, update, delete, finalize all data.


<?php
require_once('DataBaseCon.php');
mysql_select_db($database_Con,$db);

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$_var_message = "Select a Record or Add a New Record";
// process form - SQL to Insert a new record
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form3")) {
$db = mysql_connect("localhost", "root", "mycroft");
mysql_select_db("test",$db);
$sql = sprintf("INSERT INTO employees (first,last,address,position) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['first'], "text"),
GetSQLValueString($_POST['last'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['position'], "text"));
$result = mysql_query($sql);
$_var_message = "Thank you! Information has been Added.";
}
// process form - SQL to Update a record
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
$sql = sprintf("UPDATE employees SET first=%s, last=%s, address=%s, position=%s WHERE id=%s",
GetSQLValueString($_POST['first'], "text"),
GetSQLValueString($_POST['last'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['id'], "int"));
$result = mysql_query($sql);
$_var_message = "Thank you! Information has been Updated.";
}
// process form - SQL to Delete a record
if ((isset($_REQUEST["delete"])) && ($_REQUEST["delete"] == "yes")) {
// delete a record
$id=$_GET['recordID'];
$sql = "DELETE FROM employees WHERE id=$id";
$result = mysql_query($sql);
$_var_message = "Thank you! Information has been Deleted.";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="mssmarttagspreventparsing" content="true" />
<meta name="Description" content=" " />
<meta name="Keywords" content=" " />
<meta name="distribution" content="global" />
<meta name="resource-type" content="document" />
<meta name="robots" content="all" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="Author" content="Jim Miller" />
<meta name="Copyright" content="2000, Ridley Inc." />
<meta name="Revised" content="Jim Miller, 01/07/2005" />
<meta name="Expires" content="never" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>// SITE NAME // HOME PAGE. //</title>
<link rel="stylesheet" type="text/css" href="stylesheets/default.css" />
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
<style type="text/css">
<!--
body {
margin: 20px;
min-width:590px;
text-align: center;
}
#main {
width:590px;
background:#fff;
text-align: left;
border: 1px dashed #778899;
}
.style1 {color: #993300}
-->
</style>
</head>
<body>
<div id="main">
<div align="center"><h1>Record Maint Section</h1></div>
<table width="100%" border="1" align="center">
<?php
// Edit Record
if ((isset($_REQUEST["edit"])) && ($_REQUEST["edit"] == "yes")) {
// query the DB
$id=$_GET['recordID'];
$sql = "SELECT * FROM employees WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$_var_message = "Edit Record";
echo '<tr><td colspan="2" class="style1">'.$_var_message.'</td></tr>';
echo '<form method="post" name="form2" action="'.$_SERVER['PHP_SELF'].'">';
echo '<tr><td>First name: </td><td><input type="Text" name="first" value="'.$myrow['first'].'"></td></tr>';
echo '<tr><td>Last name: </td><td><input type="Text" name="last" value="'.$myrow['last'].'"></td></tr>';
echo '<tr><td>Address: </td><td><input type="Text" name="address" value="'.$myrow['address'].'"></td></tr>';
echo '<tr><td>Position: </td><td><input type="Text" name="position" value="'.$myrow['position'].'"></td></tr>';
echo '<tr><td colspan="2">&nbsp;</td></tr>';
echo '<tr><td><input type="submit" name="submit" value="Submit"></td>';
echo '<td><input type="button" value="Return to Select" onclick="location.href=\'' .$_SERVER['PHP_SELF']. '\'" /></td></tr>';
echo '<input type=hidden name="id" value="'.$myrow['id'].'">';
echo '<input type="hidden" name="MM_update" value="form2">';
echo '</form>';
// Add Record
} elseif ((isset($_REQUEST["add"])) && ($_REQUEST["add"] == "yes")) {
$_var_message = "Add a New Record";
echo '<tr><td colspan="2" class="style1">'.$_var_message.'</td></tr>';
echo '<form method="post" name="form3" action="'.$_SERVER['PHP_SELF'].'">';
echo '<tr><td>First name: </td><td><input type="Text" name="first"></td></tr>';
echo '<tr><td>Last name: </td><td><input type="Text" name="last"></td></tr>';
echo '<tr><td>Address: </td><td><input type="Text" name="address"></td></tr>';
echo '<tr><td>Position: </td><td><input type="Text" name="position"></td></tr>';
echo '<tr><td colspan="2">&nbsp;</td></tr>';
echo '<tr><td><input type="submit" name="submit" value="Submit"></td>';
echo '<td><input type="button" value="Return to Select" onclick="location.href=\'' .$_SERVER['PHP_SELF']. '\'" /></td></tr>';
echo '<input type="hidden" name="MM_insert" value="form3">';
echo '</form>';
// Display Record
} elseif ((isset($_REQUEST["display"])) && ($_REQUEST["display"] == "yes")) {
$_var_message = "Record Display";
$id = $_GET['recordID'];
$result = mysql_query("SELECT * FROM employees WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
echo '<tr><td colspan="2" class="style1">'.$_var_message.'</td></tr>';
echo '<form>';
echo '<tr><td>First Name: </td><td>'.$myrow['first'].'</td></tr>';
echo '<tr><td>Last Name: </td><td>'.$myrow['last'].'</td></tr>';
echo '<tr><td>Address: </td><td>'.$myrow['address'].'</td></tr>';
echo '<tr><td>Position: </td><td>'.$myrow['position'].'</td></tr>';
echo '<tr><td colspan="2">&nbsp;</td></tr>';
echo '<tr>';
echo '<td><input type="button" value="Edit Record" onclick="location.href=\''.$_SERVER['PHP_SELF'].'?recordID='.$myrow['id'].'&edit=yes\'" /></td>';
echo '<td><input type="button" value="Return to Select" onclick="location.href=\'' .$_SERVER['PHP_SELF']. '\'" /></td>';
echo '</tr>';
echo '</form>';
// Show Record List (Selecttion Page)
} else {
$result = mysql_query("SELECT * FROM employees",$db);
if ($myrow = mysql_fetch_array($result)) {
// display list if there are records to display
echo '<tr><td colspan="6" class="style1">'.$_var_message.'</td></tr>';
echo '<tr>';
echo '<td colspan="3">';
echo '<div align="center"><input type="button" value="ADD New Record" onclick="location.href=\'' . $_SERVER['PHP_SELF'] . '?add=yes\'" /></div>';
echo '</td>';
echo '<td>First Name</td>';
echo '<td>Last Name</td>';
echo '<td>Record ID</td>';
echo '</tr>';
do {
echo '<tr>';
echo '<form name="form9" action="" method="post">';
echo '<td><input type="button" value="Edit" onclick="location.href=\''.$_SERVER['PHP_SELF'].'?recordID='.$myrow['id'].'&edit=yes\'" /></td>';
echo '<td><input type="submit" onclick="this.form.action=\''.$_SERVER['PHP_SELF'].'?recordID='.$myrow['id'].'&delete=yes\';return confirm(\'Are you sure you want to delete this record\')" value="Delete" name="del" /></td>';
echo '<td><input type="button" value="Display" onclick="location.href=\''.$_SERVER['PHP_SELF'].'?recordID='.$myrow['id'].'&display=yes\'" /></td>';
echo '<td>'.$myrow['first'].'</td>';
echo '<td>'.$myrow['last'].'</td>';
echo '<td>'.$myrow['id'].'</td>';
echo '</tr>';
} while ($myrow = mysql_fetch_array($result));
echo '</form>';
} else {
// no records to display
echo "Sorry, no records were found!";
}
}
?>
</table>
</div>
</body>
</html>
<?php
mysql_close($db);
?>

</BODY>

</HTML>

And there is also this script:

<?php
# FileName="DataBaseCon.php"
# Type="MYSQL"
$hostname_Con = "localhost";
$database_Con = "pending";
$username_Con = "XXXXXXXXXX";
$password_Con = "XXXXXXXXXX";
$db = mysql_connect($hostname_Con, $username_Con, $password_Con) or die(mysql_error());
?>

And all I am getting in return is this:

Edit, update, delete, finalize all data.

Record Maint Section
'; echo '
'; echo ' First name:
'; echo ' Last name:
'; echo ' Address:
'; echo ' Position:
'; echo '
'; echo ' '; echo '
'; echo ''; echo ''; echo '
'; // Add Record } elseif ((isset($_REQUEST["add"])) && ($_REQUEST["add"] == "yes")) { $_var_message = "Add a New Record"; echo ' '.$_var_message.'
'; echo '
'; echo ' First name:
'; echo ' Last name:
'; echo ' Address:
'; echo ' Position:
'; echo '
'; echo ' '; echo '
'; echo ''; echo '
'; // Display Record } elseif ((isset($_REQUEST["display"])) && ($_REQUEST["display"] == "yes")) { $_var_message = "Record Display"; $id = $_GET['recordID']; $result = mysql_query("SELECT * FROM employees WHERE id=$id",$db); $myrow = mysql_fetch_array($result); echo ' '.$_var_message.'
'; echo '
'; echo ' First Name: '.$myrow['first'].'
'; echo ' Last Name: '.$myrow['last'].'
'; echo ' Address: '.$myrow['address'].'
'; echo ' Position: '.$myrow['position'].'
'; echo '
'; echo ' '; echo ' '; echo ' '; echo '
'; echo '
'; // Show Record List (Selecttion Page) } else { $result = mysql_query("SELECT * FROM employees",$db); if ($myrow = mysql_fetch_array($result)) { // display list if there are records to display echo ' '.$_var_message.'
'; echo ' '; echo ' '; echo '

'; echo ' '; echo ' First Name '; echo ' Last Name '; echo ' Record ID '; echo '
'; do { echo ' '; echo '
'; echo ' '; echo ' '; echo ' '; echo ' '.$myrow['first'].' '; echo ' '.$myrow['last'].' '; echo ' '.$myrow['id'].' '; echo '
'; } while ($myrow = mysql_fetch_array($result)); echo '
'; } else { // no records to display echo "Sorry, no records were found!"; } } ?>

What the hell?

Doggonit
08-31-2005, 11:26 PM
I also tried this script:

<?php_track_vars?>
<?
# $Header: /usr/local/www/docs/lorentz.com/RCS/mysql.php3,v 1.24 1998/07/28 15:04:13 franklin Exp $
#
# Author: Jack McKinney jackmc@lorentz.com
#
# You may redistribute this as long as you leave this attribution in.
#
# This script accepts a hostname and database name from the user and then
# uses HTTP basic authentication to get a username and password from the
# user. It tries to connect to the named mysql database on the named host
# using the supplied username and password. If it fails, it prompts the
# user for a new username and password.
#
# Once successful, the script queries the database for all tables, and then
# queries each table for all fields. It outputs a form that has a section
# each each table listing each field.
#
# The user can then fill in some or all of the fields, and press one of three
# supplied buttons, SELECT, INSERT, DELETE, to take an appropriate action.
# In using SELECT, there are several special options:
#
# If the value supplied is prefixed by an <, =, >, or ~, then that specific
# comparison is used instead of the default = (~ becomes LIKE).
#
# If the value begins with a '$', the remainder is taken as a field name
# in this or another table (i.e., it is not quoted), so that an inner join or
# self-join can be performed.
#
# FUTURE
#
# - Limit number of results returned per page.
# - Have option to show query as well as results.
# - Have option to not perform query (i.e., use above option to preview first)
# - Have option to enter own query in a TEXTAREA (preferably combined with
# previous option: display query in a TEXTAREA for editing).
# - Ability to click on a record and have the original form displayed with
# this data filled in (for updates and future inserts).
# - Add UPDATE. Hmmm... tricky, tricky, tricky.
# - Add a create table interface (probably in a second script).
# - Add a place to type in special expressions to select (e.g.,
# ROOM.LENGTH*ROOM.WIDTH AS AREA)
#

function bad_auth()
{
global $database;
Header("WWW-authenticate: basic realm=\"Database ".$database."\"");
Header("HTTP/1.0 401 Unauthorized");
$title = "Invalid login";
echo "<HTML>\n";
echo " <HEAD>\n";
echo " <TITLE>Authorization Required</TITLE>\n";
echo " </HEAD>\n";
echo " <BODY BGCOLOR=#FFFFFF TEXT=#000000>\n";
echo " I need a username and password with which to access the database.<P>\n";
echo " </BODY>\n";
echo "</HTML>\n";
exit;
}

$database=$HTTP_POST_VARS["DATABASE"];
$hostname=$HTTP_POST_VARS["HOSTNAME"];
if(!$database)
{
?>
<HTML>
<HEAD>
<TITLE>MySQL/PHP Interface</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF TEXT=#000000>
<CENTER>
<FORM ACTION=<? echo $SCRIPT_NAME ?> METHOD=POST>
<TABLE>
<TR>
<TD>Hostname:</TD>
<TD><INPUT TYPE=TEXT NAME=HOSTNAME VALUE="localhost" SIZE=40>
</TR>
<TR>
<TD>Database:</TD>
<TD><INPUT TYPE=TEXT NAME=DATABASE SIZE=40>
</TR>
<TR>
<TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT NAME=SHOW VALUE=SHOW></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<?
exit;
}
if(!isset($PHP_AUTH_USER)) bad_auth();
$username = $PHP_AUTH_USER;
$password = $PHP_AUTH_PW;
$dblink = @mysql_pconnect($hostname,$username,$password);
if(!$dblink) bad_auth();
?>
<HTML>
<HEAD>
<TITLE><?echo "$database@$hostname"?></TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF TEXT=#000000>
<CENTER>
<H1><? echo "$database@$hostname" ?></H1>
<?
$tableh = mysql_list_tables($database);
if(!$tableh)
{

?>
Could not read list of tables
</CENTER>
</BODY>
</HTML>
<?
exit;
}
$tableno = mysql_num_rows($tableh);
if(!$tableno)
{
?>
MySQL claims this database is empty!
</CENTER>
</BODY>
</HTML>
<?
exit;
}
for($i=0;$i<$tableno;$i++)
{
$table = mysql_tablename($tableh,$i);
$fieldh = mysql_list_fields($database,$table);
$fieldno = mysql_num_fields($fieldh);
for($j=0;$j<$fieldno;$j++)
{
$name = mysql_field_name($fieldh,$j);
$tables[$table][$name]["type"] = mysql_field_type($fieldh,$j);
$tables[$table][$name]["len"] = mysql_field_len($fieldh,$j);
}
mysql_free_result($fieldh);
}
mysql_free_result($tableh);
if($HTTP_POST_VARS["SELECT"]) $command = "SELECT";
if($HTTP_POST_VARS["INSERT"]) $command = "INSERT";
if($HTTP_POST_VARS["DELETE"]) $command = "DELETE";
if($command)
{
if(!mysql_select_db($database,$dblink))
{
$error = mysql_error($dblink);
?>
<H1><FONT COLOR=#0000AA>MySQL at <? echo $hostname ?> returned an error:</FONT></H1>
</CENTER>
<FONT COLOR=#DD0000>
<PRE>
<? echo $error ?>
</PRE>
</BODY>
</HTML>
<?
exit;
}
$parts = $HTTP_POST_VARS["PARTS"];
for($part=1;$part <= $parts;$part++)
{
$ftable = $HTTP_POST_VARS["TABLE".$part];
$ffield = $HTTP_POST_VARS["FIELD".$part];
$fdatum = $HTTP_POST_VARS["DATUM".$part];
$faction = $HTTP_POST_VARS["ACTION".$part];
if(strlen($fdatum))
{
$qdata[$ftable][$ffield] = $fdatum;
$kludge[$ftable] = $ftable;
if(ereg("^[$]([^$][^.]*).",$fdatum,$re) || ereg("^[<>=~] *[$]([^.]+).",$fdatum,$re))
$kludge[$re[1]] = $re[1];
}
$qaction[$ftable][$ffield] = $faction;
}

if($qdata)
{
$tablecount = count($kludge);
if($command == "SELECT")
{
for(reset($kludge);$stable = key($kludge);next($kludge))
{
$sfields = $qaction[$stable];
for(reset($sfields);$sfield = key($sfields);next($sfields))
{
$action = $sfields[$sfield];
if($tablecount > 1) $sfield = "$stable.$sfield";
if($action != "IGNORE" && $select) $select .= ",";
if($action == "SELECT") $select .= $sfield;
if($action == "DISTINCT") $select .= "DISTINCT $sfield";
if($action == "ORDERBY")
{
$select .= $sfield;
if($orderby) $orderby .= ",";
$orderby .= $sfield;
}
if($action == "SUM") $select .= "sum($sfield)";
if($action == "COUNT") $select .= "count($sfield)";
if($action == "AVG") $select .= "avg($sfield)";
if($action == "MIN") $select .= "min($sfield)";
if($action == "MAX") $select .= "max($sfield)";
}
}
}
if($command == "SELECT" || $command == "DELETE")
{
for(reset($qdata);$qtable = key($qdata);next($qdata))
{
if($command == "DELETE")
{
$from = $qtable;
$where = "";
}
$qfields = $qdata[$qtable];
for(reset($qfields);$qfield = key($qfields);next($qfields))
{
$cmp = "=";
$qdatum = $qfields[$qfield];
# ereg_replace("''","''''",$qdatum);
if(ereg("^([<>=~]) +(.*)",$qdatum,$re))
{
$cmp = $re[1];
if($cmp == "~") $cmp = "LIKE";
$qdatum = $re[2];
}
if($command == "SELECT" && ereg("^[$]([^$].*)",$qdatum,$re))
{
$qdatum = $re[1];
if($tablecount > 1 && !ereg("\.",$qdatum))
$qdatum = "$qtable.$qdatum";
}
else
if($tables[$qtable][$qfield]["type"] != "int")
{
$qdatum = "'$qdatum'";
}
if($tablecount > 1) $qfield = "$qtable.$qfield";
if($where) $where .= "\n AND ";
$where .= "$qfield $cmp $qdatum";
}
if($command == "DELETE")
$query .= "DELETE FROM $qtable WHERE $where\n\n";
}
if($command == "SELECT")
{
$from = join($kludge,",");
$query = "SELECT $select\nFROM $from\nWHERE $where\n";
if($orderby) $query .= "ORDER BY $orderby\n";
}
}
else if($command == "INSERT")
{
for(reset($qdata);$qtable = key($qdata);next($qdata))
{
$qfields = $qdata[$qtable];
for(reset($qfields);$qfield = key($qfields);next($qfields))
{
$qdatum = $qfields[$qfield];
if($tables[$qtable][$qfield]["type"] != "int")
$qdatum = "'$qdatum'";
if($columns) $columns .= ",";
$columns .= $qfield;
if($values) $values .= ",";
$values .= $qdatum;
}
$query .= "INSERT INTO $qtable ($columns)\nVALUES ($values)\n\n";
}
}
echo "<TABLE><TR><TD><PRE>$query</PRE></TD></TR></TABLE>\n";
$start = microtime();
$result = mysql_query($query,$dblink);
$end = microtime();
$start = explode(" ",$start);
$end = explode(" ",$end);
$interval = round(0.5 + 1000*($end[1]-$start[1] + $end[0]-$start[0]));
if(!$result)
{
$error = mysql_error($dblink);
?>
<H1><FONT COLOR=#0000AA>MySQL at <? echo $hostname ?> returned an error:</FONT></H1>
</CENTER>
<FONT COLOR=#DD0000>
<PRE>
<? echo $error ?>
</PRE>
</BODY>
</HTML>
<?
exit;
}
if($command == "SELECT")
{
$colno = mysql_num_fields($result);
$rowno = mysql_num_rows($result);
if($rowno != 1) $s = "s";
echo "<TABLE BORDER>\n <TR>\n";
echo " <TR><TD COLSPAN=$colno ALIGN=CENTER>$rowno result$s, $interval msec</TD></TR>\n";
for($i=0;$i<$colno;$i++)
{
$name = mysql_field_name($result,$i);
echo " <TD><B>$name</B></TD>\n";
}
echo " </TR>\n";
while($rowno--)
{
echo " <TR>\n";
$row = mysql_fetch_row($result);
for($i=0;$i<$colno;$i++)
{
$value = $row[$i];
if(!$value) $value = "&nbsp;";
echo " <TD>$value</TD>\n";
}
echo " </TR>\n";
}
echo "</TABLE>\n";
}
else
{
if($command == "INSERT") $action = "added";
if($command == "DELETE") $action = "deleted";
$rows = mysql_affected_rows($dblink);
$s = "s";
if($rows == 1) $s = "";
echo "$rows row$s $action, $interval msec";
}
}
?>
</CENTER>
</BODY>
</HTML>
<?
exit;
}
?>
<FORM ACTION=<? echo $SCRIPT_NAME ?> METHOD=POST>
<INPUT TYPE=HIDDEN NAME=DATABASE VALUE="<? echo $database ?>">
<INPUT TYPE=HIDDEN NAME=HOSTNAME VALUE="<? echo $hostname ?>">
<?
$parts = 0;
for(reset($tables);$table = key($tables);next($tables))
{
echo "<HR>\n";
echo "<TABLE>\n";
echo " <TR>\n";
echo " <TD COLSPAN=3 ALIGN=CENTER><B>$table</TD>\n";
echo " </TR>\n";
$fields = $tables[$table];
for(reset($fields); $field = key($fields); next($fields))
{
$type = $fields[$field]["type"];
$len = $fields[$field]["len"];
$parts++;
echo " <TR>\n";
echo " <TD>$field</TD>\n";
?>
<TD>
<SELECT NAME=ACTION<? echo $parts ?>>
<OPTION VALUE=SELECT SELECTED>Select
<OPTION VALUE=DISTINCT>Select Distinct
<OPTION VALUE=ORDERBY>Order By
<OPTION VALUE=SUM>sum()
<OPTION VALUE=COUNT>count()
<OPTION VALUE=AVG>avg()
<OPTION VALUE=MIN>min()
<OPTION VALUE=MAX>max()
<OPTION VALUE=IGNORE>Don't Select
</SELECT>
</TD>
<?
if($type == "int" || $type == "real")
{
$size=10;
$maxlength=40;
}
else if($type == "string")
{
$size = $len;
if($size > 40) $size = 40;
$maxlength = $len;
$type .= "[".$len."]";
}
echo " <TD>\n";
echo " <INPUT TYPE=HIDDEN NAME=FIELD$parts VALUE='$field'>\n";
echo " <INPUT TYPE=HIDDEN NAME=TABLE$parts VALUE='$table'>\n";
echo " <INPUT TYPE=TEXT NAME=DATUM$parts SIZE=$size MAXLENGTH=$maxlength>\n";
echo " </TD>\n";
echo " <TD><I>(".$type.")</I></TD>\n";
echo " </TR>\n";
}
echo " </TABLE>\n";
}
?>
<HR>
<TABLE>
<TR>
<TD><INPUT TYPE=SUBMIT NAME=SELECT VALUE="Select"></TD>
<TD><INPUT TYPE=SUBMIT NAME=INSERT VALUE="Insert"></TD>
<TD><INPUT TYPE=SUBMIT NAME=DELETE VALUE="Delete"></TD>
</TR>
</TABLE>
</CENTER>
<INPUT TYPE=HIDDEN NAME=PARTS VALUE=<? echo $parts ?>>
</FORM>
</BODY>
</HTML>

Which only gave me this:

, or ~, then that specific # comparison is used instead of the default = (~ becomes LIKE). # # If the value begins with a '$', the remainder is taken as a field name # in this or another table (i.e., it is not quoted), so that an inner join or # self-join can be performed. # # FUTURE # # - Limit number of results returned per page. # - Have option to show query as well as results. # - Have option to not perform query (i.e., use above option to preview first) # - Have option to enter own query in a TEXTAREA (preferably combined with # previous option: display query in a TEXTAREA for editing). # - Ability to click on a record and have the original form displayed with # this data filled in (for updates and future inserts). # - Add UPDATE. Hmmm... tricky, tricky, tricky. # - Add a create table interface (probably in a second script). # - Add a place to type in special expressions to select (e.g., # ROOM.LENGTH*ROOM.WIDTH AS AREA) # function bad_auth() { global $database; Header("WWW-authenticate: basic realm=\"Database ".$database."\""); Header("HTTP/1.0 401 Unauthorized"); $title = "Invalid login"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " I need a username and password with which to access the database.
\n"; echo " \n"; echo "\n"; exit; } $database=$HTTP_POST_VARS["DATABASE"]; $hostname=$HTTP_POST_VARS["HOSTNAME"]; if(!$database) { ?>

METHOD=POST> Hostname:
Database:


Could not read list of tables
MySQL claims this database is empty!
MySQL at returned an error:


=~] *[$]([^.]+).",$fdatum,$re)) $kludge[$re[1]] = $re[1]; } $qaction[$ftable][$ffield] = $faction; } if($qdata) { $tablecount = count($kludge); if($command == "SELECT") { for(reset($kludge);$stable = key($kludge);next($kludge)) { $sfields = $qaction[$stable]; for(reset($sfields);$sfield = key($sfields);next($sfields)) { $action = $sfields[$sfield]; if($tablecount > 1) $sfield = "$stable.$sfield"; if($action != "IGNORE" && $select) $select .= ","; if($action == "SELECT") $select .= $sfield; if($action == "DISTINCT") $select .= "DISTINCT $sfield"; if($action == "ORDERBY") { $select .= $sfield; if($orderby) $orderby .= ","; $orderby .= $sfield; } if($action == "SUM") $select .= "sum($sfield)"; if($action == "COUNT") $select .= "count($sfield)"; if($action == "AVG") $select .= "avg($sfield)"; if($action == "MIN") $select .= "min($sfield)"; if($action == "MAX") $select .= "max($sfield)"; } } } if($command == "SELECT" || $command == "DELETE") { for(reset($qdata);$qtable = key($qdata);next($qdata)) { if($command == "DELETE") { $from = $qtable; $where = ""; } $qfields = $qdata[$qtable]; for(reset($qfields);$qfield = key($qfields);next($qfields)) { $cmp = "="; $qdatum = $qfields[$qfield]; # ereg_replace("''","''''",$qdatum); if(ereg("^([<>=~]) +(.*)",$qdatum,$re)) { $cmp = $re[1]; if($cmp == "~") $cmp = "LIKE"; $qdatum = $re[2]; } if($command == "SELECT" && ereg("^[$]([^$].*)",$qdatum,$re)) { $qdatum = $re[1]; if($tablecount > 1 && !ereg("\.",$qdatum)) $qdatum = "$qtable.$qdatum"; } else if($tables[$qtable][$qfield]["type"] != "int") { $qdatum = "'$qdatum'"; } if($tablecount > 1) $qfield = "$qtable.$qfield"; if($where) $where .= "\n AND "; $where .= "$qfield $cmp $qdatum"; } if($command == "DELETE") $query .= "DELETE FROM $qtable WHERE $where\n\n"; } if($command == "SELECT") { $from = join($kludge,","); $query = "SELECT $select\nFROM $from\nWHERE $where\n"; if($orderby) $query .= "ORDER BY $orderby\n"; } } else if($command == "INSERT") { for(reset($qdata);$qtable = key($qdata);next($qdata)) { $qfields = $qdata[$qtable]; for(reset($qfields);$qfield = key($qfields);next($qfields)) { $qdatum = $qfields[$qfield]; if($tables[$qtable][$qfield]["type"] != "int") $qdatum = "'$qdatum'"; if($columns) $columns .= ","; $columns .= $qfield; if($values) $values .= ","; $values .= $qdatum; } $query .= "INSERT INTO $qtable ($columns)\nVALUES ($values)\n\n"; } } echo "$query

\n"; $start = microtime(); $result = mysql_query($query,$dblink); $end = microtime(); $start = explode(" ",$start); $end = explode(" ",$end); $interval = round(0.5 + 1000*($end[1]-$start[1] + $end[0]-$start[0])); if(!$result) { $error = mysql_error($dblink); ?>
MySQL at returned an error:


METHOD=POST> > SelectSelect DistinctOrder Bysum()count()avg()min()max()Don't Select 40) $size = 40; $maxlength = $len; $type .= "[".$len."]"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " (".$type.")\n"; echo " \n"; } echo " \n"; } ?>
--------------------------------------------------------------------------------


>

Note that the results are just the copied result on the HTML page. That is not the actual code for the resulting pages, just the visible result. In any case that shouldn't be like that.

I hate php and MySQL with a passion. They are impossible to learn and to use. I have been at this **** for two and a half months already and I can't even get a simple database entry form up and running (you can check out my previous posts on this board for more info).

None of the tutorials help. They are all bull****. They either don't work or are too simplistic and while they work fine, they don't teach me jack.

I still don't know how you SPECIFY which table in the GIVEN database the php script should access/write to.

This is bull****. I just wanna give up, but I can't because it is not in my nature.

firepages
09-01-2005, 12:33 AM
Hi, well it looks like your server is not setup to parse php files , else you would not see the PHP code just output &&/|| errors

tell us about your server setup.

Noodles24
09-01-2005, 12:33 AM
I can't see the problem with your scripts, but I suggest you start from scratch (it looks like you're trying to use some pre built scripts)


I still don't know how you SPECIFY which table in the GIVEN database the php script should access/write to.


This is all done through SQL, which is passed to the database server (in this case MySQL).

SELECT * FROM mytable
This selects all rows from the database table "mytable"

UPDATE mytable SET name = 'test' WHERE id = 1
This updates a column called name in a database table called "mytable", but only when it finds rows with id = 1

I suggest starting small with a example database from a tutorial site and try do things like create a query and output all the rows from the database. Updating some rows or adding new rows. Once you master the basics then you can tackle something a bit more complicated

Noodles24
09-01-2005, 12:35 AM
Hi, well it looks like your server is not setup to parse php files , else you would not see the PHP code just output &&/|| errors

tell us about your server setup.

Being that they're getting things like:


Could not read list of tables
MySQL claims this database is empty!
MySQL at returned an error:


I would say that their webserver is parsing php to some extent

Noodles24
09-01-2005, 12:36 AM
On second thought they are probably copying the text from the webpage, rather than from view source and thus only text is displayed, not all the formatting etc.

firepages
09-01-2005, 01:38 AM
I would say that their webserver is parsing php to some extent

php parsing is an all or nothing thing , the code above is all valid and just gives me connection errors (since I dont have a copy of the DB) otherwise the code itself if fine , but it is not being parsed, either PHP is not running on the server OR .php .whatever files are not being associated correctly with php.

Doggonit
09-01-2005, 03:13 PM
See I am running WAMP5. And php used to work fine. Maybe the .php format got disassociated with PHP somehow? But how? How would the WAMP server and its services (PHP being one of them) die? Actually the WAMP server is up and running fine, but how would something go wrong like this? I didn't change any settings or anything? Can the settings files corrupt themselves?

This is so f***ed up. I guessed that it was that php wasn't parsing its own ****ty code, but why? It worked before! Now I can't even get the php info to show!

firepages
09-02-2005, 10:00 AM
reinstall WAMP would seem the obvious next step , but shouting at PHP won't help ;)