Jump to content

roama1

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

roama1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Found a solution... what i did was went to my control.php page and edited the link to editbooks.php. by removing the buttons and using an image and adding the value to be carried over it worked.. weired but it solved the problem
  2. Thanks again.. tried the new code now i have this error
  3. Thanks for looking at this problem.. I tried the code you gave, now the error reads.. Query was empty...
  4. Thanks for responding.. The require once is the connection to the database.. It works fine What i want to have happen is.. when i want to edit a book in my database the list is generated by another page.. i hit the edit link and that particular book entry is brought up from the data base for editing.. what is happening is if i use the recordset to change the code to ... ... i always get the same data base entry not he one i selected.. thats why so i changed the code to this line of code Its in this line of code that i think the error is.. but i cant see it.....
  5. trying to create an page to edit the data base file But i keep getting this message You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Cant see the error. would appreciate some help.. Thanks <?php require_once('../Connections/yelan.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; 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"] == "editBooks")) { $updateSQL = sprintf("UPDATE books SET title=%s, author=%s, price=%s, description=%s WHERE bookID=%s", GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['author'], "text"), GetSQLValueString($_POST['price'], "double"), GetSQLValueString($_POST['description'], "text"), GetSQLValueString($_POST['editbooksKey'], "int")); mysql_select_db($database_yelan, $yelan); $Result1 = mysql_query($updateSQL, $yelan) or die(mysql_error()); $updateGoTo = "control.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } mysql_select_db($database_yelan, $yelan); $query_editbooks = "SELECT * FROM books WHERE bookID = $editkey"; $editbooks = mysql_query($query_editbooks, $yelan) or die(mysql_error()); $row_editbooks = mysql_fetch_assoc($editbooks); $totalRows_editbooks = mysql_num_rows($editbooks);?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>admin edit books</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p>edit books </p> <form name="editBooks" method="POST" action="<?php echo $editFormAction; ?>"> <table width="106%" border="1" id="edit"> <tr> <td width="15%">bookID</td> <td width="15%">title</td> <td width="18%">author</td> <td width="17%">price</td> <td width="20%">description</td> </tr> <tr> <td><input name="edit" type="submit" id="edit" value="edit"> <input name="editbooksKey" type="hidden" id="editbooksKey" value="<?php echo $editkey?>"></td> <td> <input name="title" type="text" id="title" value="<?php echo $row_editbooks['title']; ?>"> </td> <td><input name="author" type="text" id="author" value="<?php echo $row_editbooks['author']; ?>"></td> <td><input name="price" type="text" id="price" value="<?php echo $row_editbooks['price']; ?>"></td> <td><input name="description" type="text" id="description" value="<?php echo $row_editbooks['description']; ?>"></td> </tr> </table> <input type="hidden" name="MM_update" value="editBooks"> </form> <p> </p> </body> </html> <?php mysql_free_result($editbooks); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.