Hi, you can check the D3.js project:
And the Charts.js project:
Hi, you can check the D3.js project:
And the Charts.js project:
Hi Ed,
so in local it logs out successfully and, instead, it does not work in production? No error codes? Have you changed the information to reflect the production URL in your application?
In practice you have to change the URL in My Apps > APP Name > Settings > Basic > Website > Site URL and then it should work.
Each view in what really the questioner think and asking might take away that fog
True, but I thought in this case we needed more straight answers. Anyway, I was wondering about which date to display in the result set, about column type, date format (in case dates were saved with day name and eventual warnings due to truncated incorrect datetime value...) or if the OP was simply asking to output the day name, which can be done through the DAYNAME()
function. For example:
> select CONCAT(DATE(NOW()), ' ', DAYNAME(NOW())) AS 'result';
+---------------------+
| result |
+---------------------+
| 2015-11-12 Thursday |
+---------------------+
1 row in set (0.00 sec)
--- EDIT ---
never mind, jkon's questions are more pertinent to solve this.
Try to remove the WHERE condition, just to see if the query returns something and what is assigned to :targetID
:
$f15 = "SELECT sum(cost), :targetID as 'target' FROM ingredients";
And in output do:
error_log(print_r($g5, TRUE));
So you get the full array.
As test, try to replace line 63 (the insert query) with:
if( ! mysqli_query($dbc, "INSERT INTO ...")) {
printf("Errormessage: %s\n", mysqli_error($dbc));
}
If the problem is related to the insert query, then it should display the error returned by the database.
error is still present...
and the error is?
Hi,
the insert query is missing the VALUES
closing parenthesis:
... ADDDATE(NOW(), INTERVAL 1 MONTH))
When in doubt add mysqli_error()
:
Bye!
To extend the query to all users just remove the name condition from the WHERE clause:
SELECT * FROM `user` WHERE `expires_at` < DATE_ADD(NOW(), INTERVAL 15 DAY);
and it should work fine.
If you don't have access to those commands then you may have to ask to your hosting helpdesk. You can also test the syntax of your configuration files:
nginx -t -c /path/to/nginx.conf
The -c
flag is used to test a specific configuration file. Otherwise just run nginx -t
Hi, what you got from:
See systemctl status nginx.service and journalctl -xe for details
I see that php presentation and word has bug. May I ask you a question if there is some other way that i can view my office document file locally with my wamp server??
I don't know how this will performe in production servers, but as local solution you could install LibreOffice and perform an headless conversion from command line, something like:
exec("soffice --invisible --headless --convert-to odt file.docx");
More info here: https://help.libreoffice.org/Common/Starting_the_Software_With_Parameters
For the options: just switch from --
to -
in case of Windows environment.
In reference to the bugs I would submit them to PHPOffice, these libraries have a user large base, so it's possible that your issues have already be covered and you could get some help or temporary workarounds.
Do i still need PhpPresentation-develop.zip that i have downloaded?
No, you should use the master version as this is usually the stable version. The develop version introduce some new features but is not stable and it can change, in general develop packages shouldn't be used in production, unless you understand which issues can produce.
However theres a bug on the output. when i convert a docx file to odt which contains a table or shapes. Theres an error saying Division by zero in PhpWord\Writer\ODText\Style\Paragraph.php on line 41.
For library related errors check their documentation:
And if it does not help, then submit a bug report (with full details) to their issues section:
You have to require the autoload script. But I see that also the Common library is needed. The easiest way to install this package is through composer. Can you use it?
Composer is a packager manager for PHP, it gives you access to many libraries listed in:
Once installed it's easy to start using PHPOffice:
composer require phpoffice/phppresentation dev-master
This will install also the dependencies packages.
In order to do this manually create a src
directory, then download both master zip files:
go into each src
directory and copy the Common
and the PHPPresentation
folders into the src
directory you generated, then use a script like this:
<?php
require_once './src/PhpPresentation/Autoloader.php';
\PhpOffice\PhpPresentation\Autoloader::register();
require_once './src/Common/Autoloader.php';
\PhpOffice\Common\Autoloader::register();
$filename = './samples/resources/Sample_12.pptx';
$new_name = './file.odp';
$phpPPTX = \PhpOffice\PhpPresentation\IOFactory::load($filename);
$odpWriter = \PhpOffice\PhpPresentation\IOFactory::createWriter($phpPPTX, 'ODPresentation');
$odpWriter->save($new_name);
You can see a live example here:
Which can be downloaded. To see it at work just type php index.php
into the terminal, it will convert the sample file into odp.
No, the namespace does not reflect a path into the filesystem. It's used to:
provide a way in which to group related classes, interfaces, functions and constants.
Check the link I provided in my previous post, it explains with examples how the namespace work.
In any case, if you load correctly the library you don't have to worry about the namespace unless you're using PHP lower than 5.3.
For excel or doc files refer to the other PHPOffice projects:
The code would be similar, where instead of calling PhpPresentation you would load PhpWord or PhpExcel. In the source code of the IOFactory class you can see which drivers are supported:
For more information look at their developer documentation.
IOFactory::load()
is a static method to load a resource file, the createWriter()
method is used, in this case, to convert the loaded file to another format, the segment \PhpOffice\PhpPresentation\
is the namespace in which the IOFactory class is loaded:
No, not through copy()
, that will change only the extension. You can try PHPOffice/PHPPresentation:
For example:
$filename = '/path/to/file.pptx';
$new_name = '/destination/path/file.odp';
$phpPPTX = \PhpOffice\PhpPresentation\IOFactory::load($filename);
$odpWriter = \PhpOffice\PhpPresentation\IOFactory::createWriter($phpPPTX, 'ODPresentation');
$odpWriter->save($new_name);
it happens... lol :D
Ok with Microsoft-IIS/8.0 you can try to add a rewrite rule to your web.config file:
<rule name="Prevent image hotlinking">
<match url=".*\.(gif|jpg|png)$"/>
<conditions>
<add input="{HTTP_REFERER}" pattern="^$" negate="true" />
<add input="{HTTP_REFERER}" pattern="^http://site\.tld/.*$" negate="true" />
</conditions>
<action type="Rewrite" url="/images/say_no_to_hotlinking.jpg" />
</rule>
As explained here:
Note: I don't have much experience with IIS, so I cannot help much further, if you still need help wait for other daniwebers. Bye!
Maybe these are affected by other CSS rules. What happens if you isolate this portion and apply only his own rules?
Hi,
I have few questions:
Thats exactly what i am trying to void i dont want to loop <span>abc</span><span>def</span><span>ghi</span> the one under the other but in the same line.
To put them inline use span { display:inline-block; }
or simply inline
. However with the former you can set height, width, padding and margin properties:
The loop
attribute works fine for me with this test:
<marquee behavior="scroll" loop="2" scrollamount="4" direction="left" width="100px" height="170px">
<span>abc</span>
<span>def</span>
<span>ghi</span>
</marquee>
Live example: http://jsfiddle.net/8uqatjed/
But consider that the marquee
tag should NOT be used, as it is obsolete and not anymore supported by most recent browsers releases:
So, if I've understood good your request, this could be the reason it's not working well for you.
Do you need that row in the following loop? If not then do:
$uid = mysqli_fetch_row($query, MYSQLI_ASSOC);
echo $uid[0]['a_uid'];
while($row = mysqli_fetch_assoc($query))
# and so on
The loop will start from the second row in the result set. If you need that row in the loop then do:
$results = mysqli_fetch_all($query, MYSQLI_ASSOC);
$uid = $results[0]['a_uid'];
foreach($results as $row)
# and so on
Another approach by using mysqli_data_seek()
:
# get first row
mysqli_data_seek($query, 0);
$uid = mysqli_fetch_row($query, MYSQLI_ASSOC);
echo $uid[0]['a_uid'];
# reset internal pointer
mysqli_data_seek($query, 0);
while($row = mysqli_fetch_assoc($query))
# and so on
Besides, don't mix procedural with object, it won't work.
@davidbcn
Hi, open your own thread to get responses.
Use var_dump($val);
instead of echo $val;
to see what is returned. If the form ends like this (with a </form>
) and there aren't other input fields, then it should work fine.
Also you could do echo "<pre>". print_r($_POST, true) . "</pre>";
to see what is sent to the $_POST array.
It depends: do you want to lock out the user from his profile or allow him to enter and display a message that invites him to renew the membership?
Above query is checking if user exists and if expired, but it will not work fine if typed user is wrong. To work fine this approch would require at least two queries:
To use only one query then, yes, you can use PHP, but I suggest DateTime as this is more simple:
# the $row variable carries the query result
$expires_at = new DateTime($row['expires_at']);
$today = new DateTime('now');
if($expires_at < $today)
echo 'Your account expired, please <a href="/renew.php">renew here.</a>';
else
{
# enable session & redirect to profile
$_SESSION['logged'] = true;
$_SESSION['user_data'] = array('username', 'and', 'so', 'on');
header('Location: http://site.tld/profile');
}
If it still does not work, please show an example of date returned by the database table.
Hi, you can do this in the select query, something like:
SELECT * FROM `user` WHERE `username` = ? AND `expires_at` < NOW()
The expression expires_at < NOW()
will verify the date stamp with the current date. This requires that the column is datetime type, otherwise you have to cast. If expired, then it will return a result, otherwise it will return an empty result set.
Live example: http://sqlfiddle.com/#!9/40dfbc/3
You have to set quotes around the value you want to search, otherwise COURT
will be interpreted as a column name. So:
$sql = "SELECT full_name, tdoc_number, race, facility FROM inmate_board WHERE type = 'COURT'";
By using exceptions and the try/catch block, you would have seen the error:
Error Code: 42S22
Error Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'COURT' in 'where clause'
Look at the array through var_dump()
, it may add some information about that index.
The number sign #
acts like a comment in MySQL, in your case it will affect the query by returning all the rows instead of selecting by id. But this should not return the Invalid argument supplied for foreach() error, it seems that your query returned boolean FALSE.
To understand what is going on, use a try/catch block and exceptions. For example:
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try {
$stmt = $connection->prepare("SELECT full_name FROM customers where id = ?");
$stmt->execute(array($_POST['id']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
}
catch(Exception $e)
{
print 'Error Code: ' . $e->getCode() . PHP_EOL;
print 'Error Message: ' . $e->getMessage() . PHP_EOL;
die();
}
print $row['full_name'];
Note: using die()
and printing error messages directly in page is good in development stage, while in production you should append all error codes and messages to the error log file and return a simple message, without details.
Documentation:
Sure is not $connection->query($sql)
with ->
instead of -
? It seems you're calling a method, or an anonymous function, I think the former.
In the latter case, then in PHP you cannot use the dash in the variable name, unless you use brakets, for example:
${'connection-query'} = function() { return 'hello'; };
print ${'connection-query'}();
Or once I break out with ?> is that it, all variable can not be picked back up again futher down in the page?
What is declared in the top of the file is accessible in all the rest of the file, unless you unset the variable or rewrite it with something else.
Hi,
the set_rules()
method requires three arguments:
See documentation at:
So your rules would look like:
$this->form_validation->set_rules('email', 'email', 'required|valid_email');
$this->form_validation->set_rules('password', 'password','required');
Hi, from what I've understood you have only to set the path of the libraries, follow the instructions in this tutorial and it should work fine:
Hi, the undefined offset is probably given by:
$rawData[$i + $backdate]
Check if the index key exists:
$key = $i + $backdate;
if(array_key_exists($key, $rawData))
$pTimeseries[$i][1] = $rawData[$key][0];
Hi, use prepared statements, start from here:
Look at the first example in the first link, I'm not converting the code directly for you, because it's more important that you understand how it works and how the methods/functions are used.
I think skilled programmers usually don't have problems with basic / general language issues and, when having some difficulties, they would search for help in appropriate places, like: bug lists, mailing lists, specific niche forums & blogs or support teams.
In my activity I hardly ask for help, as I'm generally able to find what I need. Only when I'm really lost then I ask for an advice, and I search primarly in those places mentioned above, not for distrust in Daniweb members, but because you would search in those places too. I think this is the behaviour of professionals, at least a part.
Daniweb, as I see it, lacks of strong niche groups, for example: if we had groups of people working on same framework / browser plugins / mobile apps / hardware (Raspberry PI & co.) and sharing snippets and issues then, it could drive the attention of new contributors interested in rise their knowledge on those topics. From my point of view, the new tag system can help to build such groups, but it's not something that we can force, it has to emerge spontaneously.
On the other side, nowadays, there are a lot of documentation / blogs & books, so it's easy to get confident with a new technology without becoming visible to other partecipants.
Just an addition: you could use an sqlite3 database to store that amout of data and then retrieve it through a PHP script. Something like this example script:
Or, if using MariaDB (MySQL fork), through the Connect engine which allows to open a sqlite3 database as resource and perform a simple INSERT ... ON SELECT
.
Hi, sure there is no %
in front of 20
?
Can you show us more details of the script in which you create the date? Have you tried the above in a separated script: a simple <?php echo date('d-m-Y'); ?>
file, in this case do you get the same results?
what's that 'as dummy_3 ' ??
It's '' as dummy_3
i.e. empty space defined with an alias, it will return an empty column, for example:
select '' as dummy_3;
+---------+
| dummy_3 |
+---------+
| |
+---------+
1 row in set (0.00 sec)
It can be used as workaround when quering tables with column mismatch.
It happens because of:
//If form is of GET type
$x = filter_input(INPUT_GET, 'howmanytimes', FILTER_SANITIZE_NUMBER_INT);
//if form is of POST type
$x = filter_input(INPUT_POST, 'howmanytimes', FILTER_SANITIZE_NUMBER_INT);
If using a GET request, i.e.: script.php?howmanytimes=2
, then $x
will be overwritten by the INPUT_POST check, by using a POST you won't notice the error. To avoid this use only one request method or use conditional statements:
<?php
$y = 1;
if($_SERVER['REQUEST_METHOD'] == 'GET')
$x = filter_input(INPUT_GET, 'howmanytimes', FILTER_SANITIZE_NUMBER_INT);
elseif($_SERVER['REQUEST_METHOD'] == 'POST')
$x = filter_input(INPUT_POST, 'howmanytimes', FILTER_SANITIZE_NUMBER_INT);
else
$x = FALSE;
function f($x, $y)
{
if(in_array($x, array(null, false)) || in_array($y, array(null, false)))
return FALSE;
return $x + $y;
}
print f($x, $y);
Hmm, it works fine for me. What you get? Could be the array, if using PHP version prior to 5.4 then replace [null, false]
with array(null, false)
.
And how would you know which result sets belongs to what? If you're expecting a row for each table, then you could add empty columns:
select id, name, lastname from users where id = 1
union all
select user_id, email, '' as dummy_3 from addresses where user_id = 1;
But in this case the join solution is better.
About the function issue: the form will send strings, so filter_input()
will return strings or:
so the is_int()
check will always return boolean FALSE. You can convert the input through intval()
, or change the conditional rules in the function to verify that the argument is not null or false. An example:
<?php
function f($x, $y)
{
if(in_array($x, [null, false]) || in_array($y, [null, false]))
return FALSE;
return $x + $y;
}
print f(FALSE, "6");
print f("5", "6");
Hi,
by using four spaces or one tab, the system will set the paragraph into a block code. For more information check the syntax helper:
Ops! I'm sorry, I didn't noticed it was a challenge... o_o'
Now that I see that link I understand... I solved this some time ago... :D
I can say that defining the type helps.
In addition: so what you're searching for is a client to query remote services? Have you considered Guzzle?
You can integrate it into CI3 by using composer:
composer require guzzlehttp/guzzle:~6.0
And modifying the composer_autoload
variable in application/config/config.php
into:
$config['composer_autoload'] = FCPATH . 'vendor/autoload.php';
Then in your controller you can do:
public function index()
{
$client = new \GuzzleHttp\Client();
$response = $client->request('GET',
'http://httpbin.org/get',
['timeout' => 5]);
print $response->getStatusCode();
}
Something like this will fit?
<?php
$tests = file("php://stdin", FILE_IGNORE_NEW_LINES);
foreach($tests as $test)
{
for($i = 0; $i <= $test; $i++)
{
$size = 9283412;
$isEven = (($test % 2) != 0 ? true : false);
if($test == 0)
{
$size = 1;
break;
}
elseif($isEven)
$size *= 2;
else
$size += 1;
}
print $size . PHP_EOL;
}
Giving an input file:
php script.php < data.txt
With a number each line:
1
2
3
0
4
17
Returns:
18566824
9283413
18566824
1
9283413
18566824
Is this you're trying to accomplish?
Besides, you can get the same results by avoiding the inner loop:
foreach($tests as $test)
{
$size = 9283412;
$isEven = (($test % 2) != 0 ? true : false);
if($test == 0)
$size = 1;
elseif($isEven)
$size *= 2;
else
$size += 1;
print $size . PHP_EOL;
}
Because $test
($_tmp
in your script), it never changes, for example: if even it will be even for all his loops.
the browser (on the mobile phone) downloads all the video before playing it (doesn't play while buffering), and if the video is really big it's a problem.
Ok, I don't have big experience on this but, in case of .mov or .mp4 files, it seems related to metadata position:
If the production server platform will be linux, for fixing the videos, then look at avconv rather than ffmpeg because it now has better support:
A part that, you could set the headers in a previous step, save them in session and change the above IF statement to something like:
if(array_key_exists('AUTHENTICATION', $_SESSION))
# allow access to video resource
Otherwise you could submit the token through a cookie. Not sure it makes sense for you app, but I don't see other methods.
Wait to see if someone else wants to suggest other solutions, I'm sorry but, for the moment, I don't have other suggestions. Bye!