RidgeandGable Posted December 9, 2015 Share Posted December 9, 2015 Hi Guys Building a little play database where tradesmen can "black list" bad customers and any tradesman can log in and check the customer file to see if anything is on it - ie Avoid, he doesn't pay etcI have the record sets etc created and have the dynamic tables displaying the record for a particular town / city etc, but I want to allow registered user somewhere they can add further comments.So I created a new table Called "Comments" and it has ID, CustomerID and comment.I'm using Dreamwaver CS6 to build the page and used the master detail page to create the tables etc to display.. But I can't seem to get anything working with the comment area.When you click on a customersID, it goes to /moreinfo.php?recordID=1 and in the recordset for the comments, I have it set to filter on URL - recordID and I get Notice: Undefined Variable: row_recordset1 etc etcAny help? Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 9, 2015 Share Posted December 9, 2015 You want help, post some code. Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted December 9, 2015 Author Share Posted December 9, 2015 <?php require_once('Connections/New.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; } } if ((isset($_GET['ID'])) && ($_GET['ID'] != "")) { $deleteSQL = sprintf("DELETE FROM customer1 WHERE ID=%s", GetSQLValueString($_GET['ID'], "int")); mysql_select_db($database_New, $New); $Result1 = mysql_query($deleteSQL, $New) or die(mysql_error()); $deleteGoTo = "success.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } if ((isset($_GET['ID'])) && ($_GET['ID'] != "")) { $deleteSQL = sprintf("DELETE FROM customer1 WHERE ID=%s", GetSQLValueString($_GET['ID'], "int")); mysql_select_db($database_New, $New); $Result1 = mysql_query($deleteSQL, $New) or die(mysql_error()); } $colname_DetailRS1 = "-1"; if (isset($_GET['recordID'])) { $colname_DetailRS1 = $_GET['recordID']; } mysql_select_db($database_New, $New); $query_DetailRS1 = sprintf("SELECT * FROM customer1 WHERE ID = %s ORDER BY `last Updated` ASC", GetSQLValueString($colname_DetailRS1, "int")); $DetailRS1 = mysql_query($query_DetailRS1, $New) or die(mysql_error()); $row_DetailRS1 = mysql_fetch_assoc($DetailRS1); $totalRows_DetailRS1 = mysql_num_rows($DetailRS1); $colname_recordset1 = "-1"; if (isset($_GET['RecordID'])) { $colname_recordset1 = $_GET['RecordID']; } mysql_select_db($database_New, $New); $query_recordset1 = sprintf("SELECT * FROM `comment` WHERE CustomerID = %s", GetSQLValueString($colname_recordset1, "int")); $recordset1 = mysql_query($query_recordset1, $New) or die(mysql_error()); $row_recordset1 = mysql_fetch_assoc($recordset1); $totalRows_recordset1 = mysql_num_rows($recordset1); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <table width="200" border="1"> <tr> <th scope="row"><?php echo $row_Recordset1['ID']; ?></th> <td><?php echo $row_Recordset1['CustomerID']; ?></td> <td><?php echo $row_Recordset1['Comment']; ?></td> </tr> </table> <table border="1" align="center"> <tr> <td width="77">ID</td> <td width="248"><?php echo $row_DetailRS1['ID']; ?></td> </tr> <tr> <td>Name</td> <td><?php echo $row_DetailRS1['Name']; ?></td> </tr> <tr> <td>Address</td> <td><?php echo $row_DetailRS1['Address']; ?></td> </tr> <tr> <td>Postcode</td> <td><?php echo $row_DetailRS1['Postcode']; ?></td> </tr> <tr> <td>Town</td> <td><?php echo $row_DetailRS1['Town']; ?></td> </tr> <tr> <td>Telephone</td> <td><?php echo $row_DetailRS1['Telephone']; ?></td> </tr> <tr> <td>Email</td> <td><?php echo $row_DetailRS1['Email']; ?></td> </tr> <tr> <td>Category</td> <td><?php echo $row_DetailRS1['Category']; ?></td> </tr> <tr> <td height="163">Notes</td> <td><?php echo $row_DetailRS1['Notes']; ?></td> </tr> <tr> <td>last Updated</td> <td><?php echo $row_DetailRS1['last Updated']; ?></td> </tr> </table> <p><br /> </p> <p><br /> </p> <p> </p> <p> </p> <p><br /> </p> </body> </html><?php mysql_free_result($DetailRS1); mysql_free_result($recordset1); ?> Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 9, 2015 Share Posted December 9, 2015 (edited) You are using deprecated code that will not work at all in the current Php release. You need to be using PDO with prepared statements. There are several other problems I am sure other posters will point out. Edited December 9, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted December 9, 2015 Share Posted December 9, 2015 (edited) Variables are case-sensitive, so $row_Recordset1 is not the same as $row_recordset1. But what's much more important: You need to throw away the Dreamweaver stuff and start programming. I totally understand that Dreamweaver is useful for your very first website when you're too afraid to write the HTML markup and PHP code yourself. But you've been doing this for a whole year. Now the auto-generated cruft just gets in your way and prevents you from making progress. And the deprecation problem is not a joke. In 2014, it might have been OK to ignore the advice and keep going. But now PHP 7 is about to be released, and that means a lot of deprecated features (including the old ext/mysql extension) will in fact be removed. The 5.x branch is only supported for 8 more months and will reach end-of-life in 2017. Edited December 9, 2015 by Jacques1 Quote Link to comment Share on other sites More sharing options...
benanamen Posted December 9, 2015 Share Posted December 9, 2015 (edited) @Jaques1, Php7 has already been released on Dec 3, 2015 Edited December 9, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.