Jump to content

Barand

Moderators
  • Posts

    24,573
  • Joined

  • Last visited

  • Days Won

    824

Everything posted by Barand

  1. Get the mime type of the updated file and apply the extension according to that value. You are already on an outdated version of PHP, you don't want to move to a worse situation.
  2. I didn't receive that memo
  3. @QoC, See end of para 7 on http://php.net/manual/en/language.expressions.php
  4. To have $row['id'] in your results you need to select "id" in your query.
  5. you need a value for each column. You seem to have a couple of extra values at the end '".mysql_real_escape_string($data['length'])."', '', '', NOW(), 0, '') | | | | | | filesize mime ?? | | ?? added | is_done
  6. What happened to PM attachments? I can't add them any more.
  7. $real = $_FILES["file"]["name"]; // $GetName = ServerName($_FILES["file"]["name"]); $x = explode('.',$real); $GetName = time() . "." . $x[1]; If $real is "myfile.desmond.docx" then you will get desmond in $x[1]
  8. You can't nest forms. Your data tables will be 1 to many though, an employee table and a phone table, each row of which contains employee id and a phone number. Just have one form containing employee fields and multiple fields for phone number entry. Name the phone fields something like "phone[]" so they are posted in an array, which you can loop through to process. When processing, insert the employee data and grab the last_insert_id to get the value of the new auto_incremented id field. Use this to insert the emp id value in each of the phone number records.
  9. A somewhat simpler one-liner $input = "dog,white cat,white cat,black cat,white dog,black bird,white"; echo '<pre>',print_r(array_count_values(explode("\n", $input)), true),'</pre>';
  10. I wonder if there's a Facebook API for that.
  11. Just for completeness, an FYI to illustrate the SQL solution mentioned earlier The data mysql> select P_id, Prt_id, Other_id FROM _projecttbl; +------+--------+----------+ | P_id | Prt_id | Other_id | +------+--------+----------+ | 1 | AB | Ghi | | 1 | HG | Fxg | | 1 | CD | Klm | | 2 | qwer | zz | | 2 | asdf | yy | | 2 | ergx | xx | +------+--------+----------+ mysql> select Prt_id, Other_id FROM tempproj; +--------+----------+ | Prt_id | Other_id | +--------+----------+ | AB | Ghi | | ergx | xx | +--------+----------+ The delete query DELETE p FROM _projecttbl p LEFT JOIN tempproj t USING (Prt_id, Other_id) WHERE p.P_id = 1 AND t.Prt_id IS NULL; The result mysql> select P_id, Prt_id, Other_id FROM _projecttbl; +------+--------+----------+ | P_id | Prt_id | Other_id | +------+--------+----------+ | 1 | AB | Ghi | | 2 | qwer | zz | | 2 | asdf | yy | | 2 | ergx | xx | +------+--------+----------+
  12. The error message suggests that $this->connection is not a valid connection object in the failing function. The query in the first function does not need to be a prepared statement - there is no user input. The second function does not require the parameter to be sanitized if you are preparing the statement, You should use a placeholder and bind the parameter to the placeholder. It is the separation of data from query statement that makes preparation effective.
  13. This could work $str = 'HG||Fxg|||ergx||xx'; // replace "|||" with "','" so you have separate records split by quote-comma-quote $str = str_replace("|||", "','", $str); $sql = "DELETE FROM _projecttbl WHERE P_id = 1 AND CONCAT(Prt_id, '||', Oth_id) NOT IN ('$str')";
  14. While you are still working with those silly double-delimited strings of yours, forget about using SQL. Break you string into separate records (Prt_id, Oth_id) and store in a separate db table. Then you can do your deletions by matching the tables.
  15. try SELECT COUNT( * ) AS total FROM `nem_pae_atividades` WHERE `idutilizador` =1355 AND `data` <= CURDATE( ) AND ( `realizado` IS NULL OR LENGTH( `realizado` )=0 )
  16. When mixing AND and OR always use ( )'s to define your logic. For example A AND B OR C Do you mean (A AND B) OR C or A AND (B OR C)
  17. The month number was fetched in the original query. For each course we then created an events array where $m was the key and the value was an array of course dates in that month. if ($sd) $data[$cid]['events'][$m][] = date('j/m/Y', strtotime($sd)); I changed it use the month key and values when looping through the array, instead of just the values. Originally it was foreach ($cdata['events'] as $dates) which I changed to foreach ($cdata['events'] as $m => $dates) so we now had the value for the month that we now needed
  18. I've rewritten this section to use the [$m] in the arrays /********************************************************** * create table from array data ***********************************************************/ foreach ($data as $cid=>$cdata) { $trows .= "<tr><td>$cid</td><td class='cn'>{$cdata['name']}</td>"; foreach ($cdata['events'] as $m => $dates) { $trows .= "<td class='dt'>" . join('<br>', $dates) . "<div class='add_more' data-id='$cid' data-month='$m'>+</div></td>"; } $trows .= "</tr>\n"; }
  19. Why do you want to change from sqlsrv if you are still using SQLServer?
  20. I was using "$m" as an example of a month number variable
  21. No. mysqli_ functions, like mysql_ , are for the MySql database server just as sqlsrv functions are for MS SQL Server. PDO, however, is database independent so you could use that.
  22. I'd make use of data attributes. <div class='add_more' data-id='$cid' data-month='$m'>
  23. if you have <option value='$id'>$name</option> then the name is displayed but the id (value) is posted.
  24. Topics merged
×
×
  • 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.