cereal 1,524 Nearly a Senior Poster Featured Poster

You can do:

SET @dt = '2016-07-18';
SELECT * FROM `arrival` WHERE `created_at` >= DATE_FORMAT(@dt ,'%Y-%m-01') AND `created_at` < @dt;

the DATE_FORMAT() will output the first day of the month 2016-07-01, since you don't want to include the last day you cannot use the BETWEEN ... AND statement.

More info:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

if the connections are limited (20 concurrent users) then Access can work fine, by opening more connections the database performance can degrade fast.

How do you plan to update the database: through script; Access interface?

Have you considered MySQL or PostgreSQL? Both are open source, multiplatform and free for commercial use. You could also use SQLite, which is the most handy solution (easy to backup, easy to export), if most of the activity is reading and by carefully using transactions when writing.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can start from yellow pages or get a list at the local chamber of commerce. Start from typography services, if they like the work you do for them, there are chances that will call you to serve their clients too.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

do you want to build it from scratch or you want to install a monitoring software?

In the first case you can parse the access logs of the server and use javascript to catch events on the page. Read the documentation of the web server in use to see how data is logged and which features are available, for Apache read this:

I suggest you to do some research, there are a lot of articles on this topic.

If, instead, you want to install a monitoring software on the server, then look at tools like GoAccess:

you can get the results as JSON or CSV to create your own templates, or you can use the available interfaces.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

Your thread is marked solved, did you actually solved the issue? Do you care to share your solutions for the readers? Last question: are these 1/07/59 - 2/07/59 Thai calendar dates?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, is the curl request link correct? By testing I get a 404 page, not JSON data.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

  • is the second database in the same server of the first database?
  • if affirmative: do you access with same credentials?
  • if affirmative: do you have same permissions?

If it is all affirmative then you can access the second database from the same connection to the first database, just prepend the table name with the database, as in the following example:

SELECT `database1`.`table`.`attribute`, `database2`.`table`.`attribute` FROM `database1`.`table`, `database2`.`table`;
cereal 1,524 Nearly a Senior Poster Featured Poster

Hello everybody,

so, I realized that when I try to load some XML into a MySQL table through the LOAD XML LOCAL INFILE ... statement, if there is a parent with the same name of the child, MySQL will insert an extra row. Here's the example to reproduce the issue:

<fruit>
    <fruit>
        <name>Orange</name>
        <variety>Valencia</variety>
    </fruit>
    <fruit>
        <name>Apple</name>
        <variety>Fuji</variety>
    </fruit>
    <fruit>
        <name>Lemon</name>
        <variety>Eureka</variety>
    </fruit>
</fruit>

And the SQL:

CREATE TABLE IF NOT EXISTS `tmp_fruits`(
    `name` VARCHAR(50) NOT NULL,
    `variety` VARCHAR(50) NOT NULL
) ENGINE = MEMORY;

LOAD XML LOCAL INFILE 'data.xml' INTO TABLE tmp_fruits ROWS IDENTIFIED BY '<fruit>';

SELECT * FROM `tmp_fruits`;

I got four rows instead of three:

+--------+----------+
| name   | variety  |
+--------+----------+
| Orange | Valencia |
| Apple  | Fuji     |
| Lemon  | Eureka   |
| Lemon  | Eureka   |
+--------+----------+
4 rows in set (0.00 sec)

I think it happens because it matches the parent node (1) and the children nodes (3):

<fruit> <!-- parent -->
    <fruit> <!-- child -->
        <name>Orange</name>
        <variety>Valencia</variety>
    </fruit>
    <fruit> <!-- child -->
        <name>Apple</name>
        <variety>Fuji</variety>
    </fruit>
    <fruit> <!-- child -->
        <name>Lemon</name>
        <variety>Eureka</variety>
    </fruit>
</fruit>

How this could be solved? The XML is an example, I cannot change the parent to a plural <fruits> at the origin, as it's generated by an external source and defined by a namespace, maybe I could alter the received file or extract those nodes, but I'm not happy with these solutions.

NOTE
ExtractValue() works fine and matches only three records, example:

SET @xml_data := …
cereal 1,524 Nearly a Senior Poster Featured Poster

Hello, if haven't solved yet, show us the schema of the history table, run:

SHOW CREATE TABLE `history`;

Consider that the insert cannot occour if there is a unique key on the user.

cereal 1,524 Nearly a Senior Poster Featured Poster

Date is a reserved word, use backticks for the column and table names.

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe this thread?

To check your previous threads go to your profile and click on Discussion Threads.

cereal 1,524 Nearly a Senior Poster Featured Poster

If using Chrome as your browser, you can install Tampermonkey as a plugin extension.

It works also with the CJS (Custom JavaScript extension). Thank you for sharing, it's great! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

@Raj_17

Hi,

I suppose you were referring to this thread but it seems you already got a reply here:

