Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

problem of update page

Links for php scripts

Moderators: macek, egami, gesf

problem of update page

Postby begeiste » Wed Sep 15, 2004 3:29 pm

I created the updated page with update button, for some reasons the LargeImage field isn't updated. Don't know why? Can you help me to figure out ? Thanks.

<?php require_once('Connections/victorphoto.php'); ?>
<?php
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;
$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 billboard SET thumb=%s, name=%s, Gallery=%s WHERE billboardID=%s",
GetSQLValueString($_POST['thumb'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['Gallery'], "text"),
GetSQLValueString($_POST['billboardID'], "int"));

mysql_select_db($database_victorphoto, $victorphoto);
$Result1 = mysql_query($updateSQL, $victorphoto) or die(mysql_error());

$updateGoTo = "success.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}

mysql_select_db($database_victorphoto, $victorphoto);
$query_r_result = "SELECT billboardID, thumb, LargeImage, name, Gallery FROM billboard";
$r_result = mysql_query($query_r_result, $victorphoto) or die(mysql_error());
$row_r_result = mysql_fetch_assoc($r_result);
$totalRows_r_result = mysql_num_rows($r_result);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>billboard</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<link href="photos.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="strip">
<div id="nav">
<?php require_once('inc_nav.htm'); ?>
</div>
</div>
<div id="strip-orange">
<a href="#" class="title">Gallery photos of Billboard</a>
</div>
<div id="strip-y">
<a href="addrecord.php" class="addrecord">Add your Gallery photos</a> | <a href="billboard_new.php">Go back to result</a>
<div id="records">Total Records:<?php echo ($startRow_r_result + 1) ?>
to<?php echo min($startRow_r_result + $maxRows_r_result, $totalRows_r_result) ?>
of<?php echo $totalRows_r_result ?>
</div>
</div>
<div id="container">

<p>&nbsp;</p>


<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">BillboardID:</td>
<td><?php echo $row_r_result['billboardID']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Thumb:</td>
<td><input type="text" name="thumb" value="<?php echo $row_r_result['thumb']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">LargeImage:</td>
<td><input type="text" name="LargeImage" value="<?php echo $row_r_result['LargeImage']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Name:</td>
<td><input type="text" name="name" value="<?php echo $row_r_result['name']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Gallery:</td>
<td><textarea name="Gallery" value="<?php echo $row_r_result['Gallery']; ?>" size="32"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Update record"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="billboardID" value="<?php echo $row_r_result['billboardID']; ?>">
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($r_result);
?>
begeiste
New php-forum User
New php-forum User
 
Posts: 83
Joined: Thu Jun 03, 2004 11:27 am

Postby gesf » Thu Sep 16, 2004 1:10 am

I don't see the LargeImage field here...
Code: Select all
$updateSQL = sprintf("UPDATE billboard SET thumb=%s, name=%s, Gallery=%s WHERE billboardID=%s",
GetSQLValueString($_POST['thumb'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['Gallery'], "text"),
GetSQLValueString($_POST['billboardID'], "int"));
:)
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.