Hi,
I have an issue with php and/or mysql. I have a php form that writes "items"
to a mysql database, including a description of the item.
I am testing it now by putting special characters in the description field,
this is what I am entering:
Reader's Digest
Now, this item data always gets written to the db just fine and shows up in the db as entered. Seems correct and working just fine up to this point.
My problem is with my "edit item (PUBLISHER textbox)" page. This page allows users to update items, but when the data is called back up from the db to display in the "edit item" page and the description contains single quotes, the description is cut off, and only shows:
Reader
Here is the code on the "edit item" page:
<?php
session_start() ;
if ($_SESSION["validuser"]<>"YES") {
Header ("location: ../index.php");
}
include "dbConfig.p hp";
echo "<form enctype='multip art/form-data' action='editMag 3.php' method='post' >";
$id = $_REQUEST['id'];
$_SESSION['id'] = $id;
$mysql_query = "select * from dbMag where id='$id' " ;
$n1 = mysql_query($my sql_query);
$r1 = mysql_num_rows( $n1);
if($r1==0) {
die("<script>al ert('Magazine Title not found. Try again.');histor y.back()</script>");
}
$n = mysql_fetch_arr ay($n1);
$title = $n[0];
$_SESSION['magTitle']=$title;
$issue = $n[1];
// $link = $n[2];
$online = $n[3];
$type = $n[4];
$picture = $n[5];
$subtitle = $n[6];
$price = $n[7];
$publisher = $n[8];
//$publisher = htmlentites($n[8]);
//echo "$publisher ";
echo "<h1>Edit Magazine</h1>";
echo "<table border='0'>";
echo "<tr>";
echo "<td width='100'>Tit le:</td>";
echo "<td width='100'>$ti tle";
echo "</tr>";
echo "<tr>";
echo "<td width='100'>Sub Title:</td>";
echo "<td><input size='60' name='i1' value='$subtitl e'></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100'>Iss ue No:</td>";
echo "<td><input size='60' name='i2' value='$issue'> </td>";
echo "</tr>";
echo "<td width='100'>Typ e:</td>";
echo "<td><input size='60' name='i3' value='$type'></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100'>Pri ce:</td>";
echo "<td><input size='60' name='i4' value='$price'> </td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100'>Pub lisher:</td>";
echo "<td><input size='60' type=text name=i5 value='$publish er'></td>";
//echo "<td><input size='60' name='i5' value='$publish er'></td>";
echo "</tr>";
echo "<tr>";
// echo "<td width='100'>Lin k:</td>";
// echo "<td><input size='60' name='i6' value='$link'></td>";
// echo "</tr>";
echo "<td width='100'>Pic ture:</td>";
echo "<td><input size='60' name='i7' value='$picture '></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100'><in put type='hidden' name='MAX_FILE_ SIZE' value='1000000' >Select New Picture:</td>";
echo "<td><input size='60' type='file' name='userfile' value='$newPic' ></td>";
//echo"<td><input type='submit' value='upload'> </td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100'>Onl ine:</td>";
echo "<td width='20'><sel ect name='i8'>";
if ($online == "ON"){
echo "<option value='$online' selected>$onlin e</option>";
echo "<option value='OFF'>OFF </option>";
} else {
echo "<option value='$online' selected>$onlin e</option>";
echo "<option value='ON'>ON</option>";
}
echo "</select></td>";
echo "</tr>";
echo "<tr><td></td><td><input type='submit' value='submit'> </td></tr>";
echo "</form>";
echo "</font>";
//echo "<form action='upnewbo okcover.php' method='post'>" ;
// echo "<tr><td><td><i nput type='submit' value='change cover'><a href='upnewbook cover.php'></a></td></tr>";
// echo "</form>";
echo "<form action='magList .php' method='post'>" ;
echo "<tr><td><td><i nput type='submit' value='Cancel'> <a href='magList.p hp'></a></td></tr>";
echo "</form>";
echo "</table>";
?>
Put your code within php, code or html TAGS!!!! - Ronald :cool:
I have an issue with php and/or mysql. I have a php form that writes "items"
to a mysql database, including a description of the item.
I am testing it now by putting special characters in the description field,
this is what I am entering:
Reader's Digest
Now, this item data always gets written to the db just fine and shows up in the db as entered. Seems correct and working just fine up to this point.
My problem is with my "edit item (PUBLISHER textbox)" page. This page allows users to update items, but when the data is called back up from the db to display in the "edit item" page and the description contains single quotes, the description is cut off, and only shows:
Reader
Here is the code on the "edit item" page:
<?php
session_start() ;
if ($_SESSION["validuser"]<>"YES") {
Header ("location: ../index.php");
}
include "dbConfig.p hp";
echo "<form enctype='multip art/form-data' action='editMag 3.php' method='post' >";
$id = $_REQUEST['id'];
$_SESSION['id'] = $id;
$mysql_query = "select * from dbMag where id='$id' " ;
$n1 = mysql_query($my sql_query);
$r1 = mysql_num_rows( $n1);
if($r1==0) {
die("<script>al ert('Magazine Title not found. Try again.');histor y.back()</script>");
}
$n = mysql_fetch_arr ay($n1);
$title = $n[0];
$_SESSION['magTitle']=$title;
$issue = $n[1];
// $link = $n[2];
$online = $n[3];
$type = $n[4];
$picture = $n[5];
$subtitle = $n[6];
$price = $n[7];
$publisher = $n[8];
//$publisher = htmlentites($n[8]);
//echo "$publisher ";
echo "<h1>Edit Magazine</h1>";
echo "<table border='0'>";
echo "<tr>";
echo "<td width='100'>Tit le:</td>";
echo "<td width='100'>$ti tle";
echo "</tr>";
echo "<tr>";
echo "<td width='100'>Sub Title:</td>";
echo "<td><input size='60' name='i1' value='$subtitl e'></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100'>Iss ue No:</td>";
echo "<td><input size='60' name='i2' value='$issue'> </td>";
echo "</tr>";
echo "<td width='100'>Typ e:</td>";
echo "<td><input size='60' name='i3' value='$type'></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100'>Pri ce:</td>";
echo "<td><input size='60' name='i4' value='$price'> </td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100'>Pub lisher:</td>";
echo "<td><input size='60' type=text name=i5 value='$publish er'></td>";
//echo "<td><input size='60' name='i5' value='$publish er'></td>";
echo "</tr>";
echo "<tr>";
// echo "<td width='100'>Lin k:</td>";
// echo "<td><input size='60' name='i6' value='$link'></td>";
// echo "</tr>";
echo "<td width='100'>Pic ture:</td>";
echo "<td><input size='60' name='i7' value='$picture '></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100'><in put type='hidden' name='MAX_FILE_ SIZE' value='1000000' >Select New Picture:</td>";
echo "<td><input size='60' type='file' name='userfile' value='$newPic' ></td>";
//echo"<td><input type='submit' value='upload'> </td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100'>Onl ine:</td>";
echo "<td width='20'><sel ect name='i8'>";
if ($online == "ON"){
echo "<option value='$online' selected>$onlin e</option>";
echo "<option value='OFF'>OFF </option>";
} else {
echo "<option value='$online' selected>$onlin e</option>";
echo "<option value='ON'>ON</option>";
}
echo "</select></td>";
echo "</tr>";
echo "<tr><td></td><td><input type='submit' value='submit'> </td></tr>";
echo "</form>";
echo "</font>";
//echo "<form action='upnewbo okcover.php' method='post'>" ;
// echo "<tr><td><td><i nput type='submit' value='change cover'><a href='upnewbook cover.php'></a></td></tr>";
// echo "</form>";
echo "<form action='magList .php' method='post'>" ;
echo "<tr><td><td><i nput type='submit' value='Cancel'> <a href='magList.p hp'></a></td></tr>";
echo "</form>";
echo "</table>";
?>
Put your code within php, code or html TAGS!!!! - Ronald :cool:
Comment