Jump to content

johnwayne77

Members
  • Posts

    156
  • Joined

  • Last visited

    Never

Everything posted by johnwayne77

  1. nevermind, i was misleaded coz i've replaced a var with another and it didnt worked... so here is the result i get: Array ( [0] => 44444444444444444444444 [1] => 555555555555555555 [2] => 666666666666666666666 [3] => [4] => ) any idea how i can get each array in its variable to use? coz in $first_var i have all 5 arrays... but i would need a loop to echo each array .. like $first_var[] or something.. thanks
  2. yes, i extract order_qty by the SELECT command..but i'm stuck when i'm extracting the $first_var from the var.txt i mean, based on my earlier code, i extract only the first line (1 line) from that .txt but if the quantity is 2 units let's say, i need to extract first two lines ... are you with me?
  3. i have this code: $result = mysql_query("SELECT products_id FROM orders_products WHERE orders_id = $order_no ") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $var = file("var" . $row['products_id'] . ".txt"); $first_var = array_shift($var); $var= array_map('trim', $var); file_put_contents("var" . $row['products_id'] . ".txt", implode(PHP_EOL, $var)); echo $first_var; } so, in a few words: i have a table with orders. for order number $order_no there is the $products_id ordered . for each product ordered i want to extract a code from that var.txt file. the problem is that i may have more than 1 unit of $products_id ordered. therefore, i have another field in the table: $order_qty (e.g. $order_qty = '3'; ) the problem is that i don't know how to extract 3 codes (or whatever the $order_qty is) for the $products_id i don't have any algorithm in my head, please help.. cheers!
  4. hi is my syntx correct for $raw[] ? $result = mysql_query("SELECT field1 FROM table WHERE field2 = '10'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo $row['field1']; $var = file('var' . $row['field1'] . '.txt'); thanks
  5. hello! i'm implementing an e-commerce system to distribute key codes. right now i'm thinking of a sql syntax to do the following: i have a table: orders here i have the orders_id field (unique for each order placed) with this orders_id field there may be more than one products ordered therefore in the products_id field i can have the following situation: orders_id: 101 products_id: 13 orders_id: 101 products_id: 43 orders_id: 101 products_id: 1 so i have three rows with the same orders_id but different products_id now i want to grab the value of these products_id for the specified orders_id (p.s. i can provide the orders_id value already) any ideas? i'm a little stuck on this.. thanks
  6. any ideas?
  7. i have a script which retrieves a licence key from a list and mails it when it is accessed. as a security measure i need to restrict access to it by ip (only by server) do you have any ideas which is the best solution for it? p.s. keys are stored in a .txt file which will be put before public_html directory. thanks!
  8. yeah, true, i could do that and that codes txt file will be safe.. but just for my knowledge, how could i do it with the sql database? also, i need this php script to be ran only by the server (restrict ip access).. any ideas? thanks
  9. i have a table: codes with a field name: code where there added the values (i was thinking storing the codes in the db is safer than in plain txt)
  10. how could i do the same thing with a list located in sql? (cut value and update table) any ideas?
  11. ah, right.. dunno how i switched it.. my bad cheers!
  12. it workd with this line: file_put_contents('codes.txt', implode(PHP_EOL, $codes));
  13. i've replaced the line with: file_put_contents($codes, implode(PHP_EOL, $codes)); but i still get an error: [sat Sep 13 17:12:59 2008] [error] PHP Warning: file_put_contents() expects parameter 1 to be string, array given in /home/xxx/public_html/test/code.php on line 11
  14. it echoes the first line but on 2nd refresh it echoes the same first line here is the error i get: [sat Sep 13 17:07:07 2008] [error] PHP Warning: file_put_contents() expects at least 2 parameters, 1 given in /home/xxx/public_html/test/code.php on line 11 line11: file_put_contents(implode(PHP_EOL, $codes));
  15. i have a list of codes: 0000001 0000002 0000003 0000004 0000005 i want to read first line, cut the code (so it won't remain in the list anymore) and put it in a variable. the list would be either in the php file itself or an attached .txt file how do i do that? tnx in advance
  16. hey! i am developing an oscommerce for a digital goods store which sells prepaid telephony codes. I have an option in oscommerce to enable downloads for products and to add an url for each product. This is all i have from oscommerce so i need to get it working just with that. I was thinking of a system that does the following: merchant approves payment -> merchant notify oscommerce that order is ok and proceed with download -> oscommerce runs the script to deliver the key codes in customer email: script: system runs into a list of codes (either located in a .txt, either in the same php), extracts it (cuts it) from the list, put it in a variable, then mail it to the customer. what do you think? any ideas? and advices for these methods? also, if you are into oscommerce maybe u can help me figure out this: let's say i set the download url for product X 'scriptX.php' as i will have different script for each product. when merchant validates the order and sends back the payment notification, what can i do to run the script first and then mail the customer instead of mailing the script to the customer(which is not safe as he could run it a dozen times). Thanks, help is much appreciated as security measures i was thinking of allowing only my host ip to access the script.
  17. anyone any ideaS?
  18. i've tried this but no luck for($i=1;$i<=4;$i++){ $fx = '$fileName' . $_FILES['upload' . $i] . '$ext'; }
  19. i was thinking somehting like this: $xxdata = array(); foreach(array_keys($_FILES['upload$i']) as $i) $xxdata[] = $_FILES['upload$i'][$i]; $xxvalue = mysql_real_escape_string(implode("\n",$xxdata)); and then add the $xxvalue into sql but it doesn't work
  20. i have an image upload system for a travel agency. the form has 4 file fields where u can browse and add your images for upload. when you press upload, the script automatically uploads each file, creates a thumbnail and then add the path to mysql. the problem is that i can't add all the files to mysql, just the first one. i believe i need a simillar loop or something.. here are parts of the code: for($i=0; $i<10; $i++) if(!empty($_FILES["upload$i"]['name'])) { $pic[$i] = $_FILES["upload$i"]['name']; } $totalPics = count($pic); for($i = 0; $i<$totalPics; $i++) if(is_uploaded_file($_FILES["upload$i"]['tmp_name']) and copy($_FILES["upload$i"]['tmp_name'], "$fileName$i$ext")) then it comes the INSERT sql command: $sql2 = "INSERT INTO images SET numestatiune='$numestatiune', filename='$fileName$i$ext', width='$newwidth', height='$newheight' "; if(mysql_query($sql2)) { echo "images uploaded and resized"; } so on the webserver i have 0.jpg , 1.jpg, 2.jpg but in sql i have only 0.jpg any ideas anyone? cheers
  21. great dude, that works! thanks a bunch!
  22. here is my idea: i have this line: foreach(array_keys($_POST['field1']) as $n){ print $_POST['field1'][$n] . '|' . $_POST['field2'][$n] . '|' . $_POST['field3'][$n] . '<br>'; which prints me each row, one under another. what if i would insert all rows (delimited by a <br> as above) in one single variable, which i would insert into the mysql and when i want to show the result, i just echo this variable and all rows will show. eh?
  23. hold on, i've tried to alter the java and it works... it echoes all inputed fields. my bad i'll try to figure out how to insert the values into the mysql and will get back cheers
×
×
  • 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.