Jump to content

virtuexru

Members
  • Posts

    200
  • Joined

  • Last visited

Everything posted by virtuexru

  1. I got to show the HTML. Now what I need to do is just strip Line 55: <input type=hidden name=asd value="a490b986af96b1937b9d6ba6796acd11"> I need to strip it so I have a variable as: "a490b986af96b1937b9d6ba6796acd11"
  2. I need to read the source of an HTML page and be able to strip one 11 letter/number long key from it. Has to be done through PHP. I'm not so much worried about the stripping of the 11 letter/number but on how to use maybe: fopen To read the file?
  3. Now, does anyone know how I can create some kind of cron job or something to upload the .CSV file hourly?
  4. It worked. You are the man! Here's what I did: header("Content-type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=" . date("Y-m-d").".csv"); readfile('data.csv');
  5. Figured it out! Only halfway though. I got the CSV Excel file to print out on a page. Now, how would I be able to save the file? Here is my code: <?php // target $url = "http://whatever.com/"; // spoof $refer = "http://whatever.com/"; $ch = curl_init(); // set the target url curl_setopt($ch, CURLOPT_URL, $url); // referrer curl_setopt($ch, CURLOPT_REFERER, $referer); // set user agent curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // follow curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // return // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // how many parameter to post curl_setopt($ch, CURLOPT_POST, 1); // extra params curl_setopt($ch, CURLOPT_POSTFIELDS, "cc=ASD&key=xxx1234&by=1234134"); // log errors $error = curl_error($ch); // execute curl,fetch the result and close curl connection $result = curl_exec ($ch); // create new file $fp = fopen("data.csv", "x"); // THIS DOES NOT WORK... curl_setopt($ch, CURLOPT_FILE, $fp); // close connection curl_close ($ch); // display result print $error; ?>
  6. Maybe I'm in the wrong spot, not sure if I could do this with PHP. Here is my basic problem: I have a link that is connected to an excel file. The link was made through a Javascript Popup type thing: <a href="javascript:document.csv.submit()" title="Data">Link</a> <form name="csv" method="post" action="http://whatever.com/data.cgi"> <input type=hidden name=code value="X"> <input type=hidden name=key value="KEYHERE"> <input type=hidden name=number value="555"> </form> Basically, my problem is that I have to periodically DOWNLOAD this file, then UPLOAD it to my server to keep my data updated (about once an hour). I would like to figure out a way to be able to automatically download the data then upload it via FTP or web or something. Anyone have any ideas? Thank you so much in advance .
  7. You guys are great. I feel like a retard. Thank you!
  8. OK, I have a few rows in my database that are filled with the following string: $CALL So, I'm trying to do a if/else statement to replace that with just "CALL" but it seems as though the IF statement isn't catching it at all. Here is my code: <?php while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $o_price = $row['_price']; if($o_price == "$CALL") { //problem is that it's not catching this section, it skips directly to else, even when the row is actually "$CALL" $price = "CALL"; } else { $o_price = str_replace(",","",$o_price); $o_price = str_replace("$","",$o_price); $price = $o_price + $overflow; $price = "$".$price; } ?>
  9. Figured out it using that, thank you. Here was my final code: <?php // remove number $string = $content; $pattern = '/718-555-5454/'; $replacement = "001-203-509-1105"; // replace it with nothing $description = preg_replace($pattern, $replacement, $string); ?>
  10. OK. So I have a string that for example is: <?php $description = "Please call 917-000-0000. Than you."; ?> I want to either just completely strip the "917-000-0000" or replace it with another number. What's the easiest way to go about doing this?
  11. But now here is the real question, here is my code: $o_price = $row['_price']; $o_price = str_replace(",","",$o_price); $o_price = str_replace("$","",$o_price); $price = $o_price + 5000; $price = "$".$price; How should I go about getting the "," back in the right location.
  12. You could just use a simple replace <?php $Number = str_replace(",","",$Number); $Number = str_replace("$","",$Number); ?> If you have more things to remove, Just place them in a array and call str_replace once. This worked . Thanks. I know its not the most creative method but it did the trick .
  13. Or any number in that format like $24,900 to just 24900. Then turn it back? I need to make a script that will take a price and automatically add a certain amount like $24,900 should be $26,900 but I need to strip the numbers before I can use the addition function. Any ideas? Thank you!
  14. Nevermind, figured it out: $added = strtotime($row['_added']); $launch = strtotime($row['_launch']); // show the date it goes off in a readable format $dateoff = date('M d, Y', strtotime($row['_launch'])); $left = ($launch - $added); // rounds it to days instead of seconds $left = round($left / 86400);
  15. OK. Quick dilemma here. I have two dates. One is when a vehicle is "added" and one when it should be "deleted". So it would look like this: Added date: 2008-10-29 Deleted date: 2008-11-03 So I'm trying to do a psuedo "deleted - added = days left" but it doesn't work like that obviously. Should I strip the "-" and try subtraction? But that won't always be accurate. What do you guys suggest?
  16. Tried it. Still doesn't work, lets the form go.
  17. Whats the problem here? I need the script to NOT run if the length is less then 4 characters. First part works (although it still submits the form, second part doesn't even check). function validate_form ( ) { valid = true; if (document.forms[0].elements[0].value == "Search our inventory.." ) { alert ("Please enter a search term."); valid = false; } if (document.forms[0].elements[0].string.length < 4) { alert ("Our search currently supports terms over 4 characters long."); valid = false; } return valid; }
  18. OK, so when someone searches on my site, I add the keyword to a DB. Now I want to show the results as by the "Top 10 most searched keywords".. so my SQL to insert is this: $kcount = "INSERT INTO search (id, keyword) VALUES ('', '$keyword')"; mysql_query($kcount); so say I have "hummer" 3 times and "porsche" 4 times and "toyota" once. How would I make an SQL statement to see the most used keyword (in this case, it would be porsche)? I know this is probably really simple but I'm drawing a blank.
  19. I have a full text search. Basically I want to detect "No results" and echo a certain string. How should I go about doing this? This is the code I have currently: if(isset($_GET['hyb'])) { $keyword = mysql_real_escape_string($_GET['hyb']); $query = "SELECT * FROM ***** WHERE _subModel LIKE $keyword"; } if(isset($_GET['hc'])) { $keyword = mysql_real_escape_string($_GET['hc']); $query = "SELECT * FROM ***** WHERE _make LIKE \"%$keyword%\""; } if(!empty($keyword)) { $query = "SELECT *, MATCH(_make, _model, _desc, _year, _subModel) AGAINST('$keyword') AS score FROM ***** WHERE MATCH(_make, _model, _desc, _year, _subModel) AGAINST('$keyword') ORDER BY score DESC"; echo "<h3>Search Results for: <font color='red'>".$keyword."</font></h3>"; } if(empty($keyword)) { echo "<h3>Please enter a search term.</h3>"; $error = 1; } $result = mysql_query($query) or die(mysql_error()); if($error != 1) { while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $content = nl2br(strip_tags(substr($row['_desc'], 0, 250))); $content = $content; $score = $row['score']; if($score > 1.5) { echo " Results go here"; } etc..
  20. OK. I have an update record form I'm building. I can pre-fill the text fields, but have no idea how to pre-file the drop down fields? For example: <?php $query = "SELECT * FROM vehicles WHERE veh_id = '$id' LIMIT 1"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { ?> // KNOW HOW TO PRE-FILL <tr bgcolor="#E9E9E9"> <td style="padding-left: 5px;"><strong>Model:</strong></td> <td><input type="text" name="_model" value="<?php echo "{$row['_model']}"; ?>" size="25"></td> </tr> // DONT KNOW HOW TO PRE-FILL <tr bgcolor="#E9E9E9"> <td style="padding-left: 5px;"><strong>Odometer:</strong></td> <td><select name="_odometer"> <option value=""></option> <option value="Actual">Actual</option> <option value="Not Actual">Not Actual</option> <option value="TMU">TMU</option> </select> </td> </tr> <?php } ?> Any help? How would I fill-in a drop down with MySQL record data?
  21. RewriteRule /inventory/([0-9]+)/BMW/M3 /inventory_detail.php?id=5991&m=BMW&md=M3 Is that the right track? How do I put in whatever is dynamic, like for instance: "$m" will always be a make, like BMW or CADILLAC how do I integrate that?
×
×
  • 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.