cereal 1,524 Nearly a Senior Poster Featured Poster

Can you show your current code? (HTML, JS and PHP)
The above results seem to be originated by your previous code.

cereal 1,524 Nearly a Senior Poster Featured Poster

Look, it works fine for me. Do this: open the Web Developer Console which is available in Google Chrome, Chromium and Mozilla Firefox, hit the Network tab and enter a letter in the autocomplete input field, you should see a request to the server, hit the request link and click the Response tab, you should see a JSON object with the rows.

cereal 1,524 Nearly a Senior Poster Featured Poster

Try with:

$i = 0;
while($row=sqlsrv_fetch_array($select)) 
{
    $data[$i]['code'] = $row['code'];
    $data[$i]['desc1'] = $row['desc1'];
    $i++;
}
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

check the source of the custom data example in the autocomplete JQueryUI documentation:

The select property should fit your requirements:

select: function( event, ui ) {
    $( "#project" ).val( ui.item.label );
    $( "#project-id" ).val( ui.item.value );
    $( "#project-description" ).html( ui.item.desc );
    $( "#project-icon" ).attr( "src", "images/" + ui.item.icon );

    return false;
  }

Another example: https://jsfiddle.net/0wdbgage/

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

with browsers requests, the server can only accept the upload and check the sizes when it finishes. So, if you want to manage the error through PHP, raise the size and set a lower limit in the script.

If the limit in the php.ini file is 25MB and the server gets a bigger request body, then you will not see an error response. But the error log should return some information. The server can also handle the request by limiting the body request size and return an error.

You can check the file size with javascript, before the upload starts, see this snippet:

This will not stop malicious users, but it can be user-friendly solution.

<rant>
If browsers worked properly then they would wait for a HTTP/1.1 100 CONTINUE response from the server: the client in this case must send the file size through an header, wait for the server to validate the request and then proceed or discard. That would be wonderful to save bandwidth.
</rant>

diafol commented: good link - bookmarked :) +15
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

right before this code, set a check:

/* check connection */
if(mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

Too see why the connection returns null.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you have to share more information about the issue, the form and the controller code could also help.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi Dani! :D

I have few points:

A

I still not receive emails (newsletter, notifications) with my registration email address (the Receive Community-related Email? issue). I only receive the monthly newsletter with the email address of the other account. To watch an article I have to use that account from another browser, otherwise I don't get anything.

B

My old private messages are all in the other account.

C

I edited my Dazah profile to NOT display my name, but here in the forum is still shown in my Profile & CV pages.

Sincerly, I'm here just to ask or reply few questions in the forums, not to network. I think I've understood what you want to achieve, but these changes made me feel a bit unconfortable.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

in addition to Ddanbe's suggestion: with Google Chrome, right click a word in this post, choose Inspect, it will open the Web Developer Console, click on Computed: from there you get all the style information about the inspected element.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

if you want to download the project to a new box then you clone it, so you do:

git clone url_of_the_repository

If the code is already there, but not updated to the latest version, then you just pull:

git pull

and then you can push the changes. See:

diafol commented: good, as always :) +15
cereal 1,524 Nearly a Senior Poster Featured Poster

-sigh-
Why is it so, that when there's an issue, people look all around :D, but not on the issue.

lol, I asked because I do not know how you are implementing that statement and what you really expect to get. What do you mean by true 404? A redirect to the 404 error page defined by the server?

This:

While Opera fools itself, Firefox doesn't. It shows just super-empty document (not 404, but also not even standard CSS stylesheet). How do I successfully send "404 Not Found" to ALL browser.

is not a useful information, to understand your issue.

Look, to me it's easier to move the includes scripts into a separated directory, then use .htaccess to deny direct access to that directory, so it cannot be accessed through the browser.

This solution does not require to modify the scripts, so nothing like the header() 404 statement, if really needed you could force it through .htaccess and send a more appropriate 403 or even 404.

