Jump to content

dombrorj

Members
  • Posts

    67
  • Joined

  • Last visited

    Never

Everything posted by dombrorj

  1. I'm working with little php background here and trying to write mysql table data to a text file. So far what I have is... $query = "SELECT * FROM `list` "; $result = mysql_query($query) or die("Query failed : " . mysql_error()); while ($line = mysql_fetch_array($result)) { $file = "export.txt"; $fhandle = fopen($file, 'w') or die("can't open file"); $stringdata = $line["listid"]. "\n"; fwrite($fhandle, $stringdata); //write to text file fclose($fhandle); } All this does is write the very last row in my table to the text file. If I switch fwrite to the 'a' mode, it works... but I don't want it to append to existing data. Ideally I'd like to wipe any contents in the existing text file clean before adding all new data from the query. Any thoughts? Thanks for the help!
  2. Using parse_url, is there a better way to get the Host and Path of something like: http://site.com/folder1/folder2/page.html?var1=1&var2=2 I did this and is working, but not sure if this is the best way to go about it. Or is this good? $url = $_SERVER['HTTP_REFERER']; echo parse_url($url, PHP_URL_HOST) . parse_url($url, PHP_URL_PATH); Thanks for the help!
  3. Ahh Thank You!! And I appreciate you linking me to your code QuickOldCar.
  4. Hi, Hoping someone can help me out with something that is probably really simple, but I can't seem to figure out. I'm storing referring URLs, and some of them are over 1,000 characters because of all the variables. How would I Get only the actual url and not all the variables, such as... http://www.google.com/ajax/search/start.php?eid=AAAAAwAgACAAAAH0v4jVmjrvBVRZxy6_CX4Rl8t6reioLF6htZb4qitx_2nR3dkfj7b8VJhn43Rc1JD0_Mn8S05zD1-Zg35FdE4rE6-cSmGB4Jrvebc3B6sFCY1vamkir_c--8ESJIzZeybl-22ddGIv4qP3JFtmaaLXWpOZSkyeSN17nD_I-vMnhsV8nY-gHeYTC4vqddkJQYI2bBSXP9Y0KHE189A1tFH9Cyprt4hpubL7KCKE2EPG4rErzSgnERqJMiqeLDtmdUs1Fe6e6nhaoE5bBim00LCnsfvQfYfX2wWkpglx2cZIASlb7H3AohF0amFZN2ZVeQBMhR7PsCNhhIXuuxa39-mxdjARVLqwpoQHXa2ODMu7jyNA7CO5pJ56F7vqtL2h9oDA-YlQ8BBgfXwKrmKaTKgWEU-mRqMeJ076B-JGPY6NjOg9Vkpe3KVhzh_L_rF4fz7kbQYKOgyGvmnsIEdkqlVCePqDOTvkKNMwOEdDW1LqYXIG3i3u21GGZAOqUslMnCix0sVIE09ENi-K6k75mvHxvTADiBXgPAw03BodR3I5hBfw3uFjkBKAfGJ1ir_03z5ec0Yz9RoSIOEYcZlvxeiTP-V4OnTz7n5eVYzD3o0c9mfyAYhLh4KY9LVxy88Pux2NSeIG3XAWextqYtPJhoIxWvO1qSp9tJBl_smywvlF2oZRQNCCbNNGeJ4BhdvmZ3OG7e0Jjm9FL4zEadh5pENY1A0lSInBN_reFiqe2iZh2_N8NX83Y51Tl0bn_Xrhf9SOI&c=4&f=0&ui=6002910216647-id_4d487a6db36b33126309761&en=1 I only need the info up to the "?" http://www.google.com/ajax/search/start.php My php code looks like: $referer = $_SERVER['HTTP_REFERER']; mysql_query("INSERT INTO `refs` (`referer`) VALUES ('$referer')"); Is there an easy way to handle this?
  5. Got it... man I need to get past this learning curve! Just needed to add: $custname: urlencode($name); Then change all the $name instances to $custname. Thanks again for all your help!
  6. Thanks for all the help with this ChemicalBliss. The URL with the variables I want to Get is: /order-confirmation.php?item=136&reciept=6BB4B95E&thename=Dave+Test&cemail=test%40test.com&country=US&zip=90210
  7. Hmmm... I wish I could do that but the values are passed by my merchant processor.
  8. Thanks for the help! I should have been more clear though on the message part, because there's more text after the link. I'ts more like: Click this link http://mysite.com?/thename=$name&var=$var2 more text... more text...
  9. Hi, I'm trying to do the following: $name = $_GET['thename']; $to = "some@email.com"; $subject = "Subject of Email"; $message = "Click this link: http://mysite.com?$name" $headers = "From: Me" . "\r\n" . "Reply-To: my@email.com" . "\r\n" . "X-Mailer: PHP/" . phpversion(); mail($to, $subject, $message, $headers); The problem I'm experiencing is that the Get function retrieves "/thename=First+Last name", which converts to a broken link in the message (because of the "+" in the url). How would I use urlencode to make sure the Get replaces the + with a %20 in this instance? It doesn't seem that I can use php in the message itself. Thanks!
  10. Hello, I have a simple text file that looks like... 53 23243 322 92443 3990 When I use Insert Into through a php script to import the data into my table, it enters the data into the database but adds an unwanted carriage return to the end of each value. Here is the php script used to import the values... <?php include '../config.php'; mysql_query("TRUNCATE TABLE `master`"); if($fh = fopen("numbers.txt","r")){ while (!feof($fh)){ $line = fgets($fh); if($line){ echo "Importing value: $line <br />"; mysql_query("INSERT INTO `master` (`numberid`) VALUES ('$line')"); } } fclose($fh); } ?> So now the value in 'number id' looks like... 53 23243 322 92443 3990 The extra carriage returns is causing problems. Is there an easy fix for this? Thanks!
  11. Thanks for merging Pikachu2000. Didn't meant to try to scream for attention with 2 threads. It was just suggested to me to start a new thread in the other forum. akitchin, I double checked both tables and the labels are identical. Alll lowercase, no extra spaces. The only difference is that table 1 has columns and table 2 has 3 columns. For the second issue, yeah... I agree it's probably a design flaw from the programmer. Here's some sample data. Here's some example data: Table 1 (don't want to delete anything here. All unique values that were imported): index | username 1 | dave 2 | john 3 | steve 4 | jim 5 | rob Table 2 can look like this... index | username | email 1 | dave | (blank) . . . . 35 | dave | dave@email.com . . . 90 | (blank) | dave@email.com I need to keep 1 instance of any of those three variations, but not multiple instances. Does that make sense (even though it probably doesn't make sense from a design perspective). Thanks again for the assistance here.
  12. Hey akitchin, Thanks for the help and for pointing me to the site explaining how to remove similar values. That was helpful, but need just a little bit more help... I did exactly as you have here for the first query, making sure the tables and labels were accurate, and it didn't seem to work. I just received message: "0 row(s) deleted" even though duplicates between the two tables do exist. Any thoughts on what may have gone wrong here? DELETE FROM table2 WHERE username IN (SELECT DISTINCT username FROM table1) As for the Little Gut code, his code worked except I'm realizing now it has to be a bit more specific. The table looks like this: id | username | email In some instances, the 'username' field is blank. So the code given deletes all of those lines. The other issue is that it deletes the entire row. But, if it has a value for 'email' I want to keep that email information there (so just remove 'username' from the row). If there is no value for 'email' then it can delete the row. Here's the code again from The Little Guy that is deleting the row entirely, including blank fields: delete from table1 USING table1, table1 as vtable WHERE (NOT table1.ID=vtable.ID) AND (table1.username=vtable.username) Thanks again!
  13. I posted a similar thread in the php forum thinking I needed a php script, but was recommended to ask this question over here. I have a SQL database that collects visitor's info and am trying to figure out how to search and remove any duplicate entries. It's a little tricky because I some duplicates are may be on two seperate tables. Here's what's going on... Table 1 Looks Like This... Index | username Table 2 looks like this... id | username | email I don't want to remove anything from table 1 ever, but * if the username is in 1 and in 2, remove username from table 2. * if multiple instances of username is in table 2 remove the duplicates and leave one entry (if its not in table 1) * if multiple instances of email is in table 2, remove the duplicates but leave one entry The Little Guy suggested this code to tweak, but can use some assistance with that. delete from table1 USING table1, table1 as vtable WHERE (NOT table1.ID=vtable.ID) AND (table1.field_name=vtable.field_name) I was originaly thinking I needed a php script so I can set a cron to run a process periodically to clean up the duplicates, but I think I first need to figure out how to do this from within phpmyadmin. Let me know if I left out any other details. I'm kinda at a loss here, and any help is really appreciated. Thanks!
  14. Perfect! Backup complete, and now i'll give the code a shot. Thanks OldWest and Little Guy. Much appreciated.
  15. I'm realizing I probably wasn't clear enough earlier so I'll try again. And Table 1... Index | username Table 2 looks like this... id | username | email So I don't want to remove anything from table 1, but if the username is in 1 and in 2, remove username from table 2. if multiple instances of username is in table 2 remove the duplicates and leave one entry if multiple instances of email is in table 2, remove the duplicates but leave one entry I was thinking a php script so I can set a cron to run it periodically and clean up the duplicates. Let me know if I left out any other details. Thanks!
  16. Yep, I'm looking at the tables in phpmyadmin now scratching my head.
  17. I have a database that collects visitor's info and am trying to figure out how I can execute a php script that will search and remove any duplicate entries. I have table 1 that has a list of unique usernames. Table 2 adds usernames that may or may not be in table 1. I need to keep all usernames in table 1, but delete any that also appear in table 2. There are also some instances where the username is added twice to table 2, but not included in table 1. In that case, I need to remove the duplicate entries. I'm really not sure where to begin with this and hoping someone will be willing to to help me out (newbie alert!) Thanks!
  18. Thanks for the tip. But, to be honest, sounds like I'm way over my head. I'd be willing to pay a few bucks for your time if you're able to help me put this together. I can give you more detail over PM if interested?
  19. Hi, I'm trying to get a working php script that will redirect visitors based on a number of variables. I first want to check the country the visitor is from, and redirect based on the user's country ip address. If visitor is not from the US, then go to google.com (for example)... but only after also checking some other variables. I want to also redirect any user (including US visitors) who are using a mobile device browser/cell phone, and redirect visitors coming from a Linux box. I'm not sure how to add those as if/else statement. Any help would be appreciated. Here's what I have so far... Geo ip Redirect: ------------------- <?php require_once("GeoIP.inc"); $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); if($country_code == 'US') { header('Location: http://www.google.com'); } else { header("Location: http://www.redirect.com"); } ?> Mobile Browser Redirect: ------------------------------ require_once('mobile_device_detect.php'); mobile_device_detect(true,false,true,true,true,true,true,'http://redirect.com',false); So not sure how to detect and redirect Linux users, and then how to link these all together in one script so it checks all variables before sending user to destination URL. Hope you can help. I really appreciate it!
  20. Thanks jcbones. That does the trick, without the images. It's a small page, so I'll just move the images to the same directory as index.html, and that should do it. Thanks!
  21. Shoot! Sorry, wrong forum. This should be under the Apache forum. Sorry 'bout that, but can still use the help if anyone knows.
  22. I've been working on this for several hours, and I know its something you guys can do in about 3 seconds. So hoping you don't mind helping me out here... I have the following code, which is not quite working: RewriteCond %{HTTP_HOST} ^mysite.com RewriteRule ^vote/(.*)$ wp-content/blogs.dir/2/vote/$1 [L] I'm trying to load the index.html page in mysite.com/wp-content/blogs.dir/2/vote load by using mysite.com/vote, but I get a 404 - page not found. The only way it sort of works is if I go to mysite.com/vote/index.html. Even then, it doesn't load any of the images (which are stored one level deeper in an 'images' directory: mysite.com/wp-content/blogs.dir/2/vote). Any thoughts on what I'm doing wrong here? It may be important to note that Wordpress is installed on the root directory. Thanks!
  23. Excellent! Thanks teamatomic. That's your script above, which you helped me out with before. I appreciate it!
×
×
  • 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.