-
Posts
90 -
Joined
-
Last visited
RidgeandGable's Achievements
Newbie (1/5)
0
Reputation
-
SELECT Name, Town, Category FROM customer1 WHERE Name = colname Code is above (Dreamweaver CS6) I need Where Name & Town to filter on? Any help?
-
<?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); ?>
-
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 etc I 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 etc Any help?
-
SOLVED , I had an extra "," behind Now() all fixed and working Mac_yver I take on board what you said and I will soon be learner Mysqli and doing away with the bad dreamweaver, but for now, I need the site up and running to stop the customers from complaining about paper invoice etc. Dreamweaver was quick to install and setup although the errors in php code it produces does slow things down and "php helpers" are reluctant to help as soon as dreamweaver is mentioned. No excuses, but I am a father of 2 young kids with disabilitys and work almost 24/7 running my own roofing business and don't always have the time to sit down and read and learn in full so i can only manage a little bit at a time. But thank you for your help and advise and I as soon as free time pops up, I will be learning it without dreamweaver. Thanks Again Harry
-
After looking again, I've come up with this: //declare two session variables and assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; $update =("UPDATE users SET LastLogin = NOW(), WHERE Username = '$MM_Username'"); $result = mysql_query($update) or die (mysql_error()); But I now get an error on Login - 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 'WHERE Username = 'DM4571'' at line 1 The DM4571 Is the user that I tried to login with Any help on that and I think I'm sorted
-
Hi Cheers for the reply Yeap your right, I added this code in the wrong area, It was added to a the after login page. I changed this last night to the log in page and managed to get the date inserting properly but still can't get any username added in. I found the code in a book on php and thought it was what I was looking for. The login page was created using Dreamweaver and is working for now. The site is complete for what I need. The goal of this sections it to create a Log when users log in. I have the table created called logs has ID, Username and Date, I just want to capture the date and Username of a logged in user, no need for IP address as the only people to use this site would be my customers only. The loging page uses the session MM_Username and username and password are in the form for entering the data. I thought it would be simple enough to copy this username from the $_SESSION MM_Username but that throws up errors about ; and " Cheers
-
I managed to get the date part working using mysql_query("INSERT INTO logs SET Date = NOW()"); But I cannot get the username to pass The full code of page is: <?php $colname_Recordset1 = "1"; if (isset($_SESSION['MM_Username'])) { $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']); } mysql_select_db($database_Harry, $Harry); $query_Recordset1 = sprintf("SELECT * FROM users WHERE Username = '%s'", $colname_Recordset1); $Recordset1 = mysql_query($query_Recordset1, $Harry) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); mysql_select_db($database_Harry, $Harry); $query_Recordset2 = "SELECT * FROM logs"; $Recordset2 = mysql_query($query_Recordset2, $Harry) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); session_start() ?> <?php mysql_query("INSERT INTO logs SET Date = NOW()"); $colname_Recordset1 = "1"; if (isset($_SESSION['MM_Username'])) { $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']); } mysql_select_db($database_Harry, $Harry); $query_Recordset1 = sprintf("SELECT BalanceDue, AccountStatus FROM users WHERE Username = '%s'", $colname_Recordset1); $Recordset1 = mysql_query($query_Recordset1, $Harry) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?>
-
after much googling n searching I've come up with this, but not sure if it will do the job? mysql_query("UPDATE tbllog SET LastLogin=now() WHERE Username='$Username'"); am I on the right track?
-
Hi guys I have a php login form and I would like to create either a text file with loging username and date or a table with the same details. My log uses Mysql table "users" with an ID, Username and Password, can anyone offer some help. I have no idea how or where to start or what is best CHeers
-
ok did that with the quotes but still got the error. Think I'll just leave it lol, I dont mind it being in reverse just gotta remember it when I'm entering the data. Cheers though
-
Ok, so is it as easy as removing all the sprintf statements?
-
Thanks Sen Have tried what you put but still puts the same error out mysql_select_db($database_Harry, $Harry); $query_Invoices = sprintf("SELECT id,username,DATE_FORMAT(invoicedate,%d-%m-%y) as date,DATE_FORMAT(duebydate,%d-%m-%y) as date,description,invoicenumber,download,paid,DATE_FORMAT(datepaid,%d-%m-%y) as date FROM invoices WHERE username = '%s' ORDER BY invoicedate DESC", $colname_Invoices); $query_limit_Invoices = sprintf("%s LIMIT %d, %d", $query_Invoices, $startRow_Invoices, $maxRows_Invoices); $Invoices = mysql_query($query_limit_Invoices, $Harry) or die(mysql_error()); $row_Invoices = mysql_fetch_assoc($Invoices); This is row 20 - ORDER BY invoicedate DESC", $colname_Invoices); Warning: sprintf(): Too few arguments in C:\xampp\htdocs\rgroofing\Invoices.php on line 20 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 'LIMIT 0, 10' at line 1
-
When I use the above code, I get an error for using sprintf
-
SELECT id,username,InvoiceNumber,DATE_FORMAT(invoicedate,%d-%m-%y)
-
So it would become Select Date_Format("[iD],[username],[Date,'%d-%m-%Y]") ?