Hi,
go to the dropdown menu with your username, click on Edit My Profile, scroll the page down, until you get the Permanently Delete Membership button, click it.
Bye bye!
Hi,
go to the dropdown menu with your username, click on Edit My Profile, scroll the page down, until you get the Permanently Delete Membership button, click it.
Bye bye!
Hi,
array_diff()
will return the index key, so you can get the corresponding values for each array, as example:
<?php
$a = [4711, 4712, 4713, 4714];
$b = ['ALFA ROMEO', 'BMW', 'SKODA', 'TOYOTA'];
$c = [6.5, 65, 0.2, 2.9];
$d = [4711, 4712, 2856, 4714];
$diff = array_diff($a, $d);
$key = key($diff);
$template = '%s %s %s';
echo sprintf($template, $a[$key], $b[$key], $c[$key]);
Note that if array_diff()
returns more results you will have to loop, as the internal pointer will return only the first index key.
I realize it is not secure and as you stated in the beginning, it was just for beginners [...] Some of us appreciate someone taking the time to try and help us newbs out with a concept.
Hi! That's ok, but if this approach was not discouraged, what you were going to learn? A bad practice?
Hi,
you can get a list in JSON format here:
you can get a free API key for 1000 request per month and get currency rates hourly updated:
And build your own system, but you should consider using a library, like MoneyPHP:
The doc
directory has many examples, as how converting between currencies.
Ok, it happens because the topics
table is not listed it the FROM statement, add it as a JOIN, it should fix this issue.
Set exit;
after the redirect, as in this comment:
That will stop the execution of the following code. Bye!
Hi, I use this tool: http://www.generatedata.com/
The online version is limited to 100 entries, but it can be downloaded for free from github and loaded in local PHP server, just do php -S localhost:8000
.
Hi,
just add delimiters to the pattern variable, in your case it's $word
, for example:
<?php
$color = 'red';
$text = 'This is an example text sentence.';
$eregPattern = 'example';
$pregPattern = '/example/';
$replacement = '<font style="background:' . $color . ';">\0</font>';
echo eregi_replace($eregPattern, $replacement, $text);
print PHP_EOL;
echo preg_replace($pregPattern, $replacement, $text);
print PHP_EOL;
I how do I check preg_replace function is executed or not?
From the documentation:
preg_replace() returns an array if the subject parameter is an array, or a string otherwise.
If matches are found, the new subject will be returned, otherwise subject will be returned unchanged or NULL if an error occurred.
Hi, s
stands for string, if you want two conditions, for example a string and a digit you will write:
$city = 'Aurora';
$state_id = 1;
bind_param("si", $city, $state_id)
Read the documentation to see the data types you can define:
You can enable the compatibility to the ANSI standard by switching the SQL mode, see:
With that you, then, can use double quotes to define the identifiers.
Hi, in this case it would be bindColumn()
instead of bind_result()
as the OP is using PDO, not MySQLi:
// edit
I added the PDO tag to the thread, to avoid confusion, bye! :)
Hi, I would probably start from this link:
Hello, have you tried with a left join? If table 1 is reference
then try this example for MySQL:
SELECT `r`.`no`, `r`.`referenceno`, `r`.`date`, `m`.`controlno` FROM `reference` AS `r` LEFT JOIN `marine` AS `m` ON `m`.`referenceno` = `r`.`referenceno` AND `r`.`marine` = 'y' ORDER BY `r`.`no`;
Live example here: http://sqlfiddle.com/#!9/b2fca/1
Knowing the data model relationship (one to many, one to one, ...) and the database (MSSQL, MySQL, PostgreSQL, ...) could help.
Hi,
at the moment you're using the $username
variable directly inside the query and without quotes:
where username = $username
change it to the placeholder:
where username = :username
as is set by the bindValue()
method.
Also, if not used, remove the :roleid
bindValue() as that will produce:
'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens'
i.e. a fatal error that will stop the script.
If this still does not solve, then enable the PDO exceptions and the PHP error logging and post back with detailed errors.
@hielo hi! On MySQL you can use the SET
clause in the INSERT
statement, both syntaxes are supported, see:
To get the difference between two dates you can use datediff()
:
To get the difference without weekends you could also do:
drop function if exists diffdate;
delimiter //
CREATE FUNCTION diffdate(date2 DATETIME, date1 DATETIME)
RETURNS INTEGER DETERMINISTIC
BEGIN
DECLARE dt1 DATETIME;
DECLARE i INT;
DECLARE wd INT UNSIGNED;
SET i = 0;
SET wd = DAYOFWEEK(date1);
SET dt1 = date1;
IF DATEDIFF(date2, dt1) > 0 THEN
WHILE DATEDIFF(date2, dt1) > 0 DO
SET dt1:=DATE_ADD(dt1, INTERVAL 1 DAY);
SET wd:=DAYOFWEEK(dt1);
CASE WHEN wd in(2,3,4,5,6) THEN SET i:=i+1;
ELSE SET i:=i;
END CASE;
END WHILE;
ELSEIF DATEDIFF(date2, dt1) < 0 THEN
WHILE DATEDIFF(date2, dt1) < 0 DO
SET dt1:=DATE_SUB(dt1, INTERVAL 1 DAY);
SET wd:=DAYOFWEEK(dt1);
CASE WHEN wd in(2,3,4,5,6) THEN SET i:=i-1;
ELSE SET i:=i;
END CASE;
END WHILE;
END IF;
RETURN i;
END//
delimiter ;
then you can play your queries like these:
> select diffdate(now(), '2016-05-31 00:00:00') as 'without weekends', datediff(now(), '2016-05-31 00:00:00') as 'with weekends';
+------------------+---------------+
| without weekends | with weekends |
+------------------+---------------+
| -2 | -4 |
+------------------+---------------+
1 row in set (0.00 sec)
> select diffdate('2016-05-31 00:00:00', now()) as 'without weekends', datediff('2016-05-31 00:00:00', now()) as 'with weekends';
+------------------+---------------+
| without weekends | with weekends |
+------------------+---------------+
| 2 | 4 |
+------------------+---------------+
1 row in set (0.00 sec)
> select diffdate(now(), now()) as 'without weekends', datediff(now(), now()) as 'with weekends';
+------------------+---------------+
| without weekends | with weekends |
+------------------+---------------+
| 0 | 0 |
+------------------+---------------+
1 row in set (0.00 …
Hi, you can try with the BETWEEN ... AND
construct in the WHERE
clause:
Example with date_column
:
"SELECT `MatchTitle`, COUNT(`MatchTitle`) AS `mostPlayed` FROM `matches` WHERE `date_column` BETWEEN "2016-05-24 23:59:00" AND "2016-05-25 00:00:00" GROUP BY `MatchTitle` ORDER BY `mostPlayed` DESC LIMIT 1"
This will give 1 minute range. Just change date ranges according to your needs.
Little note: consider that the query()
method will return an iterable object from the Result class:
So, if you want to get the next row you have to move the internal pointer, through a loop or through data_seek()
, which should be used if, for example, you want to loop the result set again, see:
In order to get the full result set, you could use mysqli_fetch_all()
, but this is available only if you're using the mysqlnd driver (MySQL Native Driver), which should be the default setting for PHP 5.4 and above:
With PHP 5.3 and lower, the default is the libmysqlclient.
Hi, you're missing the closing parenthesis in the VALUES()
statement and the commas to separate the data:
$count = $dbh->exec("INSERT INTO animals(animal_type, animal_name) VALUES ('kiwi' 'roy'");
Should be:
$count = $dbh->exec("INSERT INTO animals(animal_type, animal_name) VALUES ('kiwi', 'roy')");
In addition to RudyM's comment, you're mixing mysql_
functions with mysqli_
functions. The formers are deprecated in PHP 5.* and removed in PHP 7.*, which is the latest stable PHP version.
So, you have to fix your queries at lines 99
and 102
and you have to fix the escaping, consider using prepared statements. Also, the return statement at line 17
of the connect file, will prevent the execution of the following code in the file, in practice mysqli_close($link)
at line 19
is not executed, which in this case is fine, otherwise the queries on the main file would not work.
Have you tried with DateTime?
<?php
$one = '09:30 am';
$two = '11:00 AM';
$time1 = new Datetime($one);
$time2 = new Datetime($two);
$diff = $time1->diff($time2);
print_r($diff);
Which outputs a DateInterval object like this:
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 1
[i] => 30
[s] => 0
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
From there, then it should be easy to perform the statements. Docs:
Hi, you can explode()
by comma and trim()
, try:
$tags = 'cats, funny, hair cut, funny hair cut';
$result = array_map('trim', explode(',', $tags));
If the update is limited to a single row, as in your example query, you could add rec_id = LAST_INSERT_ID(rec_id)
to register the value to the function and then select it, for example:
UPDATE tier_".$tier_num."
SET payer_ID = '".$payer."', sub_ID = '".$payer_sub."', create_date = '".$created."', status = 'I', rec_id = LAST_INSERT_ID(rec_id)
WHERE status = 'V'
ORDER BY rec_ID asc
LIMIT 1
And then just run:
SELECT LAST_INSERT_ID() as `rec_id`;
All of my other databases in there are accepting my permissions, just not this one.
Each database has a different folder, if for some reason in that folder there is something different from table files or the folder permissions changed, then the server will not remove it. Read this for more information about such issues:
So, use the Windows 7 search tool to find this folder enfold@002d2016
, open the path, it should be the folder that holds the tables of the enfold-2016
database. Once you're sure it's related to the database, right click the folder and delete it. Then restart the database service and check if it works fine.
As suggestion: before doing such operations, be sure to have a backup of the databases.
Hi,
I think you're confused by my previous post. The input type time
is not boolean, so to see the value you must set it in the value
attribute, so instead of:
<td><input type="time" name="timeIn" id="timeIn" <?php echo $row['timeIn'] > 0 ? ' time':''; ?>></td>
Do:
<input type="time" name="timeIn" id="timeIn" value="<?php echo is_null($row['timeIn']) === FALSE ? $row['timeIn']:''; ?>">
Your previous approach works if you're using a input types like checkbox, radio with the checked
attribute or select tags with the selected
attribute.
Try to replace disabled
with readonly
:
But if it is for security, don't rely on this solution, as one can easily edit the form and submit arbitrary input. Please, reply with a post not with a comment, thanks.
It can happen because the sizes
input field is disabled, so it will not be sent with the POST request. In order to work fine, you should remove the disabled
attribute:
Hi,
which library are you using? In the UI I only see dialog()
not modal()
. Build an example page with full requirements, so that we can test, or share the libraries you're using. A part that you could check the values sent to the form through console.log(jQuery('#sizes').val());
in browser side and var_dump($_POST);
, on PHP side, to see what you get from the form request.
With MySQL you can use FIND_IN_SET()
:
SELECT * FROM `example` WHERE FIND_IN_SET(192, `paricipantsId`);
Docs: http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_find-in-set
Or, if you need something more complex and you switch to MariaDB, then you can use some new features for dynamic columns:
However, instead of storing this information in CSV style, consider to normalize it, in general this should give better performance, for more information check point 8 of diafol's tutorial:
Concerning the color: it can be different due to the monitor calibration, you should calibrate in both systems to get the same results.
It's up to you. I use arrays, like:
<?php
return [
'paths' => [
'images' => '/path/to/images/directory/',
'styles' => '/path/to/styles/directory/',
# ...
],
# ...
];
And/or dotenv: https://github.com/vlucas/phpdotenv
Probably because of Username='{s}'
, by setting an existent username you should get the row, which means the query executes fine, which implies there is something else wrong in the code. Is $user
defined?
$user = getUserData('users', 'UserUsername');
Hi,
the above code will download the file to the web server executing the script, not to the home directory of the client browser.
In practice: if the path /home/jiby/Downloads/image.jpg
does not exists in the web server root, then the script will fail.
In addition, for a simple approach you could use require
to load the generator file and loop the offerid to it, for example:
<?php
# example array
$offerid = range(1, 10);
foreach($offerid as $value)
require 'archiveinv.php';
Then in archiveinv.php
instead to refer to $_GET['offerid']
use $value
which is set in the loop:
<?php
# your code here
print $value;
Otherwise create a set of functions or a class, load the file once and then loop the methods to generate the file:
<?php
require 'archiveinv.php';
$offerid = range(1, 10);
foreach($offerid as $value)
echo printIt($value);
And in archiveinv.php
:
<?php
function printIt($var)
{
return $var;
}
This is more the PHP way. In any case there are at least two issues:
To avoid them I would use cronjob or, if I want to start the job immediately, Beanstalkd with a good client:
Hi,
it happens because the header('Location: url');
will be overwritten by the last loop value, which is what will be executed. You cannot start multiple redirections.
Also, what is this line supposed to do?
$key . " : " . $value . "";
Print?
Hi, are you sure the database system allows remote connections? The default setup for MySQL listens on localhost. Consider also that some hosting services provide access only from a restricted range of IPs, usually their web servers.
In addition: check also about composer, it's a dependency manager for PHP, most frameworks support it and it allows to easily share and include libraries into a project:
However you don't really need to use a framework to take advantage of composer, you can use flat PHP. A part that a framework can be useful because it provides a defined and tested structure.
Hi,
I didn't downvoted but I suspect it happened because you should show some efforts on your side and share the code you've written to achieve the requested goals. This forum is not a code service.
In other words if you have doubts about a specific step of your code, we can help.
By loading your data with that table structure I get:
load data local infile '/tmp/march2016.csv' into table refs fields terminated by ',' enclosed by '"' escaped by '' lines terminated by '\n' ignore 1 rows;
Query OK, 1 row affected, 3 warnings (0.02 sec)
Records: 1 Deleted: 0 Skipped: 0 Warnings: 3
> show warnings;
+---------+------+----------------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------------+
| Warning | 1265 | Data truncated for column 'date_received' at row 1 |
| Warning | 1261 | Row 1 doesn't contain data for all columns |
| Warning | 1261 | Row 1 doesn't contain data for all columns |
+---------+------+----------------------------------------------------+
3 rows in set (0.00 sec)
But the data is inserted, however it seems that your csv has only 58 columns, while the table has 60 columns, so this generates the warnings with code 1261.
You could also check if an SQL Mode is enabled, you can do that by running:
SELECT @@sql_mode;
In some cases, for example when strict mode is enabled, the insert can be rejected. More info here:
Your query, with a custom table and data, works fine for me. Could you provide your table schema? Run this:
show create table `refs`\G
Also: is the above example data still valid? So that I can test it.
Hi,
look at the result message:
Query OK, 0 rows affected, 33 warnings (0.00 sec)
Records: 11 Deleted: 0 Skipped: 11 Warnings: 33
by running SHOW WARNINGS;
after the load query, you should get some information about the statement issues.
Hi, the attachment is sent to Gmail servers. Yahoo will only deliver the mail.
In practice the email body attachment part is composed by an header and by the content, some examples here:
Do you mean a payment from user A to user B without involving your account? Check the Adaptive Payments API:
Hi, it could be a problem with the innodb_buffer_pool_size
, the default value is 128MB of RAM, try to increase it, you can follow the suggestions in the documentation:
If this does not help check the others processes to see if something else (the web server) is using too much resources.
2 & 3 are obvious, yes, I was repeating them just to clarify point 7: not all hostings will allow Tor nodes in their networks, so it would be difficult to perform the necessary steps to build such config.
Point 4: when you start the database connection with something like new mysqli()
or new PDO()
and add the onion link (e.g. mysql=host:0123456789abcdef.onion
) the system will call the system glibc function getaddrinfo()
to resolve the link with a DNS query and then the connect()
function, at least in linux. The onion link is not resolvable with a DNS call and MySQL will not try to inject the request in the Tor node, so the connection will fail.
You could use the PHP socket extension but then you cannot use the MySQL APIs and you will have to submit the queries in raw mode and then parse the results which is like a telnet session, or like running queries from command line:
mysql -s -r -D DBNAME -e "SELECT * FROM `table_name`;"
The alternative is to force the API connection through socks but the MySQL (API) client does not support them directly, so you will need something like socat to create the local entry point, some examples, here:
This, for example, works fine for me:
socat TCP-LISTEN:3308 SOCKS4A:localhost:0123456789abcdef.onion:3306,socksport=9050
Then you can connect to the database through the local tunnel opened on port 3308:
$conn = new PDO("mysql=localhost:3308;dbname=DATABASE", "USER", "PASS");
Unless you are meaning that …
Hi, in practice this is a page that waits for a POST form submission, made by the PayPal service. An example can be found in their GitHub account:
You receive data and send it back to check if it's valid, then you can use save it.
Source:
By the way, I prefer using Guzzle instead of cURL, if you want to consider it here's the documentation:
Hi,
if you have, or can enable, the intl extension then use the IntlDateFormatter
class:
Look also at the comments in the documentation page.
Hi,
A good point to start to investigate the issue is sale2.php on line 58, can you show us that part of code? I mean: paste the relevant code not just that line.
When you use double quotes you can include the variable and this will be expanded to the associated value. The curly braces {$var}
are used to write complex expressions when the variable is: an index array, an object or an anonymous function.
Few examples:
# array
$str = "Hello {$data['name']}";
# object
$str = "Hello {$data->name}";
# anonymous function
$data = ['name' => 'James'];
$name = function($array) { return $array['name']; };
$str = "Hello {$name($data)}";
For more information look at the complex syntax examples in the documentation: