that's a JSONP response, so in order to process this through PHP you need to remove the callback function that wraps the JSON data, for example:

callback({JSON DATA});

At this point you can remove it from the string:


$jsonp = 'callback({"name": "micheal"});';
$callb = 'callback'; // to remove

$s = substr($jsonp, mb_strlen($callb) + 1); // +1 to include the opening `(`
$s = substr($s, 0, -2); // -2 to remove `);`

print_r(json_decode($s, true));

Now, most JSON servers allows the client to define a callback in the requesting link:


So you receive:

foo({JSON DATA});

This allows you to write a more robust solution, as it's should not affect your script if they change their default callback function. See also if the server allows to get other formats, like simple JSON or XML.


Embedded contens like YouTube and Vimeo are served by them directly to the client, your page just sends the resource link, then the client opens a connection to the resource. You can see this through the developer console in Chrome: select the Network tab, hit reload for your page and see how the browser start to request data do different domains.

This means that your website bandwidth is not affected by these streams. It would if the video file was hosted and streamed by your server. Or if it was streamed as a proxy system from your web server to the clients connecting to your domain, an example:

It's the same with Google fonts or javascript libraries served by CDN systems.

Votes + Comments
Good explanation of how things work.

This brings me straight to 2000-2003 years, at that time I was working in a small lab assembling & repairing computers, the worst was when people wanted to recover EFS encrypted files from Windows XP drives. Windows XP policy was insane, they allowed to use EFS without a recovery agent, so people could backup the files, format the disk, reinstall Windows and ta-da when copying back they could not anymore access the files. You try to explain that using the same username would not lead to success and that an additional step, previous to the encryption, was needed but nothing. The only available solution that I knew was to try to recover the temporary copy created when processing the file, but at that time it was really difficult to find information and open source solutions, at least to try.

Lately, instead, I was able to recover data from a damaged CF card through PhotoRec: http://www.cgsecurity.org/wiki/PhotoRec
actually it recovered not only the shoot day but also jobs from the last year.


However internalImageUpload() writes only to the database.

Instead, it's in:

imagejpeg($im, $upload_path.$filename);

I overlooked that, and yes by defining a second parameter you would save the resource loaded into $im. However you cannot inject (as far as I know) the contents from $_POST['image'] to $im.

Try something like this:


$uid      = $_POST['uid'];
$token    = $_POST['token'];
$group_id = $_POST['group_id'];
$needle   = $_POST['image'];
$haystack = 'data:image/png;base64,';
$png_blob = substr($needle, mb_stripos($needle, $haystack) + mb_strlen($haystack));

$upload_path = '../' . UPLOAD_PATH;
$filename    = time() . $uid . '.jpg';

// save to image folder
file_put_contents($upload_path . $filename, base64_decode($png_blob));

// save to database
internalImageUpload($uid, $filename, $group_id, FALSE);

$imageID       = internalGetUploadImage($uid, $filename);
$fullImagePath = BASE_URL . UPLOAD_PATH . $filename;

echo "<img src='".$fullImagePath."'  class='webcam_preview' id='".$imageID[0]->id."'/>";

Just make sure the path is correct, that ../ in $upload_path makes me nervous :D as it would always be relative to the link in the frontend side and to the system path in the backend side.


Okay, I got it to work, the JS function will export the canvas contents to PNG:


so, what you get in$_POST['image'] is a base64 encoded blob. All you need to do is to remove the data:image/png;base64, part, as you were doing, decode the remaining string and save it to a file, at basic:

$needle      = $_POST['image'];
$haystack    = 'data:image/png;base64,';
$png_blob    = substr($needle, mb_stripos($needle, $haystack) + mb_strlen($haystack));
$destination = __DIR__ . '/image.png';

file_put_contents($destination, base64_decode($png_blob));

So if $needle is data:image/png;base64,AAA..., $png_blob will be AAA. You don't need the GD functions unless you want to test if the resulting file is really a PNG and not a script.

Full test:

