Jump to content

Maq

Administrators
  • Posts

    9,363
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Maq

  1. Cause $x is not incremented. Sorry for that, like I said this is not tested. $x=0; while($pieces[$x]) { $your_array[$i].=$pieces[$x]; $x++; } print_r($your_array); $i++;
  2. Yes I know, but there is a while loop before it. So if there's nothing in the loop then menu_details will never be initialized and if he tried to use that variable in another section he would still receive that same error. I come from a java background, so I'm used to initializing and assigning types to everything Even though, I still don't follow some of these practices in PHP...
  3. Go to your database with PhpMyAdmin or w/e you use and find out what fields you have in the 'subject' table. When you SELECT * it means you select everything and if you only need that one row then only select menu_name. So obviously the position field does not exist.
  4. Then you're going to need to have another while loop inside the EOF while loop to grab all the values. Something like: ***NOT TESTED p.s.- use print_r() to print arrays not echo. $pieces = explode(",", $buffer); $x=0; while($pieces[$x]) { $your_array[$i].=$pieces[$x]; } print_r($your_array); $i++; }
  5. It most certainly does. There used to be a Staff link at the top nav, where you could view all the Groups that rank above members, but that got taken down when they upgraded to SMF 2.0
  6. I would go with b. It is the easiest and fastest way to count the views instead of going through all the records, especially if your video collection expands. Every time someone views the video, just increment by 1 and you're done...
  7. Can you debug by printing out variables like $name? Also, do you have display errors on? ini_set ("display_errors", "1"); error_reporting(E_ALL);
  8. You are if you initialize it It's also better practice to initialize variables.
  9. Could you post the format of the two different CSV files you're comparing and any the conditions? There may be an easy way to do this using, in_array(), but in your situation it may not work.
  10. It's already parsed with commas... comma-separated values. I'm not sure what you're trying to accomplish but this maybe close: $i=0; $handle = @fopen("your_file.csv", "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle); $pieces = explode(",", $buffer); $one = $pieces[0]; $two = $pieces[1]; $three = $pieces[2]; $your_array[$i]=$one.",".$two.",".$three; $i++; } } So you can refer to the array key and explode each line.
  11. Where are you retrieving this from, an excel sheet, database, where? I assume you are using a database because you mentioned MySQL. Do you already have this set up in your database?
  12. You would have to use get_contents or cURL to get the information from that page. This makes things a little more complicated...
  13. You need to initialize it first. Before your while loop do: $movie_details = "";
  14. Makes more sense... I'm not native to English so I confuse TLAs from time to time. You know that SQL is for Standardised Questioning Language? SQL does not stand for that, it stands for 'Structured Query Language'.
  15. but I don't want to specify fields. I need to use the link above Can you explain exactly what you're trying to accomplish? My guess is that you're taking the fields from the URL and using them to query something from your database. Then place the results from that query in the CSV file...?
  16. Are you sure it's even being uploaded? Do you check to make sure, something like: // upload a file if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { echo "successfully uploaded $file\n"; } else { echo "There was a problem while uploading $file\n"; } Post your entire code for uploading.
  17. Actually, CSV stands for 'comma-separated values'.
  18. Here is a sample of how to open and write to a CSV file: $myFile = "your_list.csv"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $field1 . ", " . $field2 . ", " . $field3 . "\n");
  19. LOL, bottom left.
  20. kenrbnsn is right, we're all wasting our time guessing as to what the OP exactly wants. huh?
  21. There are many reasons why you would want to do that. First of all you should have a variable for the return. Something like: function getNumber($first, $second) { if ($first=="abc" && $second=="efg") { echo 'Both $first & $second are true '; return 1; } else { if ($first=="abc") { echo '$first is true, but second is false '; return 4; } else { echo 'Both $first & $second are false '; return 3; } } }
  22. if ($first=="abc" && $second=="efg") { echo 'Both $first & $second are true '; } else { if ($first=="abc") { echo '$first is true, but second is false '; } else { echo 'Both $first & $second are false '; } }
  23. Yes I know because you have to pass $_GET['product_id'] through the URL. You said when a user clicks on: "http://www.example.com/pepper_spray/index.php?productid=sw45" they get the results for SW45. So when you pass variables with the GET method they tag on to the end of the URL and you retrieve them with $_GET[]. Try this: //$get_id = $_GET['productid']; $get_id = "SW45"; $handle = @fopen("Book1.csv", "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle); $pieces = explode(",", $buffer); $productid = $pieces[0]; $producttitle = $pieces[1]; $productprice = $pieces[2]; if($productid == $get_id) { echo $producttitle; echo $productid; echo $productprice; } } }
  24. Does this solve your problem?
  25. Cron jobs run scripts for you. You need to specify the frequency of how often to run these scripts, every 10 minutes, or every Sunday at 12:00 am.
×
×
  • 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.