Jump to content

Hybride

Members
  • Posts

    286
  • Joined

  • Last visited

Everything posted by Hybride

  1. Actually, I managed to figure it out (somehow that keeps happening after I post on this forum)... To those interested, $xml = simplexml_load_file('products.xml');foreach ($xml->items->item as $cat) { preg_match('#whatever#i',$cat->category,$matches); if($matches[0]) { echo $cat->title.'<br/>'; echo $cat->model.'<br/>'; echo $cat->price.'<br/>'; }} It loops through the entire document, finding only whatever you're trying to match, printing the respected title/model/price, though that can easily be changed to fit your needs.
  2. I know this is very simple, but alas, I can't figure it out. I need to grab the CData from an XML file using SimpleXML, loop through every item in the XML file, pick out specific products and then put them in a different file. Using echo "<pre>",print_r($xml,true),"</pre>"; the structure goes as - id - title [items] - item - model - title - category or basically $xml->items->item then whatever node I need. It's the title that has the <![CDATA[whatever]]> and I can't figure out how to extract that information as well. It just shows up as SimpleXMLElement Object. I tried to do something along the lines of: $xml = simplexml_load_file('products.xml'); if($xml->items->item->category == ";whatever;") { print $xml->items->item; } Where assuming the category is what I need, then only the items are printed (but I realised this is more of a Perl thing and I became confused.) I tried looking at these pages: Reading XML with elements and attributes and Extract XML via PHP which helped, but this is the first am actually doing XML->PHP work and not sure how to actually do it. Any help would be sincerely appreciated.
  3. Syntax is actually correct, but the reason for the error is: echo "<p>Thank you, <b>$_POST[name]</b>, for your message!</p>";} // <- remove that curly brace over here
  4. Please make sure to get rid of that hard-coded password: it's a severe breach in security. You're only asking to be hacked. On that note, you were missing some curly brackets in your code (I also indented the code for readability): $password = $_POST['password']; if ($password =="pgpg7755opcd") { $itemid = $_POST['id']; $imagelink = $_POST['imagelink']; $name = $_POST['name']; $description = $_POST['description']; $price = $_POST['price']; $member = $_POST['member']; $noted = $_POST['noted']; $rare = $_POST['rare']; $nontradable = $_POST['nontradable']; $staffonly = $_POST['staffonly']; $lettercatagory = $_POST['lettercatagory']; if (!$itemid || !$name || !$description || !$price || !$lettercatagory) { echo '<tr><td colspan="5" style="color: #888888; font-style: italic;">Item ID: <form action="acp.php" method="POST"><input type="text" name="id"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">Image link: <input type="text" name="imagelink"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">Name: <input type="text" name="name"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">Description: <input type="text" name="description"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">Item Price: <input type="text" name="price"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">Member: <input type="text" name="member"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">Noted: <input type="text" name="noted"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">Rare: <input type="text" name="rare"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">Non-Tradable: <input type="text" name="tradable"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">Staff only: <input type="text" name="staffonly"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">Letter Category: <input type="text" name="lettercatagory"/><input type="submit"></form></td></tr>'; } else { mysql_query("INSERT INTO items VALUES ('', '$itemid', '$imagelink', '$name', '$description', '$price', '', '$member', '$noted', '$rare', '$nontradable', '$staffonly', '$lettercatagory', '', '')") or die(mysql_error()); echo "Item added!"; echo '<br></table> </div> </div> <div class="center"> Change a Price </div> <div class="inbox_body">'; $id = $_POST['itemid']; $price = $_POST['newprice']; if (!$id || !$price) { echo '<tr><td colspan="5" style="color: #888888; font-style: italic;">Item ID: <form action="acp.php" method="POST"><input type="text" name="itemid"/></td></tr> <tr><td colspan="5" style="color: #888888; font-style: italic;">New price: <input type="text" name="newprice"/><input type="submit"></form></td></tr>'; } else { //display data $get = mysql_query("SELECT * FROM items WHERE itemid='$id'"); while ($row = mysql_fetch_assoc($get)){ // get data $oldprice = $row['price']; } $change = $price - $oldprice; mysql_query("UPDATE items SET changeprice = $change WHERE itemid='$id'"); mysql_query("UPDATE items SET price = $price WHERE itemid='$id'"); mysql_query("UPDATE items SET beforeprice = $oldprice WHERE itemid='$id'"); echo "Item has been updated."; } // <-- missing these } // <-- } else { if (!$password) { echo '<tr><td colspan="5" style="color: #888888; font-style: italic;">ACP Password: <form action="acp.php" method="POST"><input type="text" name="password"/></form></td></tr>'; } else { echo "Incorrect password."; } }
  5. I do believe Javascript is the answer to your problem. You can use CSS in conjunction with JS, but I don't think CSS can do it on its' own (although, someone else can actually clarify/correct that if they could.)
  6. Try: $sql = "SELECT DISTINCT(university_1), latitude, longitude FROM stores ";
  7. This page may be of some help: MySQL server has gone away. You may have to cut up your query in half and try to run them like that.
  8. It depends on the server, really. I don't actually have the options available to me, as I said, it was on a hosting company and they did the changing (but it didn't work, don't know why). Anyway, my best guess would be to check your mysql configuration files, and depending on the installation, they should be somewhere in directory /usr/local/mysql/data. This page might also be of some help: MySQL Server has gone away.
  9. I had, it was on a hosting service for my company. I put it in the bug ticket, they said that they increased the timeout time on MySQL (so you do have to tinker with the settings a bit, just not sure which). Idk if that's the answer, as it didn't work for my sites, but that might be an option. Also, you might try cutting up the file and uploading it in batches if it doesn't work. Painful, I know.
  10. I just checked on my browsers, including Chrome, and not sure where you're seeing this. It comes up fine.
  11. Depends what kind of S/FTP client it is, but I usually do right-click, properties, and then change permissions as needed. Here's a decent tutorial on explaining permissions: File permissions.
  12. Background repeat.
  13. $query = mysql_query("SELECT DISTINCT(event_tag) FROM calendar WHERE MONTH(caldate) = '$calmonth2' && YEAR(caldate) = '$calyear' ORDER BY DAY(caldate) LIMIT 1") or DIE(mysql_error()); ought to do it.
  14. Try: $result = preg_split("/#|=|\s/", "name =abcd #132542") "\s" is used for matching whitespace.
  15. Am not entirely sure what you're doing with that query in the first part (it looks backwards to me), but this is your if/elseif/else statement fixed up: if ($percentage<=25) { echo "you are " .$row['poor']; } elseif ($percentage >25<=50) { echo "you are " .$row['acceptable']; } elseif ($percentage>50<=75) { echo "you are " .$row['good']; } else { echo "you are " .$row['geek']; } More than that, I would recommend using switch/case statements for sanity's/readable sake.
  16. if (mail($para, $asunto, $mensaje $header)) { is missing a comma. Change it to: if (mail($para, $asunto, $mensaje, $header)) {
  17. Your margins are strange, why do you have the #txtHint3 (that's the last one) be closer to the page than the #txtHint2? You can also try absolute positioning them.
  18. Can you post the HTML also? Not sure if this is intentional but #nav li ul, #nav li ul a{ background-color:#414141; color:#FFFFFF; font-style:bold!important; text-align… /* <-- that text-align should be removed */ width: 200px;
  19. Can you show your code, please? Are you using a loop to show all of your values?
  20. Your site seems to be down, but to answer your question - if the second is working, and not the first, then the two variables for $bamm are not actually returning anything. Without the rest of the code, there's no way to be sure, but check that the first 2 variables actually have something.
  21. I may be wrong, but I think the only way to do it is Javascript (at least, that's the most logical that I can tell).
  22. "Stick" as in all the way at the bottom? Trying to remember from memory, but try this: #footer {position:absolute;bottom:0} Otherwise, post your code and please be a bit clearer on what you want.
  23. Do you have code you can show us? Otherwise, you can use margins and padding with your absolute and relative to get it to the position you want.
  24. Yeah it does, here's a page detailing it: CSS image map.
  25. If this is an online form, a table manipulated with a CSS print file should work. Check this page out for a good basic design: Create a simple print CSS. If this is offline, I think it's a matter of how your program/printer is set up? You can scale to fit on a single page, or make the form itself smaller... it all depends what program you're using.
×
×
  • 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.