<!DOCTYPE html>

    <video id="player" width="480px" height="240px" autoplay="true"></video>
    <button id="takeSnap" class="startbutton messageButton">Take Snap</button>

    <div id="webcam">
        <input type="hidden" id="uploadvalues">
        <canvas id="snapshot"></canvas>
        <div id="webcam_preview"></div>

    <h3>Reload to see latest snapshot</h3>
    <img src="image.png">

    <script type="text/javascript" src="https://unpkg.com/jquery@3.2.1"></script>
    <script type="text/javascript">

        var captureButton = document.getElementById('takeSnap');
        var snapshot      = document.getElementById('snapshot');
        var video         = document.getElementById('player');

        // @see https://www.kirupa.com/html5/accessing_your_webcam_in_html5.htm

        navigator.getUserMedia  = navigator.getUserMedia
                               || navigator.webkitGetUserMedia
                               || navigator.mozGetUserMedia
                               || navigator.msGetUserMedia
                               || navigator.oGetUserMedia;

        if (navigator.getUserMedia)       
            navigator.getUserMedia({video: true}, handleVideo, videoError);

        function handleVideo(stream) {
            video.src = window.URL.createObjectURL(stream);

        function videoError(e) {
            // do something

        captureButton.addEventListener('click', function(e)
            var context = snapshot.getContext('2d');

            // Draw the video frame to the canvas.
            context.drawImage(player, 0, 0, snapshot.width, snapshot.height);

            //start webcam upload
            var webcamURL = 'post.php';

            $.post(webcamURL, {type: 'data', image: snapshot.toDataURL('image/png')}, function(data) {
                        var values = $('#uploadvalues').val();


                        var X = $('.webcam_preview').attr('id');

                        if ($.trim(values).length > 0)
                            var Z = X + ',' + values; ...
Votes + Comments
Nice work.
Going the extra mile, again :) +1



it could be the power supply or a RAM module. Do you hear any beeps when turning on? And if yes, how many? Each BIOS has is own codes and can give an idea of what is wrong, for example Intel's:

Also, are the fans spinning? If you can, test with another power supply. When testing unplug all disks from motherboard and see if you can get to the BIOS. If the power supply is fine then you would remove all peripherals and test each RAM module separately by moving the RAM into each (RAM) slot, to understand: if all RAM modules and slots are fine. And then move to each peripheral, until you isolate the problem.

NOTE - please, always be sure to have unplugged the computer from power electricity BEFORE you put your hands into the tower.



Something similar and probably more sane exists, see https://bountify.co/

There you can see each solution, unless the parts decide to use private messages. It works like this:

  • the requester sets a bounty, the range goes from 1 to 100 USD (before it allowed up to 500 USD) and it will stay active for 7 days
  • the requester pays the bounty upfront, on this stage he also pays a small fee to the website
  • if users decide to reply they usually use gist.github.com or pastebin & co. to share their solutions
  • the requester can discuss with each participant to fix the solutions
  • if the requester is happy with one of the provided solutions he/she can assign the bounty to the author
  • at this point the winner can receive the bounty

An example: https://bountify.co/help-converting-a-flat-json-file-into-hierarchical-json-schema-to-use-with-d3-treemap

If the requester does not choose a winner, or the winner does not withdraw the prize, after seven days the bounty will go to charity. Right now there is only one available, last time I checked there where a couple more, I think there was EFF also.

They have been up for the last five years and receive 3-4 requests per week.

Most of the time bounties are very low but people answer because they want to compete or try to solve the requests. However, I think this does not fit Daniweb and in general, forums.

If you think your idea can work, then put it up and see what you ...


Can you change excel sheet and make it importable into mysql tables?

Yes, it can be done. You can convert it to CSV and the use fgetcsv() and prepared statements. Search for PHPExcel or similar. If you use MariaDB, a MySQL fork, then you can use the ODBC connect engine to attach the excel file to a table and run a query to insert the rows into the destination table, see:



In addition to rproffitt's: contents, in the MS knowledge board, are loaded through Javascript, file_get_contents() won't load them, you need a rendering engine (like browsers do) to run your scripts. So you need something like PhantomJS: http://phantomjs.org/

Few months ago I posted an usage example here:

Which generates a screenshot of the page. The discussion was about testing the existence of a page with an HEAD request, which MS drops, and on success perform a GET request.



if you can edit the main php.ini file, change the option to on:


then reload the phpinfo page to see if it applied. The location of the file is defined in the Configuration File (php.ini) Path of the phpinfo view. If you cannot edit the main php.ini, you can try to create a new php.ini file in the document root. And just add the options you want to change. The Loaded Configuration File field of the phpinfo view should show if the new file is loaded.

Note: some times, the configuration (of PHP or of the web server) does not allow to override the settings through custom php.ini files, so you may need to contact your hosting support to make changes.

For more info, see the HOST and PATH directives:



you are missing a comma between these two columns, in the update statement:

work_carry = '$work_carry' demage_found = '$demage_found'

Then edit_customer_detail is not set by the form which, however, is okay if this is set by a previous step and carried through GET.


I see why, to be honest I was reading the documentation for PDO and saw why you were using fpassthru():

PDO::PARAM_LOB tells PDO to map the data as a stream, so that you can manipulate it using the PHP Streams API.

However while testing I got:

PHP Warning:  fpassthru() expects parameter 1 to be resource, string given

And in fact a comment in the same page states the same issue:


Just a note!

I was just curious to learn why anyone would bother using the long version if the short version can do the same job. file_get_contents() using a URL is not guaranteed to work in all situations, as it depends on a configuration setting to allow it to use HTTP (which is sometimes disabled for security reasons) ...

It happens because allow_url_fopen is set to false, in case curl is not available you can also use sockets or fsockopen() & co.

Also, file_get_contents() allows more complex requests, in fact, it can make POST requests, by using the resource context parameter. The same can be done by file(), readfile(), fopen() and in general by all functions that support streams, an example:


$url = "https://www.apple.com/";

// Resource context
$rc["http"]["method"] = "GET";
$rc["http"]["header"] = "Accept-language: en\r\n";
$rc["http"]["follow_location"] = 1; // 1 = yes, 0 = no
$rc["http"]["timeout"] = 10; // seconds

$context = stream_context_create($rc);

$fp = fopen($url, "r", FALSE, $context);

while( ! feof($fp))
    print fread($fp, 4096);


$name is defined? If not the loop will not run:

while($i < count($name))
    $stmt->execute([':user_id' => $user_id, ':name' => $name[$i], ':email' => $email[$i], ':role' => $role[$i]]);

Also, you could add debugDumpParams() to see what looks like the prepared statement:

while($i < count($name))
    $stmt->execute([':user_id' => $user_id, ':name' => $name[$i], ':email' => $email[$i], ':role' => $role[$i]]);

This will stop the execution after the first loop and will show the contents of the query. If it does not help paste the result here and also the code.

Votes + Comments
Big hyand for debugDumpParams