Follow sunny kashyap suggestion and use Illuminate\Http\Request, check the documentation https://laravel.com/docs/5.2/requests#files

Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition, you can also do:

echo " AS " . ($index - 10) . " - " . $index . " SA ";
cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,

I was trying to send a PM but it seems to hang: after clicking the submit button this disappears and it does not happen anything else. With short messages it seems to work fine, but it appears slow.

When I try to submit a message with ~9k characters, I have no success and get this in the console log:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Where the resourse is https://www.daniweb.com/js/messages/post

I'm not sure this is due to the size of the message or to the code blocks.

// EDIT
By splitting the message I had success, so it seems to be the size.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, look at the request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header></soapenv:Header>
   <soapenv:Body>
      <tem:GetIndividualCourseDetail>
         <!--Optional:-->
         <tem:CourseId>12262</tem:CourseId>
      </tem:GetIndividualCourseDetail>
   </soapenv:Body>
</soapenv:Envelope>

Here the only element you have to add, to the <tem:GetIndividualCourseDetail> method, is <tem:CourseId>12262</tem:CourseId>, so we don't need criteria as in the previous example, just do:

$search = new stdClass;
$search->CourseId = 12262;
$values = $client->GetIndividualCourseDetail($search);

And it should work.

returning the data in xml format

The PHP Soap Client returns an object, to get it in XML you have some choices:

  • use SoapClient::__getLastResponse():

    $search = new stdClass;
    $search->CourseId = 12262;
    $client->GetIndividualCourseDetail($search);
    $xml = $client->__getLastResponse(); # will be a string
  • use a serializer to convert an object to XML, I've not tested but while searching I saw Symfony serializer was suggested;
  • use curl to make the request, or an alternative client, in which you submit the XML request generated by SoapUI.

Here's an example with Guzzle, a curl client:

<?php

    require_once './vendor/autoload.php';

    $template = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header></soapenv:Header>
   <soapenv:Body>
      <tem:GetIndividualCourseDetail>
         <!--Optional:-->
         <tem:CourseId>%s</tem:CourseId>
      </tem:GetIndividualCourseDetail>
   </soapenv:Body>
</soapenv:Envelope>
EOD;

    $wsdl    = 'http://service.fetchcourses.ie/service/FetchCourse.svc?wsdl';
    $sopa    = 'http://tempuri.org/IFetchCourse/GetIndividualCourseDetail';
    $client  = new GuzzleHttp\Client();
    $request = sprintf($template, 12262);
    $length  = strlen($request);
    $options = [
        'body'    => $request,
        'headers' => [
            'Accept'         => 'text/xml',
            'Content-Type'   => 'text/xml;charset=utf-8',
            'SOAPAction'     => $sopa,
            'Content-Length' => $length,
            ],
        'connect_timeout' => 10,
        'timeout'         => 10
        ];

    $response = $client->request('POST', $wsdl, $options);
    $xml = $response->getBody()->getContents();

    print $xml;

And the same in pure curl:

<?php

    $template = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header></soapenv:Header>
   <soapenv:Body>
      <tem:GetIndividualCourseDetail> …
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

if you add echo $client->__getLastRequest(); you can see what is sent to the SOAP server, in this case it will not set the sol namespace, see:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"><SOAP-ENV:Body><ns1:SearchCourseReturnCourseId/></SOAP-ENV:Body></SOAP-ENV:Envelope>

Since it's a complex request, use an object, basically do this:

$search = new stdClass;
$search->criteria = new stdClass;
$search->criteria->ProviderId = 25;

Full example:

<?php

$wsdl   = "http://service.fetchcourses.ie/service/FetchCourse.svc?wsdl"; 
$client = new SoapClient($wsdl, ['trace' => TRUE]);

$search = new stdClass;
$search->criteria = new stdClass;
$search->criteria->ProviderId = 25;

$values = $client->SearchCourseReturnCourseId($search);

# get response message
print $values->SearchCourseReturnCourseIdResult->ResponseInfo->ResponseMessage;

# get first listed course
print $values->SearchCourseReturnCourseIdResult->courses->CourseIds[1]->CourseId;

For reference see:

cereal 1,524 Nearly a Senior Poster Featured Poster

test

cereal 1,524 Nearly a Senior Poster Featured Poster

Your profile picture on Dazah?

Yes, I went to Control Panel > Edit Profile, but I don't find how to remove it.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello Dani,

how can I remove my image from the Dazah.com profile? It seems it was acquired through the GMail access.
Thanks!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

if you're trying to run the script outside the 000webhost.com hosting and you don't have a premium account, then the connection will fail, read:

cereal 1,524 Nearly a Senior Poster Featured Poster

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!

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

In short you need a script that can receive a GET request, filter it and use it to perform a query, in which case would be something like:

SELECT `last_name` FROM `clients` WHERE `last_name` LIKE 'LETTER%' ORDER BY `last_name`, `first_name` LIMIT 10;

