Jump to content

SusieWoosey

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Everything posted by SusieWoosey

  1. Thank you Gevans I will give that try out. Forgive the inane questons, but am a total novice at php. Suzanne
  2. This is the first page. After you pick yourself up off the floor from laughing....... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php session_start(); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <!-- DW6 --> <head> <!-- Copyright 2005 Macromedia, Inc. All rights reserved. --> <?php include'metatags.php'; ?> <title>Suzanne's Share Chart</title> <link rel="stylesheet" href="2col_leftNav.css" type="text/css" /> <style type="text/css"> <!-- .style2 {font-size: medium} .style3 {color: #FF0000} --> </style> </head> <!-- The structure of this file is exactly the same as 2col_rightNav.html; the only difference between the two is the stylesheet they use --> <body> <div id="masthead"> <h1 class="style3" id="siteName">Suzanne's Share Chart</h1> <?php //include'navbar-affiliates.php'; ?> <!-- end masthead --> <div id="content"> <div id="breadCrumb"> <a href="index.php">Home</a> / Update Low</div> <h2 id="pageName">Update A Price</h2> <div class="feature"> <h3>Suzanne's Share Chart</h3> </div> <div class="feature"> <?php //connecting to the server and then to the database $host = "localhost"; $username = "root"; $password = "4396974"; $database = "shares"; //$table1 = "consumer"; mysql_connect ($host, $username, $password) or die ('Unable to connect to the database server : ' . mysql_error()); mysql_select_db ($database) or die ('Unable to connect to the database because : ' . mysql_error()); // $result = mysql_query("SELECT * FROM $table1 "); // $numrows = mysql_num_rows($result); ?> <FORM NAME="getcategory" METHOD="GET" ACTION="update_low.php"> <select name="commodity"> <option value="Appliances Brand">Appliances Brand</option> <option value="Baby Food Line">Baby Food Line</option> <option value="Brewery">Brewery</option> <option value="Canned Goods Line">Canned Goods Line</option> <option value="Caviar Farm">Caviar Farm</option> <option value="Cereals Brand">Cereals Brand</option> <option value="Clothing Store Chain">Clothing Store Chain</option> <option value="Coffee Shop Chain">Coffee Shop Chain</option> <option value="Cosmetics Line">Cosmetics Line</option> <option value="Designer Clothing Brand">Designer Clothing Brand</option> <option value="Designer Handbag Brand">Designer Handbag Brand</option> <option value="Fast Food Restaurant Chain">Fast Food Restaurant Chain</option> <option value="Footwear Brand">Footwear Brand</option> <option value="Jewelry Store Chain">Jewelry Store Chain</option> <option value="Luxury Automobiles Line">Luxury Automobiles Line</option> <option value="Luxury Furniture Line">Luxury Furniture Line</option> <option value="Snacks Brand">Snacks Brand</option> <option value="Soft Drinks Brand">Soft Drinks Brand</option> <option value="Toys Line">Toys Line</option> <option value="Wedding Dress Brand">Wedding Dress Brand</option> <option value="Winery">Winery</option> </select> <br><INPUT TYPE="submit" VALUE=" Send Request "> </P> </FORM> <?php $category="consumer"; import_request_variables(gp, "formval_"); $commodity = $formval_commodity; //print "category >".$category."< "; $result = 0; $searchstring = "SELECT * FROM $category WHERE `commodity` = '$commodity' ORDER BY lowprice ASC"; //print "<br>Search string ".$searchstring; $result = mysql_query($searchstring); $numrows = mysql_num_rows($result); //print "Found $numrows entries for category.... $category\n"; // print "<br>Result string ".$result; // echo "<br /><TABLE width=60% bgcolor=#FDEDF9 BORDER=1 cellpadding=1 valign=top>"; //echo "<TR><TD width=20%><B><u>id</u></B><TD width=20%><B><u>category</u></B><TD width=20%><B><u>commodity</u></B><TD width=20%><B><u>low price</u></B><TD width=20%><B><u>high price</u></B>"; //echo "<TR><TD width=30%><B><u>commodity</u></B><TD width=15%><B><u>low price</u></B><TD width=15%><B><u>high price</u></B>"; while ($myrow = mysql_fetch_array($result)) { $id = $myrow['id']; $cat = $myrow['cat']; $comm = $myrow['commodity']; $lowprice = $myrow['lowprice']; $highprice = $myrow['highprice']; // print "<TR><TD>".$id."<TD>".$cat."<TD>".$comm."<TD>".$lowprice."<TD>".$highprice; // print "<TR><TD>".$comm."<TD>".$lowprice."<TD>".$highprice; } //echo "</TABLE>"; $_SESSION["commodity"] = $comm; $_SESSION["id"] = $id; //echo $_SESSION["commodity"]; //echo $_SESSION["id"]; ?> </div> <div class="story"> <h3> </h3> <?php //include'paypal.php'; ?> </div> </div> <!--end content --> <div id="navBar"> <?php include'navbar-search.php'; ?> <?php //include'navbar-left.php'; ?> <?php //include'navbar-headlines.php'; ?> </div> <!--end navbar --> <?php include'navbar-bottom.php'; ?> </body> </html> this is the page it goes to <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php session_start(); Print_r ($_SESSION); echo $_SESSION["commodity"]; echo $_SESSION["id"]; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <!-- DW6 --> <head> <!-- Copyright 2005 Macromedia, Inc. All rights reserved. --> <?php include'metatags.php'; ?> <title>Suzanne's Share Chart</title> <link rel="stylesheet" href="2col_leftNav.css" type="text/css" /> <style type="text/css"> <!-- .style3 {color: #FF0000} --> </style> </head> <!-- The structure of this file is exactly the same as 2col_rightNav.html; the only difference between the two is the stylesheet they use --> <body> <div id="masthead"> <h1 class="style3" id="siteName">Suzanne's Share Chart</h1> <?php //include'navbar-affiliates.php'; ?> <!-- end masthead --> <div id="content"> <div id="breadCrumb"> <a href="index.php">Home</a> / Update Low</div> <h2 id="pageName">Update A Price</h2> <div class="feature"> <h3>Suzanne's Share Chart</h3> </div> <div class="feature"> <FORM NAME="getprice" METHOD="GET" ACTION=""> <strong>Enter New Low Price </strong><br /> <INPUT TYPE="text" SIZE="30" NAME="newprice"> <br> <br><INPUT TYPE="submit" VALUE=" Update "> </P> </FORM> <?php //connecting to the server and then to the database $host = "localhost"; $username = "root"; $password = "4396974"; $database = "shares"; mysql_connect ($host, $username, $password) or die ('Unable to connect to the database server : ' . mysql_error()); mysql_select_db ($database) or die ('Unable to connect to the database because : ' . mysql_error()); ?> <?php import_request_variables(gp, "formval_"); $newprice = $formval_newprice; $result = 0; $searchstring = "UPDATE `shares`.`consumer` SET `lowprice` = $newprice WHERE `consumer`.`id` = $id"; //print "<br>Search string ".$searchstring; $result = mysql_query($searchstring); $numrows = mysql_num_rows($result); echo "<br /><TABLE width=60% bgcolor=#FDEDF9 BORDER=1 cellpadding=1 valign=top>"; echo "<TR><TD width=20%><B><u>id</u></B><TD width=20%><B><u>category</u></B><TD width=20%><B><u>commodity</u></B><TD width=20%><B><u>low price</u></B><TD width=20%><B><u>high price</u></B>"; //echo "<TR><TD width=30%><B><u>commodity</u></B><TD width=15%><B><u>low price</u></B><TD width=15%><B><u>high price</u></B>"; while ($myrow = mysql_fetch_array($result)) { $id = $myrow['id']; $cat = $myrow['cat']; $comm = $myrow['commodity']; $lowprice = $myrow['lowprice']; $highprice = $myrow['highprice']; print "<TR><TD>".$id."<TD>".$cat."<TD>".$comm."<TD>".$lowprice."<TD>".$highprice; } echo "</TABLE>"; ?> </div> <div class="story"> <h3> </h3> <?php //include'paypal.php'; ?> </div> </div> <!--end content --> <div id="navBar"> <?php include'navbar-search.php'; ?> <?php //include'navbar-left.php'; ?> <?php //include'navbar-headlines.php'; ?> </div> <!--end navbar --> <?php include'navbar-bottom.php'; ?> </body> </html> CV, those are my two pages, hope you can figure it out. I know my coding isn't the best, but I am willing to learn. Suzanne.
  3. Well thanks for your help guys, I guess my web page is doomed to be forever unwritten and functioning. As far as I can see everything happens on a webpage 'all at the same time' from top to bottom, I don't really know properly how PHP works, I can only go on my previous experience and that means using BASIC many years ago, but of course PHP doesn't work like that, execute a bit, then do something dependent on the input from the user, execute a bit more of the 'program', etc.... I think this is why I cannot work out why I lose my variables, I am desparately trying to understand how this all works. Suzanne.
  4. Hi CV, Thanks for your patience. I think it is inexperience on my part at writing php code. I imagine if you looked at my code you would cringe, and that I think is where my problem is, sloppy coding maybe. If I stop 'page1' from going to 'page2' then the SESSION variables get written properly. I checked this by taking out the page name of 'page2' from the ACTION part in the form. It stays on 'page1', and my SESSION variables are printed on the screen exactly as I expect. If I then put the ACTION part back into the form, and make my selection on the form, 'page1' then goes to 'page2' before the SESSION variables have chance to be written, which is why they are empty on 'page2'. I tried using a temporary database to hold the value I want on 'page2'. This works if I keep 'page1' from going to 'page2', the value corresponding to my selection on my form is written to a field on a temporary database, let 'page1' go to 'page2' and the value doesn't change in the temporary database field, because, again, it doesn't get chance to be written there. Does this make sense? My programming efforts are to blame, but i don't know how to fix them. Suzanne.
  5. Ok so we tried the first option, goggled for SESSIONS. Found several sites, tried one, eventually found out I need session_start(); on each page. Why do Web Tutorials not give you the whole picture? Anyway, it would appear my variables are being stored, but, it seems they are not being transfered to my next page. If I use Print_r ($_SESSION); to see what is there on the second page, all I get is Array ( [commodity] => [id] => ) which to me looks empty when it should say something like Furniture and 11. What am I doing wrong? I am trying to work this out, but it is screwing my brains at the moment. Suzanne
  6. Hello, How do i pass a variable to another webpage? Try as I might I cannot figure it our and make it happen. I have a small database (MySQL) I have created and I am trying to write a routine to update various fields, as and when I need to. The database is defined as such: CREATE TABLE `consumer` ( `id` mediumint(5) NOT NULL AUTO_INCREMENT, `cat` varchar(15) NOT NULL DEFAULT '', `commodity` varchar(30) DEFAULT '', `lowprice` int(11) NOT NULL DEFAULT '0', `highprice` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM; I need to be able to update the lowprice and highprice fields, I can select the record I want to update, but cannot get the value of the field "id" to pass over to the next page. I am using this code: <FORM NAME="getcategory" METHOD="GET" ACTION="update_low.php"> <select name="commodity"> <option value="Appliances Brand">Appliances Brand</option> <option value="Baby Food Line">Baby Food Line</option> <option value="Brewery">Brewery</option> </select> <br><INPUT TYPE="submit" VALUE=" Send Request "> </P> </FORM> to select the record to edit. How do I pass the contents of the id field to the update_low.php webpage, and so be able to update the correct record with an update query? Hope this is clear. Not very good at asking techie questions, I know what I want to do myself. Thanks for looking in. Suzanne
  7. Sorted. UPDATE tracks2 SET newdate = (SELECT STR_TO_DATE(mydate, '%d-%m-%Y')) solved the problem, I now have my dates sorted, and it is now a DATE field too. Thanks for your help PFMaBiSmAd. Suzanne is a happy bunny again.
  8. Yes it is VarChar, I will try that. Thanks for the suggestion. Suzanne
  9. Server version: 5.0.26-community-nt, MySQL client version: 5.0.22, phpMyAdmin - 2.9.1 I have a field in my table which holds a date. I started out by filling in the date in standard UK date format DD-MM-YYYY. Or at least, what I would call standard UK date. However, I find now that it would have been better to use the format YYYY-MM-DD. My problem, how can I alter this field so the date reads as YYYY-MM-DD? I have tried in SQL from with phpMyAdmin, but all I get is and error with the code I tried, so I tried to do it from a small php program. Firstly with a copy of the table, but all I succeeded in doing was filling the field with same piece of data - the first field it checked. So I changed things and now it fills the field with the last piece of data it finds. I created a second column and tried to get the prgram to feed the corrected date to that, it sort of does, but it stills ends up filled with the same piece of data. How to I get my program to increment and putin the correct piece of data? A snippet of the code I am using is as follows:- The echo's show me that I am changing the date around. if ($result !=0) { while ($myrow = mysql_fetch_array($result)) { $mydate = $myrow['mydate']; echo $mydate . " "; $temp_date = date("Y-m-d",strtotime($mydate)); echo $temp_date . " "; $searchstring = "UPDATE tracks2 SET newdate = '$temp_date'"; $fred = mysql_query($searchstring); echo $fred . " "; $fred++; echo $fred . " "; } } Any help and suggestions would be appreciated. Suzanne.
  10. Well I don't have any idea what class db is or should be, or anything about classes and objects, well very little anyway. Maybe I'll just strip the code out and look for something else to replace it. Thanks for help, Suzanne.
  11. Hi Barand, Thank you for replying. Well I think I understand what you say. I've looked at the code, $db is declared as global as far as I can see in a function at the beginning of the code... function prepare_results($search_results) { global $db, $q, $s_array, $searchterm, $exact_term, $exact_term_array; if ($search_results) { foreach ($search_results as $search_result) { $relevancy = 0; $match = 0; $context = ""; this is the first few lines of the function. The only other time $db is used, is at the end of the code, not inside a function, on line 437 where it all falls to pieces and I get the error. $search_sql .= ' )'; // echo "search sql is " . $search_sql . "<br />"; // -------------------------------------------------------------------------------- // --- now do the actual content search... // -------------------------------------------------------------------------------- if ($_POST["searchtitle"] || $_POST["searchcontent"]) $search_results = $db->get_results($search_sql); <-- line 437 // -------------------------------------------------------------------------------- // --- now prepare the results (assign relevancy AND select context text)... // -------------------------------------------------------------------------------- $results_array = prepare_results($search_results); // -------------------------------------------------------------------------------- // --- finally, display the results... // -------------------------------------------------------------------------------- display_results($results_array); this is the last few lines of the code. Sorry if my ramblings are incoherent, I am not a php programmer. Just hoping to sort it out and make it work. Suzanne Bradley
  12. (php Server version: 4.0.25-standard) (MySQL client version: 4.1.22) Hi all, I am not very clever with .php, but can usually modify something to make it work for me. However, I cannot figure out what this error message is telling me - Fatal error: Call to a member function on a non-object in /home2/andibrad/public_html/16mm/searchmagindex-testnewsearch.php on line 437 Line 437 in my code is - if ($_POST["searchtitle"] || $_POST["searchcontent"]) $search_results = $db->get_results($search_sql); How does the error relate to the php code? What is the error telling me is wrong? Or is it that my php/mysql just doesn't understand it? Suzanne Bradley ps. I can post the whole of the search code if necessary but it is rather long. The code can be seen at http://www.webmastersherpa.com/content/useful-code/32/#c5t_form
  13. MySQL client version: 4.1.22 - Server version: 4.0.25-standard - phpMyAdmin - 2.10.0.2 (it's what they provide). My table was originally defined thus:- CREATE TABLE `triviadata` ( `id` int(11) NOT NULL auto_increment, `date` varchar( NOT NULL default '', `year` varchar( NOT NULL default '', `data` text NOT NULL, PRIMARY KEY (`id`) ) TYPE=InnoDB ; date contains the day/month part of the date i.e. 18 Apr, year contains a four digit number i.e. 1969. I want to join two fields together from my database into a new field on a search query, namely date and year fields. I have tried searching on the 'net for a solution but all I can find is ways of joining tables. I can do that, but cannot get two fields to join. My attempts give results which are not really what I require. SELECT id, date & ' ' & year AS newdate, data FROM `triviadata` WHERE `year` LIKE '%1969%' LIMIT 0 , 30 it outputs the id, and data fields ok, but the newdate field is a 'zero'. I figure it is ANDing them together maybe? SELECT id, date + ' ' + year AS newdate, data FROM `triviadata` WHERE `year` LIKE '%1969%' LIMIT 0 , 30 this doesn't work either. All I get is the year field with a nuber from the date field added to it. SELECT id, date || ' ' || year AS newdate, DATA FROM `triviadata` WHERE `year` LIKE '%1969%' LIMIT 0 , 30 this doesn't work, all I get is the newdate field equal to '1' for all occurences of 1969 that are found. I know I probably should have used a proper date field, but it can't cope with dates prior to year 1000 and my trivia database has many entries for years prior to this, including BC years. So how do I do it? I can't write my php till I know how. Suzanne.
  14. Thanks for the comment Fenway, but I have to ask - Why? What problems is it likely to cause me? I'd appreciate the advice. I have another MySQL database that stores a lot of URLs for another website, and all the URLs for that are created 'on the fly' as the webpage is put together, which is how I think you suggest it should be done. How would I go about making just a small part of the field into a URL, such as my example words 'Rolling Stones', those two words are surrounded by lots of other text. Bearing in mind there is nearly 83,000 entries on the database and only about 250 of them refer to the Rolling Stones. The data in the field doesn't change, unless I need to amend it or add something extra to it. The URL for the website is http://www.andibradley.com/whatya/index.php if you like to have a look-see. Regards, Suzanne.
  15. Thanks very much, I knew there might be a way. I'm still learning the commands. Very much appreciated. Suzanne.
  16. Server version: 4.0.25-standard. MySQL client version: 4.1.22. (Both provided by my webspace reseller) Is it possible to update just part of a field? Let me see if I can make that clearer. I want to update just a couple of words in a field on my database, I know I can update an individual record, but there is more than one occurance of the words I want to change. Is it possible with the UPDATE command, or do I, as I suspect, have to write code to split the field contents , change the bit I want changed, then join it all back together and then place it back in the field? Is that clear? I hope so, not easy to write it down. Just for example suppose my field contains the following text:- The first night of a 30 date tour with The Everly Brothers, Bo Diddley and The Rolling Stones, Little Richard was later added to the bill to boost poor tickets sales. I have a number of records on my database that contain 'The Rolling Stones' - I want to change that to '<a href="ppage09.php#stones">Rolling Stones</a>' so that when it shows up in a browser, it shows a link for a page I have on The Rolling Stones. Some entries on the database (new ones) are already like that, older entries are not. I need to change all old entries to show the URL style. Can I do that with UPDATE, or do I need to write some code and process the field (making necessary changes), and then do an UPDATE. Hope that's clear, Suzanne (who now has an online database in MySQL accessed via a browser page, I did it at last)
  17. Thank you that worked perfectly. Suzanne
  18. Thanks wildteen, yet again you score gold. Well at least I am now into phpmyadmin, but I get this error when I first get in - The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results. I expect it's something I haven't set up properly in config? The char set appears to be set at - UTF-8 Unicode (utf8) - what would be best? Best wishes, Suzanne
  19. Thanks Wildteen, I shall have a read. Suzanne
  20. A sticky? I've looked all over these boards for some help before posting. Suzanne.
  21. OK I give up, what did I do wrong? I got Apache working, I got php working, now I can edit .php files locally. Works a treat. I've installed mySQL and it seems to work,  but there is noway I can work it from the command line interface. Hence my attempts at installing phpMyAdmin. I have failed miserably, all I get when I open index.php in my browser is - phpMyAdmin - Error  - Cannot load msql extension. Please check your PHP configuration. - Documentation. I presume that is how phpmyadmin is started?? Or do I use main.php? I have looked at the documentation till I am blue in the face. Help - what have I missed or done wrong. I am very confused as to where the phpmyadmin installlation should go. Suzanne (UK) :(
  22. I think it's Apache. It appears to only do it when I close Apache Server down, and restart it. (I think). Anyway Apache seems to be OK now, I get good local .php pages, so my objective of seeing them before committing them to a live website has been achieved. I've installed MySQL, all seems OK. I cannot use it from that command line client though. Suggestions? Suzanne
  23. Hmm, well I guess my euphoria was short lived. Seems today it now won't/doesn't want to work. I get this error when I try to start it - Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock could not bind to address 0.0.0.0:80 no listening sockets available. What have I done wrong or what have I not done? Any ideas? Suzanne.
×
×
  • 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.