Jump to content

mancroft

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mancroft's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a list: fred harry43986.php jayne.php diana732 james and need to sort out the strings which end .php from those that don't. What's the RegEx for that? Thanks.
  2. If you so a php page using includes e.g. mypage.php <?php include("includeheader.php"); ?> Blah <?php include("includefooter.php"); ?> Do search engines pick up the whole mypage.php page includes and all or just the Blah?
  3. Occasional session problem Hello I have done a logger: thelogger.php. This usually works OK BUT sometimes a user lands on the site, sets the session ID as 4re3ccc...etc and then goes to another file and a new session ID xc3zkf...etc gets set. The user agent appears to be a standard browser e.g. Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) and not a crawler. Any idea as to the cause and solution? Thank you. Here is the code at the top of the logger file. This file is accessed at the top of every php file by using: [code] <?php include("thelogger.php"); ?> [/code] The GetTheId() function is used to get the session ID when putting it into the database. [code] <?php session_start(); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache");     function GetTheId(){ if(isset($_COOKIE["theId"])){ return $_COOKIE["theId"]; } else { session_start(); setcookie("theId", session_id(), time() + 36000, "/", "",0); return session_id(); } } [/code]
  4. Sorting problem... session & time Hello Lets say you have data like this: Time Sessionid 20.55 x3 20.44 x3 20.39 a1 20.33 a1 20.29 x3 20.27 x3 and you want to sort it so it looks like this i.e. grouped according to Sessionid and then Time: x3 = 20.55 20.44 20.29 20.27 a1 = 20.39 20.33 What is the best way to do this in mySQL? Thank you.
  5. Bona vada I have just set up a database and put two tables into it but phpmyadmin gives the following message (see below the actual question which comes next): My actual question is: what is $cfg[\'Servers\'][$i][\'pmadb\'] and how do I \"just put your current database name in $cfg[\'Servers\'][$i][\'pmadb\']\" ???? Thanks! >>>>>>>>>>>>>>>>>>>>>>>> Error The additional Features for working with linked Tables have been deactivated. To find out why click here. >>>>>>>>>>>>>>>>>>>>>>>> which leads to: >>>>>>>>>>>>>>>>>>>>>>>> Database cos_cart running on localhost PMA Database ... not OK[ Documentation ] General relation features Disabled >>>>>>>>>>>>>>>>>>>>>>>> and the link to documentation leads to: >>>>>>>>>>>>>>>>>>>>>>>> $cfg[\'Servers\'][$i][\'pmadb\'] string Starting with version 2.3.0 phpMyAdmin offers a lot of features to work with master / foreign - tables. To use those as well as the bookmark feature you need special tables with a predefined structure, which we explain below. If you are the only user of this phpMyAdmin installation, you can use your current database to store those special tables; in this case, just put your current database name in $cfg[\'Servers\'][$i][\'pmadb\']. If you are setting up a multi-user phpMyAdmin installation, you will need to create a new db and setup special privileges, so, as superuser: create a new database for phpmyadmin: CREATE DATABASE phpmyadmin; Note that \"controluser\" must have SELECT, INSERT, UPDATE and DELETE privileges on this database. Here is a query to set up those privileges (using \"phpmyadmin\" as the database name, and \"pma\" as the controluser): GRANT SELECT,INSERT,UPDATE,DELETE ON phpmyadmin.* to \'pma\'@\'localhost\'; do not give any other user rights on this database. enter the databasename in $cfg[\'Servers\'][$i][\'pmadb\'] >>>>>>>>>>>>>>>>>>>>>>>>
  6. What I wish to do is insert values into a database using a file (insert.php). 1. Is the layout of the file (see below) the proper way to do it? 2. Once the file is created, what do I do?, just put it on the server and then run the url http://pathtofile/insert.php <? //dbuser $usr = \"yyyyyyyy\"; //dbpass $pwd = \"xxxxxxxx\"; //dbname $db = \"zzzzzzzzzz\"; //dbhost $host = \"localhost\"; // connect to the sql database $link = mysql_connect($server, $user, $pass); $db = mysql_select_db($database, $link); \"insert into items values(0, \'Tony\', \'Tony blah\', 23.95)\"; \"insert into items values(0, \'FI\', \'FI blah\',36.50)\"; ?>
  7. First, to say that I really appreciate all the help from this forum! Still on the shopping cart problem... the mysql database has two tables: cart and items please see details below. What I am trying to do is create a mailform to send out details of the customer selections to the \"shop\". So far the following is working: $result = mysql_query(\"SELECT * FROM cart\",$con); if ($result === false) die(\"failed\"); while ($row=mysql_fetch_row($result)) { $content .= \"Ref no:\" .$row[2].\"nqty: \".$row[3].\"nn\";} This sends the ref no and quantity from the table cart. What I wish to do AS WELL is to send itemName and itemPrice from the table items. Any ideas please? >>>>>>>>>>>>>>>>>>>>>>>>>>>>> table items: Field Type Attributes Null Default Extra Action itemId int(11) No auto_increment Change Drop Primary Index Unique Fulltext itemName varchar(50) Yes NULL Change Drop Primary Index Unique Fulltext itemDesc varchar(250) Yes NULL Change Drop Primary Index Unique Fulltext itemPrice decimal(4,2) Yes NULL Change Drop Primary Index Unique Fulltext >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> table cart: Field Type Attributes Null Default Extra Action cartId int(11) No auto_increment Change Drop Primary Index Unique Fulltext cookieId varchar(50) Yes NULL Change Drop Primary Index Unique Fulltext itemId int(11) Yes NULL Change Drop Primary Index Unique Fulltext qty int(11) Yes NULL Change Drop Primary Index Unique Fulltext >>>>>>>>>>>>>>>>>>>>
  8. Direct add cart url link not working I am doing a simple shopping cart which works (code below)BUT... when i click on the add item to cart link it works and produces a url: blah/cart.php?action=add_item&id=4&qty=1 Now, what I would like to do is link the url to a button in flash so that people can click directly and add a specific item. I know how to do that but when i try to change the add_item&id=1 to add_item&id=2 or whatever, the thing does not work properly. Any ideas please? The cart file: <?php include(\"db.php\"); switch($_GET[\"action\"]) { case \"add_item\": { AddItem($_GET[\"id\"], $_GET[\"qty\"]); ShowCart(); break; } case \"update_item\": { UpdateItem($_GET[\"id\"], $_GET[\"qty\"]); ShowCart(); break; } case \"remove_item\": { RemoveItem($_GET[\"id\"]); ShowCart(); break; } default: { ShowCart(); } } function AddItem($itemId, $qty) { // Will check whether or not this item // already exists in the cart table. // If it does, the UpdateItem function // will be called instead global $dbServer, $dbUser, $dbPass, $dbName; // Get a connection to the database $cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName); // Check if this item already exists in the users cart table $result = mysql_query(\"select count(*) from cart where cookieId = \'\" . GetCartId() . \"\' and itemId = $itemId\"); $row = mysql_fetch_row($result); $numRows = $row[0]; if($numRows == 0) { // This item doesn\'t exist in the users cart, // we will add it with an insert query @mysql_query(\"insert into cart(cookieId, itemId, qty) values(\'\" . GetCartId() . \"\', $itemId, $qty)\"); } else { // This item already exists in the users cart, // we will update it instead UpdateItem($itemId, $qty); } } function UpdateItem($itemId, $qty) { // Updates the quantity of an item in the users cart. // If the qutnaity is zero, then RemoveItem will be // called instead global $dbServer, $dbUser, $dbPass, $dbName; // Get a connection to the database $cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName); if($qty == 0) { // Remove the item from the users cart RemoveItem($itemId); } else { mysql_query(\"update cart set qty = $qty where cookieId = \'\" . GetCartId() . \"\' and itemId = $itemId\"); } } function RemoveItem($itemId) { // Uses an SQL delete statement to remove an item from // the users cart global $dbServer, $dbUser, $dbPass, $dbName; // Get a connection to the database $cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName); mysql_query(\"delete from cart where cookieId = \'\" . GetCartId() . \"\' and itemId = $itemId\"); } function ShowCart() { // Gets each item from the cart table and display them in // a tabulated format, as well as a final total for the cart global $dbServer, $dbUser, $dbPass, $dbName; // Get a connection to the database $cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName); $totalCost = 0; $result = mysql_query(\"select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = \'\" . GetCartId() . \"\' order by items.itemName asc\"); ?> <html> <head> <title> Your Shopping Cart </title> <script language=\"JavaScript\"> function UpdateQty(item) { itemId = item.name; newQty = item.options[item.selectedIndex].text; document.location.href = \'cart.php?action=update_item&id=\'+itemId+\'&qty=\'+newQty; } </script> </head> <body bgcolor=\"#ffffff\"> <h1>Your Shopping Cart</h1> <form name=\"frmCart\" method=\"get\"> <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"> <tr> <td width=\"15%\" height=\"25\" bgcolor=\"red\"> <font face=\"verdana\" size=\"1\" color=\"white\"> <b>Qty</b> </font> </td> <td width=\"55%\" height=\"25\" bgcolor=\"red\"> <font face=\"verdana\" size=\"1\" color=\"white\"> <b>Product</b> </font> </td> <td width=\"20%\" height=\"25\" bgcolor=\"red\"> <font face=\"verdana\" size=\"1\" color=\"white\"> <b>Price Each</b> </font> </td> <td width=\"10%\" height=\"25\" bgcolor=\"red\"> <font face=\"verdana\" size=\"1\" color=\"white\"> <b>Remove?</b> </font> </td> </tr> <?php while($row = mysql_fetch_array($result)) { // Increment the total cost of all items $totalCost += ($row[\"qty\"] * $row[\"itemPrice\"]); ?> <tr> <td width=\"15%\" height=\"25\"> <font face=\"verdana\" size=\"1\" color=\"black\"> <select name=\"<?php echo $row[\"itemId\"]; ?>\" onChange=\"UpdateQty(this)\"> <?php for($i = 1; $i <= 20; $i++) { echo \"<option \"; if($row[\"qty\"] == $i) { echo \" SELECTED \"; } echo \">\" . $i . \"</option>\"; } ?> </select> </font> </td> <td width=\"55%\" height=\"25\"> <font face=\"verdana\" size=\"1\" color=\"black\"> <?php echo $row[\"itemName\"]; ?> </font> </td> <td width=\"20%\" height=\"25\"> <font face=\"verdana\" size=\"1\" color=\"black\"> $<?php echo number_format($row[\"itemPrice\"], 2, \".\", \",\"); ?> </font> </td> <td width=\"10%\" height=\"25\"> <font face=\"verdana\" size=\"1\" color=\"black\"> <a href=\"cart.php?action=remove_item&id=<?php echo $row[\"itemId\"]; ?>\">Remove</a> </font> </td> </tr> <?php } // Display the total ?> <tr> <td width=\"100%\" colspan=\"4\"> <hr size=\"1\" color=\"red\" NOSHADE> </td> </tr> <tr> <td width=\"70%\" colspan=\"2\"> <font face=\"verdana\" size=\"1\" color=\"black\"> <a href=\"products.php\"><< Keep Shopping</a> </font> </td> <td width=\"30%\" colspan=\"2\"> <font face=\"verdana\" size=\"2\" color=\"black\"> <b>Total: $<?php echo number_format($totalCost, 2, \".\", \",\"); ?></b> </font> </td> </tr> </table> </form> </body> </html> <?php } ?> The products list file: <?php // This page will list all of the items // from the items table. Each item will have // a link to add it to the cart include(\"db.php\"); // Get a connection to the database $cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName); $result = mysql_query(\"select * from items order by itemName asc\"); ?> <html> <head> <title> Product List </title> </head> <body bgcolor=\"#ffffff\"> <h1>Products</h1> <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"> <tr> <td width=\"30%\" height=\"25\" bgcolor=\"red\"> <font face=\"verdana\" size=\"1\" color=\"white\"> <b>Product</b> </font> </td> <td width=\"10%\" height=\"25\" bgcolor=\"red\"> <font face=\"verdana\" size=\"1\" color=\"white\"> <b>Price</b> </font> </td> <td width=\"50%\" height=\"25\" bgcolor=\"red\"> <font face=\"verdana\" size=\"1\" color=\"white\"> <b>Description</b> </font> </td> <td width=\"10%\" height=\"25\" bgcolor=\"red\"> <font face=\"verdana\" size=\"1\" color=\"white\"> <b>Add</b> </font> </td> </tr> <?php while($row = mysql_fetch_array($result)) { ?> <tr> <td width=\"30%\" height=\"25\"> <font face=\"verdana\" size=\"1\" color=\"black\"> <?php echo $row[\"itemName\"]; ?> </font> </td> <td width=\"10%\" height=\"25\"> <font face=\"verdana\" size=\"1\" color=\"black\"> $<?php echo $row[\"itemPrice\"]; ?> </font> </td> <td width=\"50%\" height=\"25\"> <font face=\"verdana\" size=\"1\" color=\"black\"> <?php echo $row[\"itemDesc\"]; ?> </font> </td> <td width=\"10%\" height=\"25\"> <font face=\"verdana\" size=\"1\" color=\"black\"> <a href=\"cart.php?action=add_item&id=<?php echo $row[\"itemId\"]; ?>&qty=1\">Add Item</a> </font> </td> </tr> <tr> <td width=\"100%\" colspan=\"4\"> <hr size=\"1\" color=\"red\" NOSHADE> </td> </tr> <?php } ?> <tr> <td width=\"100%\" colspan=\"4\"> <font face=\"verdana\" size=\"1\" color=\"black\"> <a href=\"cart.php\">Your Shopping Cart >></a> </font> </td> </tr> </table> </body> </html>
×
×
  • 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.