Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Still cannot understand exactly what is required. How do you call the function and where does the value for $kataloski_broj come from that you pass to the function?
  2. Easiest way to batch them is to use array_chunk(); $f_pointer=fopen("unique.csv","r"); // file pointer $users = array(); while ($ar=fgetcsv($f_pointer)) { if (trim($ar[0])!='') $users[] = $ar[0]; } fclose ($f_pointer); $batchSize = 50; // set size of your batches $batches = array_chunk($users, $batchSize); foreach ($batches as $batch) { $list = join(',', $batch); // process the batch list here }
  3. fetch_assoc() is a method of the mysql_result class, not statement class. Use $result = $sql->get_result(); $row = $result->fetch_assoc(); As you are using a prepared query you do not escape the variables with real_escape_string.
  4. Sub-contract it to someone who knows what they are doing. At least you'd be doing your client a favour.
  5. And your problem is what?
  6. vrijeme is set when data is inserted and is updated every time the data in the record is changed.
  7. $_xml_string is not an object. $_xml_string = '<Order> <EmbeddedDoc DocumentName="TestDoc" DocumentFormat="PDF">jdsahfdhflhfsdlfhdslhsdflsdfhflkdslkfsdhkfhskldhkl</EmbeddedDoc> <EmbeddedDoc DocumentName="TestDoc1" DocumentFormat="PDF">jdsahfdhflhfsdlfhdslhsdflsdfhflkdslkfsdhkfhskldhkl</EmbeddedDoc> </Order>'; $xml = simplexml_load_string($_xml_string); foreach ($xml->xpath('//EmbeddedDoc') as $doc) { echo $doc . '<br>'; }
  8. It looks as though that function will never get past line 14, where it just returns the value of $kataloski_broj that you passed to it. You could save time by having function zamjena_broja($kataloski_broj){ return $kataloski_broj; } How do you know if a number is newer? Is it freshly painted whereas the old ones are a little rusty? You have a timestamp field (vrijeme) but you aren't using that in any of your queries. Perhaps if you showed us some sample data to demonstrate exactly what you are looking for.
  9. The [..] syntax instead of array() requires version 5.4+.
  10. And someone should tell your professor that mysql_ functions are deprecated and he should be teaching mysqli_ or PDO functions.
  11. You don't have to select a field that you are joining on, unless you also want to output it. Naturally, if you want to output a field it needs to be selected. Other cases vary with flavour of SQL. With MySQL you can GROUP BY or ORDER BY a field that isn't selected but others, like MS SQL SERVER, are less lenient and adhere to the standard and the fields must be selected.
  12. One problem could be the use of <? instead of <?php on line 1
  13. You could put the condition in the query EG SELECT (CASE Post_Id WHEN 7 THEN 0.00 ELSE Post_cost END) as Post_cost, ...
  14. Strange how it "worked" in PhpMyAdmin then
  15. show the data echo '<pre>', print_r($fbdata->data, 1), '</pre>';
  16. Store in array then join(). $f_pointer=fopen("unique.csv","r"); // file pointer $users = array(); while ($ar=fgetcsv($f_pointer)) { $users[] = $ar[0]; } fclose ($f_pointer); $list = join(',', $users);
  17. Case sensitivity!. $Ctry = $WV_info['country']; should be $Ctry = $WV_info['Country']; Are you really storing data in a separate table for each week?
  18. Use "\n" and not "<br>" in textareas. <?php $txt = ''; while($stmt->fetch()){ $txt .= $date . " " . $stratoparse . "\n\n"; } ?> <textarea cols="50" rows="10"> <?php echo $txt; ?> </textarea>
  19. How can we figure it out when you give us little more than "it doesn't work"? Have you tried outputting the content from mysqli_error() after attempting the insert query? What is the output from "echo $sql;" ? We are not looking over your shoulder seeing what you see on the screen. I doubt anyone here is going to download the content of an unknown file. If you got an email saying you had won 1 million dollars and had to click on a download link for details, would you? Post the output from "SHOW CREATE TABLE products".
  20. Does this mean you have given up trying to find the reason for the error (even though you've been told how) and want us to do the work for you?
  21. While developing, instead of just outputting "errror", try outputting something helpful to you, like mysqli_error
  22. this will do it $a['a'] = array('a' => '5'); $a['b'] = array('b' => '4'); $a['c'] = array('c' => '3'); $a['d'] = array('z' => '2'); $a['e'] = array('f' => '1'); echo '<pre>'; uasort($a, 'mysortASC'); print_r($a); uasort($a, 'mysortDESC'); print_r($a); echo '</pre>'; function mysortASC($a, $b) { $atmp = array_values($a); $btmp = array_values($b); return $atmp[0] - $btmp[0]; } function mysortDESC($a, $b) { $atmp = array_values($a); $btmp = array_values($b); return $btmp[0] - $atmp[0]; }
  23. It would work for indexed arrays (they will sort on the value of the first item) but not for associative arrays like that one. It does work if the associative arrays have consistent key values for comparisonEG $a['a'] = array('a' => '5'); $a['b'] = array('a' => '4'); $a['c'] = array('a' => '3'); $a['d'] = array('a' => '2'); $a['e'] = array('a' => '1'); That lack of consistency of array keys also make the custom sort option problematical too.
  24. Just in case you aren't using a database, you can sort the array by good(DESC), time(ASC) then take the the first element. $results = [ ['name'=>'carl', 'good'=>1, 'time'=>14], ['name'=>'john', 'good'=>2, 'time'=>25], ['name'=>'benny', 'good'=>2, 'time'=>21] ]; usort($results, 'resultSort'); echo $results[0]['name']; // benny function resultSort($a, $b) { // compare by 'good' DESC $x = $b['good'] - $a['good']; if ($x==0) { // if same, compare by 'time' ASC return $a['time'] - $b['time']; } else return $x; }
  25. http://php.net/manual/en/function.mail.php see example #2
×
×
  • 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.