It's even better if you move the includes directory to the parent of the public_html directory, which if correctly set, is not accessible by the browsers, that way you don't even need to use .htaccess file to define what is accessible and what not.

diafol commented: GSOH! +15
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

It happens because of rounding errors, for more information see:

You could try with Decimal():

from decimal import Decimal

# with binary floating points
print(divmod(356, 3.56))
(99.0, 3.5599999999999947)

# with arbitrary roundings
print(Decimal('356') % Decimal('3.56'))
0.0

Example: http://ideone.com/a6UDRi

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

have you tried the web developer console integrated in your browser (Mozilla Firefox, Chrome, Chromium) to see if the javascript code is raising some errors?

Can you provide a live example?

Besides, test your script with a simple HTML form, you will see there are at least few issues:

Issue 1
move_uploaded_file($_FILES["fileUpload"]["tmp_name"],WWW_ROOT.$dirname."/".$_FILES["file"]["name"]);

In the first parameter you refer to fileUpload, in the second to file, so it's like if your are trying to get the values from two different arrays. Fix them to match fileUpload as defined in the javascript.

Issue 2

This involves multiple lines:

/// client side
<input id="serverUrl" type="text" value="http://sample.com/mobile_app/upload_img.php" />

/// server side
$dirname = "./user_img";
mkdir ($dirname, 0777, true); 
move_uploaded_file($_FILES["fileUpload"]["tmp_name"],WWW_ROOT.$dirname."/".$_FILES["file"]["name"]);

If you define $dirname with a relative path, then the upload_img.php script will create the directory inside his own path, so you end with:

/mobile_app/user_img/

The move_uploaded_file() function, instead, points to the document root, and you get something like this:

/./user_img/

The mover function will not find the path, so it will fail to complete the task. However, the $_FILES array gets populated before these things happen, so it may not affect your current issue.

Issue 3

The mkdir() will raise a warning as soon you run the script successfully for the second time, because the path already exists. Use file_exists() to verify if it exists, or just create it manually and remove mkdir().

cereal 1,524 Nearly a Senior Poster Featured Poster

@zebnoon1 Hi, you were asked multiple times, to reply to some questions with useful information. Calmly read again Pritaeas posts and reply to his requests.

For example, he asked:

What size is the downloaded file?

So the downloaded .pdf file is 0 bytes, few bytes and when opens is like corrupted? Have you tried to open the file into your PHP editor? Because it could be a plain-text file (with .pdf extension) and more importantly with a PHP error generated by your script. If this is so, then that error could help a lot to understand what happens.

So read again Pritaeas posts and reply to his requests.

pritaeas commented: :) +15
cereal 1,524 Nearly a Senior Poster Featured Poster

Also:

filter_var($not_an_int, FILTER_VALIDATE_INT);

Returns FALSE when it's not an integer: http://ideone.com/O3wyIS

diafol commented: I favour this one +15
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you could use filter_var() with FILTER_SANITIZE_NUMBER_INT:

filter_var($not_an_int, FILTER_SANITIZE_NUMBER_INT);
filter_var($actual_int, FILTER_SANITIZE_NUMBER_INT);

Will return string, that can be casted, se an example here:

Docs: http://php.net/manual/en/filter.filters.sanitize.php

cereal 1,524 Nearly a Senior Poster Featured Poster

To tell the truth, there is a space between the substitution and the flags:

RewriteRule ^new/([0-9]+)/?$ new.php?msgID=$1 [R=301,L]
           ↑                ↑                ↑
         space            space            space

What you returned is without the space. That rule works fine for me, so could you share the code of the new.php file? Because, I really don't have other suggestions right now.

rproffitt commented: Gimme my spaces. +11
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

the composer command development-enable is part of the zf-development-mode tools which ships in version 3.0 and requires PHP 5.6 or PHP 7.0, you're using 5.4, so it won't be installed. See if you can install version 2.* of these tools, as it should support your PHP version. For more information see:

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, so the /155 segment should be the msg_id, correct? Can you show us the rewrite rules? Maybe you just need to point to another index, try to dump the $_GET array var_dump($_GET); to see what is set.

