Please help, How can update info to database from Dreamweaver
Hello, I have a issues with my database, I know is working perfectly my database but when insert update to my database from my form table what I create with dreamweaver, I have this error
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\dwwithphp\TMPbcn96qcid9.php on line 20
I don't know why change my localhost to " SYSTEM@localhost" in the part said using password all ready set up in dreamweaver the password can access all the database in Dreamweaver, so I don't know what can I do?
This all the code of my talble form:
<?php require_once('Connections/dw_bookstore.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE titles SET title=%s, pub_id=%s, au_id=%s, price=%s, notes=%s, pubdate=%s WHERE title_id=%s",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['pub_id'], "text"),
GetSQLValueString($_POST['au_id'], "text"),
GetSQLValueString($_POST['price'], "double"),
GetSQLValueString($_POST['notes'], "text"),
GetSQLValueString($_POST['pubdate'], "date"),
GetSQLValueString($_POST['title_id'], "text"));
mysql_select_db($database_dw_bookstore, $dw_bookstore);
$Result1 = mysql_query($updateSQL, $dw_bookstore) or die(mysql_error());
}
mysql_select_db($database_dw_bookstore, $dw_bookstore);
$query_rsPubs = "SELECT pub_id, pub_name FROM publishers ORDER BY pub_name ASC";
$rsPubs = mysql_query($query_rsPubs, $dw_bookstore) or die(mysql_error());
$row_rsPubs = mysql_fetch_assoc($rsPubs);
$totalRows_rsPubs = mysql_num_rows($rsPubs);
mysql_select_db($database_dw_bookstore, $dw_bookstore);
$query_rsAuthors = "SELECT au_id, au_lname, au_fname FROM authors ORDER BY au_lname ASC";
$rsAuthors = mysql_query($query_rsAuthors, $dw_bookstore) or die(mysql_error());
$row_rsAuthors = mysql_fetch_assoc($rsAuthors);
$totalRows_rsAuthors = mysql_num_rows($rsAuthors);
$colname_rsTitles = "-1";
if (isset($_GET['title_id'])) {
$colname_rsTitles = $_GET['title_id'];
}
mysql_select_db($database_dw_bookstore, $dw_bookstore);
$query_rsTitles = sprintf("SELECT * FROM titles WHERE title_id = %s", GetSQLValueString($colname_rsTitles, "text"));
$rsTitles = mysql_query($query_rsTitles, $dw_bookstore) or die(mysql_error());
$row_rsTitles = mysql_fetch_assoc($rsTitles);
$totalRows_rsTitles = mysql_num_rows($rsTitles);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php $pagetitle="The Night Owl"?>
<html xmlns="http://www.w3.org/1999/xhtml" >
<meta http-equiv="Content-Type" content="; charset=" />
<title>The Night Owl</title>
<link rel="stylesheet" href="styles.css" type="text/css" media="screen" />
</head>
<body>
<?php include('Includes/header.php'); ?>
<h1>Welcome to <?php echo $pagetitle?></h1>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Title_id:</td>
<td><?php echo $row_rsTitles['title_id']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Title:</td>
<td><input type="text" name="title" value="<?php echo htmlentities($row_rsTitles['title'], ENT_COMPAT, ''); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Pub_id:</td>
<td><select name="pub_id">
<?php
do {
?>
<option value="<?php echo $row_rsPubs['pub_id']?>" <?php if (!(strcmp($row_rsPubs['pub_id'], htmlentities($row_rsTitles['pub_id'], ENT_COMPAT, '')))) {echo "SELECTED";} ?>><?php echo $row_rsPubs['pub_name']?></option>
<?php
} while ($row_rsPubs = mysql_fetch_assoc($rsPubs));
?>
</select></td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Au_id:</td>
<td><select name="au_id">
<?php
do {
?>
<option value="<?php echo $row_rsAuthors['au_id']?>" <?php if (!(strcmp($row_rsAuthors['au_id'], htmlentities($row_rsTitles['au_id'], ENT_COMPAT, '')))) {echo "SELECTED";} ?>><?php echo $row_rsAuthors['au_lname']?></option>
<?php
} while ($row_rsAuthors = mysql_fetch_assoc($rsAuthors));
?>
</select></td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Price:</td>
<td><input type="text" name="price" value="<?php echo htmlentities($row_rsTitles['price'], ENT_COMPAT, ''); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" valign="top">Notes:</td>
<td><textarea name="notes" cols="50" rows="5"><?php echo htmlentities($row_rsTitles['notes'], ENT_COMPAT, ''); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Pubdate:</td>
<td><input type="text" name="pubdate" value="<?php echo htmlentities($row_rsTitles['pubdate'], ENT_COMPAT, ''); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Update record" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="title_id" value="<?php echo $row_rsTitles['title_id']; ?>" />
</form>
<p> </p>
<p> </p>
<?php include('Includes/footer.php'); ?>
<!-- end page -->
<p> </p>
</body>
</html>
<?php
mysql_free_result($rsPubs);
mysql_free_result($rsAuthors);
mysql_free_result($rsTitles);
?>
So please help me Thanks for you time!!!
I really apreciate that......
