Jump to content

Donald.

Members
  • Posts

    19
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Donald.'s Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've figured it out. It was something with the website rather than my regexp...
  2. Hey guys, I'm back for more help. I haven't been here in a while since I was busy with college but now that finals are over I can once again get going with little things I do. As a side project I'm scraping some data online and I'm having a ton of trouble getting a hold of the price. I've tried countless possibilities on how to get it, but I can't seem to grab it. Here's part of the HTML section of the contents I'm trying to scrape. In this case I'd want the 6.58 <div class="item-block-top"> <h3> $6.58 <span style="float: right; color: #8BD442"> <img src="/static/images/icon/up.png" /> 0.76% </span> </h3> <div class="item-details">Helm: +31% Extra Gold from Monsters<br> Weapon: Critical Hit Damage Increased by 100%<br> Other: +58 Dexterity<br> <br> Item Level: 66</div> </div> I'm using python with the BeautifulSoup extension... Here's the section of my code relevant to the price. I've already managed to get several other information on the items im scraping but the price is giving me headaches. # Grab the price to the price of the item using REGEX priceString = '<<I REALLY DONT KNOW WHAT TO PUT HERE ANYMORE>>' FinderPrice = re.compile(priceString) # Store all of the prices found findPrice = re.findall(FinderPrice,webpage) I even tried getting all of the content inside the <h3> tags and that still gives me a blank result. I was thinking that maybe it's because there is a $ character and that signals the end(?). priceString = '<h3>(.*)</h3>' Any help is really appreciated. Thanks, Donald.
  3. Change the include "connect_to_mysql.php"; to require_once "connect_to_mysql.php" so the page ensures you get the file before executing anything else. It's usually a good practice, in my opinion, as the script will not work if you can't get that file. <? require_once ("connect_to_mysql.php"); $result = mysql_query("SELECT * FROM posts") or die("SELECT Error: ".mysql_error()); //This will tell you if there is an error with the query. while($row = mysql_fetch_array($result)) { echo $row['title'] . " " . $row['content']; echo "<br />"; } ?> Also what are you encountering a blank page, any errors?
  4. Thanks, with some fine running of the query I managed to add some more info as well. You're amazing!
  5. I'll try to come up with an idea, but is there a way to limit the concatenated data ONLY to have the last 5 or 10 events displayed? The table has a date field so I could theoretically arrange it by date descending but I don't know how to only concatenate the last X terms.
  6. Thanks, I had no idea this was possible, its has definitely helped me. However, I'm experiencing one little problem which I think might have something to do with the amount of data it can hold. Some queries are returning everything as they should but some get cut right in the middle. Do they have a character limit? Because some users have more than 80 events and generate quite a long list.
  7. Hey guys, I've been trying to think about a solution to this problem without having to put a query within a while loop displaying the results of a query (querynception) but I guess my skills are not there yet. I'm sure there is a way to display the sum of the total points and each entry a user has after running a search. Here's a small explanation of how the table is set up. logs +----------+------------+--------+ | usr_id | event | points | +----------+------------+--------+ | 1 | event 1 | 5 | | 2 | event 3 | 10 | | 3 | event 2 | 7 | | 1 | event 4 | 3 | | 1 | event 2 | 7 | | 1 | event 1 | 5 | +----------+------------+--------+ I want have a search function that display the following when I search for usr_id=1. I know I can use the SUM(points) as totalPoints to get the sum but how can I echo it? Am I missing something in the query and how can I echo it without having a query inside another? mysql_query("SELECT usr_id, event, points, SUM(points) as totalPoints FROM logs WHERE usr_id='{$usr_id}'") or die(mysql_error()); Thanks!
  8. Try echoing the array to see what the values in them are.
  9. $check = mysql_query("SELECT * from csci01members"); $check_count = mysql_num_rows($check); if ($check_count == 1) { die (" The user is already a member."); } You are selecting everything from the table. There should be a WHERE clause to see if the username is already there and then if the search returns no matches you can proceed to add the member. Assuming you've got 1 member in the table, that script will always end up there.
  10. Each if($_POST['Submit']) should have a different unique name so it knows which one you're actually wanting to run. Name them Submit_index, Submit_about, Submit_rentals, you get the deal. You'll also need to change the name of each submit button to match accordingly. Is it changing all the text files into blank ones or just the one you hit submit?
  11. Not the correct section to post it in, but here it is... http://forums.phpfreaks.com/index.php?action=profile;area=showposts;u=135121
  12. This is not what Pikachu2000 meant when he said to parse it with the code tags and formatted it properly. You also need to indent it so it flows easily when reading what it does.
  13. You're totally right, he missed the first ' in the insert statement. This should do the trick. $insert = "INSERT INTO tblPurchasesHeader (Vendor, InvoiceDate,Invoice,TotalAmount,TaxAmount) VALUES ('".$vendor."','".$date."','".$invoice."','".$total."','".$tax."')";
  14. The function session_is_registered() was deprecated in PHP 5.3 and removed in 5.4 so I'd stay away from that. I'd use something else assign sessions. Something like this will work. <?php session_name('loginSession'); session_start(); $_SESSION['username'] = "Admin"; //Sets the sesision username var to Admin //Now we can use this to display content if the there is a session or username or by username //We can use it for everyone logged in or just a particular user if($_SESSION['username']) { //Your sidebar here for everyone logged in } if($_SESSION['username'] == "Admin") { //Your sidebar here for user with username Admin } ?>
  15. I might be wrong as I'm not a pro, but try the following. Replace: $conn->Execute($insert); echo "The information has been submitted."; With: if(mysql_query($insert)){ echo "The information has been submitted."; }
×
×
  • 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.