If I can suggest, consider to include a router into your application, something like nikic/FastRoute:

This is already in the Slim framework, and allows you to define a new link like this:

$app = new \Slim\App();
$app->get('/messages/{msg_id}/{another_var}', function($request, $response, $args) {
    echo $args['msg_id'] . ' ' . $args['another_var'];
});

Adding variables at that point becomes easy.

cereal 1,524 Nearly a Senior Poster Featured Poster

The backtick is the operator used to define those objects known as identifiers: table names, columns, databases and to distinguish a column name, for example, from a reserved word. See: http://dev.mysql.com/doc/refman/5.7/en/identifiers.html

To test your query, open the mysql client and run:

\W -- to enable warnings
SELECT `type` FROM `messages` WHERE `msg_id` = 1;

If it runs fine, then see if $_GET['msg_id'] is set, because, otherwise, it's like sending this query:

SELECT `type` FROM `messages` WHERE `msg_id` = ;

Which will raise the same syntax error.

cereal 1,524 Nearly a Senior Poster Featured Poster

@phpio

Hi,
the source of __FILE__ (and the other files in the same path) can still be read with this line:

include "php://filter/convert.base64-encode/resource=index.php";

This is a variant of the LFI (Local File Inclusion attack) that uses php://filter and will return a base64 string that, converted, shows the source code. When the filesystem was accessible then reading the contents of files, like /etc/passwd, was simply a matter of writing the correct path.

More info about php:// @ http://php.net/manual/en/wrappers.php.php

diafol commented: You are a naughty boy cereal :D +15
cereal 1,524 Nearly a Senior Poster Featured Poster

@phpio

Hi,

test diafol's script and execute / you get the system root, you can traverse the filesystem, you can arrive to the passwd file from there. Also, it's possible to:

  • download the script that executes the code
  • write to the parent directory through the error_log() function
  • execute SQLite and create a database directly in RAM

I suggest you to stop this box, and start from a new installation, set correct permissions otherwise the system can be compromised.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you can setup a replication model: master to master or master to slave. See:

I suggest you to do a research on Google about MySQL Replication, you will find a lot of tutorials and solutions.

cereal 1,524 Nearly a Senior Poster Featured Poster

@Antony try:

SELECT * FROM `TABLENAME` ODER BY date_format(str_to_date(`TIME_COLUMN`, '%r'), '%T') ASC;

This will convert the string to a timestamp that MySQL can parse, then use %T to get the order in the 24H format. But, as suggested, it's better to convert the existing rows into the 24H format and then always save in that format, to avoid extra processing. So you could run an update query, just like above:

UPDATE `TABLENAME` SET `TIME_COLUM` = date_format(str_to_date(`TIME_COLUMN`, '%r'), '%T');

Replace TABLENAME and TIME_COLUMN with yours and remember to test on a copy.

Rule is: save always in UTC, save always in the format that the database can parse, then convert for the client.

For more info see:

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

go to http://regexr.com/3eb88 and mousehover the components of the expression (or hit the Explain tab), it will explain the meaning of each block. If you have some sample data you can paste it in their form and see how it is applied.

For example, try to change [\W_] to [\w] to see what is parsed.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,

so, standing at the original example you want two rows for each date > item, correct?

Use implode() after each cycle, change this:

# loop each date > item
foreach($items as $item)

    # loop each date > item > item
    foreach($item as $elem)
        $r[] = sprintf('%s %s %s'
                     , $elem->attributes()->Name
                     , $elem->attributes()->Type
                     , $elem);

to:

# loop each date > item
foreach($items as $item)
{
    # initialize the $r array at each loop
    $r = [];

    # loop each date > item > item
    foreach($item as $elem)
    {
        $r[] = sprintf('%s %s %s'
                     , $elem->attributes()->Name
                     , $elem->attributes()->Type
                     , $elem);
    }

    # convert the $r array to a string
    $s[] = implode(',', $r);
}