Where 'LETTER%' would be a placeholder for a prepared statement, i.e. this :last_name and defined in PHP as:

$data[':last_name'] = $input . '%';

See:

I prefer autocomplete.js as with JQuery you have to add the UI library and what followes: styles, images and more code, but it's your choice:

Have you tried something? If affirmative, paste it here, so we can suggest you how to continue, if needed.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok,

then it can be the result set, that is buffered into PHP and that hits the limit. You can limit the query, but if you are retrieving blob data or large chunk of text even in small data sets you don't solve.

By default, MySQL queries are buffered, but you can avoid this behaviour. You should switch to PDO or MySQLi as the MySQL API is deprecated and now removed from PHP 7.*

But, anyway, instead of mysql_query() try mysql_unbuffered_query() as explained here:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

check if the new value was applied by using ini_get():

echo ini_get('memory_limit');

some hostings does not allow to change the core directives.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, do you mean database triggers?

cereal 1,524 Nearly a Senior Poster Featured Poster

By the way, have you tried through their API? https://codepen.io/bfred-it/pen/GgOvLM

rproffitt commented: That's the click to play fullscreen method. So far, you can't omit that click. +10
cereal 1,524 Nearly a Senior Poster Featured Poster

Before that line check if the $_FILES array exists: if the form is submitted without appending a file, or if the upload fails (file too big, for example), then you will get that error.

Also, you can use pathinfo() to get the extension:

$ext = pathinfo($_FILES['file']['name'])['extension'];

Docs: http://php.net/manual/en/function.pathinfo.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you still need a client side script to submit the on going request, you can do that without a framework, look for an example at the autocomplete.js code:

it does not have dependencies.

cereal 1,524 Nearly a Senior Poster Featured Poster

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?

cereal 1,524 Nearly a Senior Poster Featured Poster

After the execute() do:

$id = $con->lastInsertId();

Docs: http://php.net/manual/en/pdo.lastinsertid.php

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, it happens because the topics table is not listed it the FROM statement, add it as a JOIN, it should fix this issue.

cereal 1,524 Nearly a Senior Poster Featured Poster

Good, can you show also the query cited in your first post?

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, can you show the full query and the create table statement? Run: show create table topics;

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

topics.id stands for tableName.columnName, if this is not the case and you have a column name with a dot, then do:

SELECT `topics.id` FROM `topics`;

This will select the column with the dot. If it was a table name, instead it would be:

SELECT `topics`.`id` FROM `topics`;

Ref: http://dev.mysql.com/doc/refman/5.7/en/identifiers.html

cereal 1,524 Nearly a Senior Poster Featured Poster

A string is not an integer.

in PHP, from the POST and GET arrays, you always get strings, even if submitting integers. PHP does automatic type casting, but it can be forced as explained here:

cereal 1,524 Nearly a Senior Poster Featured Poster

Set exit; after the redirect, as in this comment:

That will stop the execution of the following code. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, use the search box in the developers website:

From there you can see how the add and update metadata functions are used and in which files are written.

See also:

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

The $id variable is undefined, at line 96 you check if it's empty but you're not defining it anywhere, so the condition will always be false and you will get the else statement at line 113, the same happens in the healthcheck file at lines 178 and 193.

cereal 1,524 Nearly a Senior Poster Featured Poster

But what if I cannot install anything? This isn't my server. I'm using hosting.

In this case ask the provider if they will introduce it and/or use the fetch methods, look for example at fetch_assoc(), for the other methods look at the result class:

The documentation says if the method is available only with mysqlnd, like for example fetch_all(), useful but unavailable with your setup.

Personal opinion: this inconsistence between the drivers is one of the reasons why I prefer PDO over MySQLi.

cereal 1,524 Nearly a Senior Poster Featured Poster

You get undefined because get_result() is a function introduced by the mysqlnd (MySQL Native Driver). Usually if you're using PHP 5.4 and above this is the default, otherwise PHP will use the libmysqlclient driver, see:

In practice the MySQLi extension can be served by two drivers, that can affect the behaviour of the script. Here you can read the differences between the two:

In general try to work always with the mysqlnd driver.

cereal 1,524 Nearly a Senior Poster Featured Poster

After the execute() do:

$stmt->store_result();

Then you can call $num_rows:

$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {

http://php.net/manual/en/mysqli-stmt.num-rows.php

cereal 1,524 Nearly a Senior Poster Featured Poster

But what is $stmt->bind_result($district); does it just store result in $district?

Yes, but only for the current result pointer.

Is this correct:

You have to store the result, otherwise you get 0.

cereal 1,524 Nearly a Senior Poster Featured Poster

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:

cereal 1,524 Nearly a Senior Poster Featured Poster

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, don't use single or double quotes around table and column names, otherwise these are interpreted as strings, use backticks, so:

INSERT INTO `members` (`username`, `password`, `email`) VALUES ('axe', 'axe', 'weql');