-
Posts
24,573 -
Joined
-
Last visited
-
Days Won
824
Everything posted by Barand
-
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.
-
How to Create a "action.php" page for HTML Form?
Barand replied to rashidpathiyil's topic in PHP Coding Help
I didn't receive that memo -
Need help posting to mysql and sending email from form
Barand replied to gabbymiles's topic in PHP Coding Help
@QoC, See end of para 7 on http://php.net/manual/en/language.expressions.php -
To have $row['id'] in your results you need to select "id" in your query.
-
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
-
What happened to PM attachments? I can't add them any more.
-
$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]
-
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.
-
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>';
-
I wonder if there's a Facebook API for that.
-
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 | +------+--------+----------+
-
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.
-
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')";
-
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.
-
try SELECT COUNT( * ) AS total FROM `nem_pae_atividades` WHERE `idutilizador` =1355 AND `data` <= CURDATE( ) AND ( `realizado` IS NULL OR LENGTH( `realizado` )=0 )
-
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)
-
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
-
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"; }
-
Can PHP integrate with microsoft sql by using mysqli?
Barand replied to FooKelvin's topic in MySQL Help
Why do you want to change from sqlsrv if you are still using SQLServer? -
I was using "$m" as an example of a month number variable
-
Can PHP integrate with microsoft sql by using mysqli?
Barand replied to FooKelvin's topic in MySQL Help
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. -
I'd make use of data attributes. <div class='add_more' data-id='$cid' data-month='$m'>
-
How to obtain last id number, to submit in Picasso for App..
Barand replied to dave204's topic in PHP Coding Help
Topics merged. -
Display vs POST info in a mysql based dropdown
Barand replied to itgranny's topic in PHP Coding Help
if you have <option value='$id'>$name</option> then the name is displayed but the id (value) is posted. -
Topics merged