The contents of $s will look like this:

array (2) [
    string (184) "received Date 2015/12/18 00:00,accepted Date 2016/03/31 00:00,aheadofprint Date 2016/04/14 00:00,entrez Date 2016/04/15 06:00,pubmed Date 2016/04/15 06:00,medline Date 2016/04/15 06:00"
    string (152) "epublish Date 2016/05/23 00:00,entrez Date 2016/07/12 06:00,pubmed Date 2016/07/12 06:00,medline Date 2016/07/12 06:00,pmc-release Date 2017/01/01 00:00"
]

If you want them all in the same string, then just initialize the $r array before or the first loop (# loop each <date> node) and move the implode out of the loops, at the end, basically:

$r = [];

# loops

$s = implode(',', $r);
cereal 1,524 Nearly a Senior Poster Featured Poster

If you just need to remove what comes after the first occurrence of the bracket and display what is remaining, then you could basically loop the input into strstr(), like this:

$line = 'Águila (El Salvador)';
$out = strstr($line, '(', TRUE) . '(';
print $out; # Águila (

See: http://php.net/manual/en/function.strstr.php
Example:

<?php

$fp = function($file) {

    $out   = '';
    $lines = file($file);

    foreach($lines as $line)
        $out .= strstr($line, '(', TRUE) . '(' . PHP_EOL;

    return $out;
};

$output = $fp('./input.txt');
print $output;

Or switch to fopen if the input is a big file.

cereal 1,524 Nearly a Senior Poster Featured Poster

It happens because you have to manually move to the next node, you can do like this:

<?php

$file = 'dates.xml';
$xml  = simplexml_load_file($file);

# loop each <date> node
foreach($xml->date as $node) {

    $items = $node->children();

    # loop each date > item
    foreach($items as $item)

        # loop each date > item > item
        foreach($item as $elem)
            $r[] = sprintf('%s %s %s'
                         , $elem->attributes()->Name
                         , $elem->attributes()->Type
                         , $elem);
}

print_r($r);

Will return:

Array
(
    [0] => received Date 2015/12/18 00:00
    [1] => accepted Date 2016/03/31 00:00
    [2] => aheadofprint Date 2016/04/14 00:00
    [3] => entrez Date 2016/04/15 06:00
    [4] => pubmed Date 2016/04/15 06:00
    [5] => medline Date 2016/04/15 06:00
    [6] => epublish Date 2016/05/23 00:00
    [7] => entrez Date 2016/07/12 06:00
    [8] => pubmed Date 2016/07/12 06:00
    [9] => medline Date 2016/07/12 06:00
    [10] => pmc-release Date 2017/01/01 00:00
)

To get the attributes, in this case, since $elem will be a SimpleXMLElement object you can use the attributes() method:

Use var_dump() or a debugger like this to see which kind of object you are iterating, for example:

foreach($items as $item)
    sd($item);

Returns:

SimpleXMLElement (2) (
    public @attributes -> array (2) [
        'Name' => string (7) "History"
        'Type' => string (4) "List"
    ]
    public Item -> array (6) [
        string (16) "2015/12/18 00:00"
        string (16) "2016/03/31 00:00"
        string (16) "2016/04/14 00:00"
        string (16) "2016/04/15 06:00"
        string (16) "2016/04/15 06:00"
        string (16) "2016/04/15 06:00"
    ]
)

So you can see the attributes of the main node:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

according to FPDF manual the Output() arguments must be reversed, instead of:

$pdf->Output('newpdf.pdf', 'D');

Do:

$pdf->Output('D', 'newpdf.pdf');

Documentation:

Also, if you want to force the download, then change the Content-Disposition header to attachment.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

can you describe the problem?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

in the first line (drop ...) is missing the separator (the semi-colon in this case), so all the following falls into a syntax error.

cereal 1,524 Nearly a Senior Poster Featured Poster

@rproffitt The cron program is indeed a daemon, but the scripts listed in the cron table (crontab) are usually not daemons: once executed they quit and will ran again at the defined time in the crontab. Cron has 1 minute limitation, it does not execute immediately, so once you send the job, for example: by altering a database table value, or by using a lock file, it will start in the next valid minute.

Cron will, also, start a new instance of the script, with a different PID, when the time is reached again, so you can end having uncontrolled multiple instances of the same script running on the same batches, if the rows are not signed as in one of the current queues.

Obviously one could list multiple scripts in the crontab to do the same work and speed the execution, but again these processes will be concurrent in the query requests and each script will have to lock the database and sort which rows to process.

IMHO this is where work queues softwares come handy and solves most of these issues. In this case the worker script is usually a daemon that waits to process a job. The client instead it can be a simple PHP script that receives the request from a form (or even by cron) and submits the jobs to the job server. It's a very different approach.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello all!

@spluskhan you can do that, but by increasing the number of bills to process, the script may crash for timeout or for memory issues, for this reason you were requested to provide more details.

To keep it simple: you can start the bill generation process by pressing a form button, but you need to delegate the work to another script that runs in background and process the request asynchronously. You have to define a queue, and process it by a batch, eg 100 bills at time.

With cronjob you can create a script that consumes the queue at regular intervals, the minimum is 1 minute. It means that if the script is able to generate 100 PDF in 1 minute, then, you can generate 1000 bills in 10 minutes. But you have to log somewhere (perhaps the database) which rows are in the queue, which have been executed successfully and also the failures, so that you can repeat the failed job and don't miss any bill.

With cronjob you may not have timeout issues, because the script will quit when it finishes and it will start a new process when the cron tab is executed, but you have less control and possibly more latency.

For this task I would prefer using a daemon: a script that waits to get a job (the bill generation) and that when it finishes it starts another one, without quitting. If your server is able to process multiple requests, then you can add …

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

it happens because in <140/90 mmHg OR <130/80 mmHg) there is the < character that has a special meaning in the HTML parsing. Example:

<?php

$html = '<p>Hello < 140 / 32 World</p>';
$dom  = new DomDocument();
$dom->loadHTML($html);

print $dom->saveHTML();

It returns <p>Hello </p> (I've stripped the rest of the HTML).

To solve you could strip all the tags, or replace them with placeholders, see Textile for example, convert to HTML entities all the special characters and then inject them back in the page.

But it's not worth if this has to be done frequently. In my opinion you should:

  • save questions and answers into a database;
  • apply an encoding (UTF-8 for example) to these strings: in the database, in the server so that requests and responses are treated the same, and in the HTML page, so that the browser will display them correctly;
  • use a template to generate the pages: so that you have to change only one file;
  • use approriate tags: titles and lists instead of paragraphs everywhere;
  • use external styles to change the appearance of the elements

or, if semantically relevant, you could just modify the template to add tags like strong, but operate on a template instead of altering multiple static files.

cereal 1,524 Nearly a Senior Poster Featured Poster

Fix this part of the code:

foreach ($_FILES['audioaud']['name'] as $name => $value)
{
    $filename = stripslashes($_FILES['audioaud']['name'][$name]);

the first argument of the foreach should be an array, you're submitting a string, unless you're uploading multiple arrays and you set the name attribute to array, so instead of:

<input type="file" name="audioaud" id="audioaud">

you shall write:

<input type="file" name="audioaud[]" id="audioaud">

only by applying this change you get arrays:

Array
(
    [name] => Array
        (
            [0] => foo.txt
            [1] => bar.txt
        )

    [type] => Array
        (
            [0] => text/plain
            [1] => text/plain
        )
...

Otherwise you get strings and the loop is not required. To simplify the testing part, add a debugger, a good choice for SlimPHP is Kint, check it here:

Docs:

Are they more than one php.ini files on a wamp server?

I don't know about WAMP setups, on linux yes: there are different config files for each extension and SAPI, for example when using PHP-FPM you can create separated pools to start an app with a different user & group.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

remove the ; from this line:

always_populate_raw_post_data = -1

semi-colons, in the PHP configuration files, are used to comment lines and exclude them from the parsing.

//Edit
And remember to reload the server.

cereal 1,524 Nearly a Senior Poster Featured Poster

the browser display "Cannot Select Database".

ok, it's the same issue: add the $conn parameter to the mysqli_select_db() function, see:

If you read the documentation carefully, you will see that the MySQLi extension supports procedural and object styles, depending on what you use, the number of parameters will change.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi Zelrick,

line 21: $mypassword=$_POST['pwd'[; wrong closing bracket, fix that and the script seems fine, for me.

Have you tried to print something before the rest of the script executes? Put the following on the top of the script and send the request through the form:

die('date: ' . date('Y-m-d H:i:s'));

You should, at least, see the output of this line. If it does not work, repeat the same line under a new file, then request it directly from the browser (to test a GET request) and then point the form to the new file to test a POST request. If it's not the PHP configuration and the login.php file is not corrupted by some invisible character, then it could be Apache: POST requests can be disabled, but usually not in the default configuration.

In my firefox browser, I type this.. localhost/portal/Test/login.html
I think I set my localhost as /var/www/html

Apache, with the default configuration, uses two log files: one for the errors and one for the access requests. From there you can see if the form is submitted and how the server answers to the request.

You can find these files under /var/log/apache2/ or check the /etc/apache2/apache2.conf file to get the correct location.

The PHP log file is usually under /var/log/ too. See if it returns something useful.

From here I cannot do much more. For this reason too I suggested you to use the built-in server: at least you don't have to deal with web …

cereal 1,524 Nearly a Senior Poster Featured Poster

Is the Apache access log registering the requests? Are you accessing the form page from the server or through file:///?

There are some errors at lines 25, 27, 31 and 33 of the login.php file:

$myusername = mysqli_real_escape_string($myusername);
$password = mysqli_real_escape_string($mypassword);
$result = mysqli_query($sql,$conn);
$conn = mysqli_num_rows($result);

Add the connection parameter to the escape functions, reverse the parameters in the query function and, in the last line, change $conn with $count:

$myusername = mysqli_real_escape_string($conn, $myusername);
$password = mysqli_real_escape_string($conn, $mypassword);
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);

You should enable error reporting by adding this on top of your scripts:

error_reporting(E_ALL);

Docs to read:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

in the dbconnect.php file you have this line:

$conn = new mysql($servername, $username, $password);

which is wrong. In PHP there are three APIs that you can use: mysql, mysqli and PDO. The first is deprecated in PHP 5.* and removed from the latest version (7). I think here you want to use new mysqli() info here.

In the other files you are not using anymore the connection created by the dbconnect.php file, instead you're using the functions of the deprecated API: mysql_query() and so on. You have to convert your script to mysqli or PDO.

Read: http://php.net/manual/en/mysqlinfo.api.choosing.php

And once you decided which to use between mysqli or PDO learn, first of all, to use prepared statements:

don't ignore this practice, it will help you to write safer scripts.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

so you want to group the names under each town? For example:

<ul>
    <li>Town
        <ul>
            <li>Name X</li>
            <li>Name Y</li>
            <li>Name Z</li>
        </ul>
    </li>
    ...
</ul>

is this correct?

cereal 1,524 Nearly a Senior Poster Featured Poster

ErrorUnknown column 'created_at' in 'where clause'
How to overcome this

Replace with the appropriate columns, mine is an example, I don't know your table structure.

rproffitt commented: I'll upvote and share my table has four legs. +10
zelrick commented: I'll upvote also coz Sir rproffitt has the best structure of table lol +2
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

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

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

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

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'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: