cereal 1,524 Nearly a Senior Poster Featured Poster

If the are columns with the same name, for example id, when using the wildcard character the database will return error 1052:

Solution is to define each column:

SELECT property.id, personal.id, spouse.id FROM property JOIN personal ON personal.id = property.id JOIN spouse ON spouse.id = property.id;

As explained in the linked documentation above. Read also:

By the way do not use the MySQL API (mysql_query() & co.) switch to MySQLi or PDO:

cereal 1,524 Nearly a Senior Poster Featured Poster

Too bad I didn't read their docs! Thanks for sharing the solution. Bye ;D

cereal 1,524 Nearly a Senior Poster Featured Poster

Sorry for my last post, I think it doesn't help much: I'm seeing some weird results from BlueHost DNS server, whatever you search through dig is redirected to the same IP address 74.220.199.6 which is parking.bluehost.com, it doesn't match passhe.edu because they do not redirect any .edu domain, some information here:

So I'm not anymore sure this can be related with your issue. For now, please, do not consider it.

Going back to your script: last check you can do is to search directly their IP:

<?php

    $url = "http://204.235.148.32:8042/cgi-bin/Pwebrecon.cgi";
    print_r(get_headers($url));

With the IP it should work fine and temporarly fix your script, but if the problem is with your hosting DNS then it doesn't solve your issue in case you try to perform a request to another edu domain, for example:

<?php

    $url = "https://search.library.cornell.edu/";
    print_r(get_headers($url));

Anyway, I would still try the dig commands from a terminal in your remote server to evaluate the output and ask if it's possible to enable a forwarding DNS. If the correct IP is displayed then it's not BlueHost but something else like diafol's suggestion.

cereal 1,524 Nearly a Senior Poster Featured Poster

Forgot to add

klnpa.org is reachable from BlueHost DNS, so it may be this the problem, here's the output:

dig @ns1.bluehost.com klnpa.org

; <<>> DiG 9.9.5-3-Ubuntu <<>> @ns1.bluehost.com klnpa.org
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32087
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 2800
;; QUESTION SECTION:
;klnpa.org.                     IN      A

;; ANSWER SECTION:
klnpa.org.              60      IN      A       74.220.199.6

;; Query time: 210 msec
;; SERVER: 74.220.195.31#53(74.220.195.31)
;; WHEN: Tue Nov 25 21:26:39 CET 2014
;; MSG SIZE  rcvd: 54

As you can see there is an Answer Section with the IP address of klnpa.org. Depending on the configuration of your hosting plan, maybe you can add a forwarder DNS to match correctly all the domains, but as suggested in my previous post you may want to ask support to BlueHost.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ah, so as diafol suspected, then, there's something that prevents my server from accessing the Pilot one. (Right?)

Yes, the error of get_headers() helps a bit: failed to open stream: Connection timed out.

I suspect the problem is given by the DNS of Bluehost, which are:

  • ns1.bluehost.com
  • ns2.bluehost.com

By quering passhe.edu through the dig command we can see the domain is not resolved by their DNS servers and so it could not be reachable from your server:

dig @ns1.bluehost.com passhe.edu

; <<>> DiG 9.9.5-3-Ubuntu <<>> @ns1.bluehost.com passhe.edu
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56885
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 2800
;; QUESTION SECTION:
;passhe.edu.                    IN      A

;; Query time: 242 msec
;; SERVER: 74.220.195.31#53(74.220.195.31)
;; WHEN: Tue Nov 25 20:40:23 CET 2014
;; MSG SIZE  rcvd: 39

While by testing through Google DNS we can see it:

dig @8.8.8.8 passhe.edu

; <<>> DiG 9.9.5-3-Ubuntu <<>> @8.8.8.8 passhe.edu
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20522
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;passhe.edu.                    IN      A

;; ANSWER SECTION:
passhe.edu.             899     IN      A       204.235.147.180

;; Query time: 247 msec
;; SERVER: 8.8.8.8#53(8.8.8.8) …
cereal 1,524 Nearly a Senior Poster Featured Poster

I think your setup should support this script.

Check the PHP error log on Bluehost and, if this doesn't help, then check the access & error log of Apache (or of the web server in use), from there you can understand if the problem is PHP or, as suggested, if the access is failing from your server.

A simple test you can do:

<?php

    $url = "http://pilot.passhe.edu:8042/cgi-bin/Pwebrecon.cgi";
    print_r(get_headers($url));

Should return something like this:

Array
(
    [0] => HTTP/1.1 200 OK
    [1] => Date: Mon, 24 Nov 2014 12:01:11 GMT
    [2] => Server: Apache
    [3] => Connection: close
    [4] => Content-Type: text/html
)

At least you make sure it's accessible from your server.

cereal 1,524 Nearly a Senior Poster Featured Poster

As I wrote:

the same applies to the user, the password and the database name

it means that you have to change them, accordingly with your database setup.

cereal 1,524 Nearly a Senior Poster Featured Poster

This error is generated by the database connection string:

$db = new mysqli("host","user","pass","db");

Change the first parameter to the IP of your database for example localhost or 127.0.0.1, the same applies to the user, the password and the database name. Since the connection fails, it fails everything else. To prevent such errors you have to check if the connection is up, if you really got a result set from the database and then you can go further. For more information you can read this thread:

cereal 1,524 Nearly a Senior Poster Featured Poster

The problem is given by the closing bracket } of the very first IF statement:

if(isset($_GET['question'])){
    $question = preg_replace('/[^0-9]/', "", $_GET['question']);
    $next = $question + 1;
    $prev = $question - 1;
} // <-- this is missing
cereal 1,524 Nearly a Senior Poster Featured Poster

Have you tried open source solutions? Here's a list:

cereal 1,524 Nearly a Senior Poster Featured Poster

Follow these instructions: http://dev.mysql.com/doc/refman/5.6/en/time-zone-support.html

But you should always save as UTC and then convert the datetime to the client local timezone.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, here you can see the code and play the example:

Just click on run and then submit the form.

diafol commented: Thanks for the url - new site on me - runnable. Brilliant +15
cereal 1,524 Nearly a Senior Poster Featured Poster

(Or are you guys saying that you were actually able to return something from http://pilot.passhe.edu:8042/ ?)

(yes), it works fine for me, I'm attaching my full examples. If preferred I can paste all the code here.

what I'm asking is, what is there about http://pilot.passhe.edu:8042/ ... that makes it different from other sites that cURL readily scrapes?

Since it works, for me, there is no reason why this link is different from others.

cereal 1,524 Nearly a Senior Poster Featured Poster

On/off status for what? The website? Then you can use artisan from the command console:

php artisan down

The website will go in maintenance mode. With up it will go back online. If you wish something different then, please, explain it better.

cereal 1,524 Nearly a Senior Poster Featured Poster

It happens because you are defining these variables only when a POST request is submitted to the script, while on GET request (i.e. when you open the page) these variables are not defined.

So, initizialize them on top of the script:

<?php session_start();

    $submitted = FALSE;
    $name = '';
    $email = '';
    $message = '';

For the validation of the form, instead, use filter_input:

cereal 1,524 Nearly a Senior Poster Featured Poster

@Ryujin

In addition to diafol suggestion :)

There is no specific rule, you have to try the forms to understand the functionality. In the vufind case the first problem is given by the $url, you're targetting the form page, but the action of the form is pointing to another page:

<form method="get" action="/vufind/Search/Results" id="advSearchForm" name="searchForm" class="search">

so to get results $url must be:

https://vf-kutz.klnpa.org/vufind/Search/Results

The method must be GET, because they could verify the request method also, since this is an advanced search form, the receiving script is going to check for more variables, for example, by searching math & euler the minimun query string to send is this:

$data = array(

    'join'              => 'AND',
    'bool0'             => array(
        'AND'
        ),

    'lookfor0'          => array(
        'math',
        'euler',
        ''
        ),

    'type0'             => array(
        'AllFields',
        'AllFields',
        'AllFields'
        ),

    'sort'              => 'relevance',
    'submit'            => 'Find',
    'illustration'      => -1,
    'daterange'         => array(
        'publishDate'
        ),

    'publishDatefrom'   => '',
    'publishDateto'     => ''

);

$body = http_build_query($data);
$url  = "https://vf-kutz.klnpa.org/vufind/Search/Results?".$body;
$results_page = curl($url);

Note lookfor0[], bool0[], type0[], daterange[]: are all arrays for example lookfor0[] can be declared multiple times, but there are some conditions: you have to match each with $type0[]. The above can be rewritten like this:

$data = array(

    'join'              => 'AND',
    'bool0[]'           => 'AND',
    'lookfor0[0]'       => 'math',
    'lookfor0[1]'       => 'euler',
    'lookfor0[2]'       => '',
    'type0[0]'          => 'AllFields',
    'type0[1]'          => 'AllFields',
    'type0[2]'          => 'AllFields',
    'sort'              => 'relevance',
    'submit'            => 'Find',
    'illustration'      => -1,
    'daterange[]'       => 'publishDate',
    'publishDatefrom'   => '', …
diafol commented: sorry c, heh heh, didn't mean to wander off in another direction +15
cereal 1,524 Nearly a Senior Poster Featured Poster

Follow this link http://windows.php.net/download/

You can choose the NTS (Non Thread Safe) version if IIS is serving PHP as fastcgi module, more information on http://php.iis.net/

cereal 1,524 Nearly a Senior Poster Featured Poster

This is defined by server configuration, if using Apache this can be declared also in the .htaccess context, for example:

DirectoryIndex index.html index.php
cereal 1,524 Nearly a Senior Poster Featured Poster

If you use prepared statements then it's not a problem, create the list of queries:

<?php

    return array(

        "query_cities"  => "SELECT * FROM cities WHERE name = ?",
        "query_address" => "SELECT * FROM addresses a JOIN cities c ON c.id = a.city_id WHERE street_name = ? AND zipcode = ?",

    );

Then require the list:

<?php

    $list = require './queries.php';

    # query cities
    $param = array(
        $_GET['city_id']
    );

    $stmt = $pdo->prepare($list['query_city']);
    $stmt->execute($param);
    $city = $stmt->fetchAll();


    # query addresses
    $param = array(
        $_GET['street_name'],
        $_GET['zipcode']
    );

    $stmt = $pdo->prepare($list['query_address']);
    $stmt->execute($param);
    $address = $stmt->fetchAll();
cereal 1,524 Nearly a Senior Poster Featured Poster

Are you using indexes? You can enable the slow query log to see in which conditions this happens:

cereal 1,524 Nearly a Senior Poster Featured Poster

There are few errors in the CSS, first at line 17 of the HTML page fix this:

header h1 { font-size: 48px;
    } type="text/css">

By removing type="text/css">. Then inside the css file at line 79:

nav li:hover {
    background: blue;

nav li:nth-child(even) a {
    color: red;
}

You are not closing the brackets:

nav li:hover {
    background: blue;
}

nav li:nth-child(even) a {
    color: red;
}

At the end of the file it's missing another closing bracket:

@media only screen and (min-width : 320px) and (max-width: 767px) {
/* Styles */

When in doubt you can use the CSS validator:

cereal 1,524 Nearly a Senior Poster Featured Poster

The problem here is that you are defining the array of options for curl without including the POST data:

CURLOPT_POSTFIELDS     => $curl_data,

$curl_data is not defined anywhere, and you're including the input in the url so this becomes a post request with an empty body and the variables in the GET array. What you can do is to prepare the body like this:

$DDCnumber = 873;
$url = "http://pilot.passhe.edu:8042/cgi-bin/Pwebrecon.cgi";

$data = array(
    'DB'            => 'local',
    'CNT'           => 90,
    'Search_Arg'    => $DDCnumber,
    'Search_Code'   => 'CALL',
    'submit.x'      => 23,
    'submit.y'      => 23
    );

$body = http_build_query($data);
$results_page = curl($url, $body);

And add an argument to the function:

function curl($url, $curl_data) {

then it should work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

Check if in your system there is the php_gmp.dll file, then edit php.ini and append:

extension=php_gmp.dll

Restart Apache and it should work. Check the comments for more information:

Otherwise, if you cannot find the dll file, you can use Math_BigInteger, you can install it by using pear or composer:

pear install Math_BigInteger
composer require pear/math_biginteger

In both cases you need to install the pear client or the composer client:

There's also BC Math which sometimes is shipped with the PHP core installation, but it depends a lot on the PHP version in use, I'm not sure about Windows situation. All these libraries treats the numbers as strings, which gives you the ability to not be limited by the CPU architecture. Math_BigInteger, when available, will use GMP or BC_Math to speed up the execution.

Example:

<?php

    require_once '/path/vendor/autoload.php';

    $a = new Math_BigInteger(rand(0,100), 10);
    $b = new Math_BigInteger(md5('test'), 16);

    echo $a->bitwise_xor($b);

By the way, I'm not sure this example is what you need, I'm just replicating my first example ^_^'

edit

I was forgetting, Math_BigInteger is also available on GitHub:

Just donwload library and include it in your script. This does not require for you to install pear or composer... bye!

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

@Lokesh_4 open a new thread, explain the issue and show the code.

cereal 1,524 Nearly a Senior Poster Featured Poster

Assign height and width to the #banner-background:

#banner-background {
    width:100%;
    height:100px;
    background: url('/images/banner.jpg') no-repeat top left scroll;
}

Then, if you want, you can assign the background directly to the parent div of the inputs:

<div id="banner-background">
    <input type="text" class="form" name="email">
    <input type="text" class="form" name="password">
</div>
cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe:

$xor1 = gmp_init(md5('test'), 16);
$xor2 = gmp_init(decbin(rand(0, 100)), 2);
$xor3 = gmp_xor($xor1, $xor2);

echo gmp_strval($xor3);

?

cereal 1,524 Nearly a Senior Poster Featured Poster

Yup, use the Geocoding API, you can use cURL or simply file_get_contents(), an example:

<?php

    # geocoding
    $api = 'YOUR_SERVER_API_KEY';
    $url = 'https://maps.googleapis.com/maps/api/geocode/';
    $format = 'json';

    $paramenters = array(
        'address' => $_GET['address_line'],
        'key'     => $api
    );

    $submit   = $url . $format . '?' . http_build_query($paramenters);
    $response = json_decode(file_get_contents($submit), true);

    print_r($response);

The format can be either json or xml. Note: the Geocoding API is meant for server side operations, not for direct client access, for that as suggested in the documentation there is another API.

For more information read this:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi! Define the namespace in Spotify.php:

<?php namespace Foo\Bar\Baz;

class Spotify
{
    public function __construct()
    {
        echo "yes"; 
    }
}

Then it should work fine.

diafol commented: Big hand. Thank you +15
cereal 1,524 Nearly a Senior Poster Featured Poster

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables

It happens because of:

$sql->bind_param('ss', $uname);

Since you're binding only one variable, which is string, you have to pass only one s:

$sql->bind_param('s', $uname);

s stands for string, if the value is an integer then it would be i, f for floats and b for blobs.

cereal 1,524 Nearly a Senior Poster Featured Poster

The real_escape_string method is part of mysqli, so to use it append it to the database object: $conn->real_escape_string($uname).

But don't rely on this for security you have to validate the input, then sanitize and use prepared statements:

$uname = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_SPECIAL_CHARS);
$pword = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_SPECIAL_CHARS);

$query = $mysqli->prepare("SELECT * FROM users WHERE name = ? AND email = ?");
$query->bind_param('ss', $uname, $pword);

$query->execute();
$query->store_result();

if($query->num_rows > 0)
{
    # create session for valid user & redirect to profile
}

else
{
    # error, not found
}

Docs about sanitization of the input:

Docs about prepared statements:

cereal 1,524 Nearly a Senior Poster Featured Poster

Cannot find column [year]

Does the column year exists it the queried tables? Have you tried to perform the same queries directly in a MySQL client?

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use a view, for example:

CREATE VIEW test_view AS SELECT fruit FROM t1 WHERE id IN(1,2) UNION SELECT fruit FROM t1 WHERE fruit = 'cherries';

Or you can use a temporary table:

CREATE TEMPORARY TABLE IF NOT EXISTS test_memory ENGINE = memory AS SELECT fruit FROM t1 WHERE id IN(1,2) UNION SELECT fruit FROM t1 WHERE fruit = 'cherries';

In the first case the union is performed each time you run the query, in the second the temporary table will survive until you close the session, so by querying:

select * from test_memory;

you will always get the cached data, nothing new unless you decide to insert new data over a new select. By removing the statement TEMPORARY the table structure will survive and the data will become accessible also to other connections, but if the engine remains memory it will loose the data when performing a reboot of the server.

To see the differences between test_view and test_memory use explain over the queries:

explain select * from test_view;
explain select * from test_memory;

Another method is to enclose the union in a subquery and perform the where statement in the primary query, for example:

SELECT sub.id, sub.fruit FROM (SELECT * FROM t1 WHERE id IN(1,2) UNION SELECT * FROM t1 WHERE fruit = 'coconut') AS sub WHERE sub.id = 5;

The execution plan of this last query is pratically the same of the one produced by the …

cereal 1,524 Nearly a Senior Poster Featured Poster

Mysqli num_rows returns integers not booleans (true|false) so if you want to check how many rows you're returning change the if statement to:

if($result->num_rows > 0){

But, if the query fails for an error this statement will not prevent a PHP notice:

PHP Notice:  Trying to get property of non-object ...

It happens because $result will be false, so a more complete check is to verify if $result is not false:

if($result && $result->num_rows > 0){

Note that mysqli_query on success can return an object or simply boolean true, the documentation explains the cases:

Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE.

So for SELECT queries you can almost always rely on num_rows but if you perform an INSERT, DELETE or UPDATE then you cannot use num_rows, this for example:

$result = $mysqli->query("create temporary table mytest engine = memory as select 1+1 as 'sum' from dual");

Is a perfect valid query, it's the equivalent of an INSERT ... SELECT, and it will create a temporary table, but it will not return an object, it will return only boolean, so this check:

if($result && $result->num_rows > 0)

Will fail generating the same PHP notice as above, in this case use only:

if($result)

Edit: adding info
I forgot to add an exception: a select query can return only boolean true if you use …

cereal 1,524 Nearly a Senior Poster Featured Poster

Applying this code at each page load is not really efficient, it can be useful to create static html files to use as cache but not for live content.

cereal 1,524 Nearly a Senior Poster Featured Poster

It depends on what you want to do, you could remove the container and add it again, just place another node to define in which area of the page you want to add the new empty container, in this case the html page will be:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
</head>
<body>

    <div id="container"></div>
    <div id="marker"></div>

</body>
</html>

The new script is this:

<?php

$file = "./test.html";
$imgs = glob('../images/*.jpg');

$dom = new DOMDocument();
$dom->preserveWhiteSpace = true;
$dom->formatOutput = true;
$dom->loadHTMLFile($file);

$container = $dom->getElementByID("container");

if($container != null && $container->hasChildNodes())
{
    # remove the container
    $parent = $container->parentNode;
    $parent->removeChild($container);

    # create new container
    $container = $dom->createElement("div");
    $container->setAttribute("id", "container");

    # insert the new container before a specific node
    $marker = $dom->getElementByID("marker");
    $parent->insertBefore($container, $marker);
}

if(count($imgs) == 0 || $imgs === false)
    die('Error: glob is failing.');

# populate the new container
foreach($imgs as $img)
{
    $basename = pathinfo($img, PATHINFO_BASENAME);
    $tag = $dom->createElement("img");
    $tag->setAttribute('src', '/images/'.$basename);
    $container->appendChild($tag);

    # appending new lines and tabs
    $br = $dom->createTextNode("\n\t");
    $container->appendChild($br);

    $tag = null;
    $br  = null;
}

$dom->saveHTMLFile($file);

This is the easy method, but if you want, you can compare each child node values with the glob array to perform only specific operations, for this check:

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

It seems fine, the only problem I can see is related to the space between the include and the string:

include"conn.php";

It should be:

include "conn.php";

But at query level use $result->error:

if($result){
    echo "welcome to new page";
}

else{
    echo $result->error;
}

It will display the error related to the query, if any.

cereal 1,524 Nearly a Senior Poster Featured Poster

login1 is the database name or the table name, or both?

Instead of:

if(!$conn){
    echo "Connection not established";
}

Do:

if ($conn->connect_errno) {
    printf("Connect failed: %s\n", $conn->connect_error);
    exit();
}

As suggested in the documentation. And return the error here.

cereal 1,524 Nearly a Senior Poster Featured Poster

The meta tag is added automatically, just specify your own flavour to avoid a change of charset, for example:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Test</title>
</head>
<body>

    <div id="container"></div>

</body>
</html>

The fact that the tags are not added to the container means that glob() return an empty array or false. Before the loop you can add this check:

if(count($imgs) == 0 || $imgs === false)
    die('Error: glob is failing.');

Complete example:

<?php

$file = "./test.html";
$imgs = glob('../images/*.jpg');

$dom = new DOMDocument();
$dom->loadHTMLFile($file);
$container = $dom->getElementByID("container");

if(count($imgs) == 0 || $imgs === false)
    die('Error: glob is failing.');

foreach($imgs as $img)
{
    $basename = pathinfo($img, PATHINFO_BASENAME);
    $tag = $dom->createElement("img");
    $tag->setAttribute('src', '/images/'.$basename);
    $container->appendChild($tag);

    $tag = null;
}

$dom->saveHTMLFile($file);
cereal 1,524 Nearly a Senior Poster Featured Poster

You could use the DOMDocument class:

An example:

<?php

$file = "./test.html";
$imgs = glob('../images/*.jpg');

$dom = new DOMDocument();
$dom->loadHTMLFile($file);
$container = $dom->getElementByID("container");

foreach($imgs as $img)
{
    $basename = pathinfo($img, PATHINFO_BASENAME);
    $tag = $dom->createElement("img");
    $tag->setAttribute('src', '/images/'.$basename);
    $container->appendChild($tag);

    $tag = null;
}

$dom->saveHTMLFile($file);

By using the method getElementByID() you can define a container in your HTML in which append each new element, so the base for test.html of the above example is:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
</head>
<body>

    <div id="container"></div>

</body>
</html>

Note: the doctype is important, otherwise it will add HTML 4.0.

cereal 1,524 Nearly a Senior Poster Featured Poster

What you don't understand?

cereal 1,524 Nearly a Senior Poster Featured Poster

In order to perform multiple updates you have to submit the fields of the form as array groups, for example:

<form action="" method="post">
<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Size</th>
            <th>Qty</th>
            <th>Price</th>
        </tr>

    <tbody>
        <tr>
            <!-- group 0 -->
            <td><input type="text" readonly name="product[0][id]" value="23" /></td>
            <td><input type="text" name="product[0][name]" /></td>
            <td><input type="text" name="product[0][size]" /></td>
            <td><input type="text" name="product[0][qty]" /></td>
            <td><input type="text" name="product[0][price]" /></td>
        </tr>
        <tr>
            <!-- group 1 -->
            <td><input type="text" readonly name="product[1][id]" value="72" /></td>
            <td><input type="text" name="product[1][name]" /></td>
            <td><input type="text" name="product[1][size]" /></td>
            <td><input type="text" name="product[1][qty]" /></td>
            <td><input type="text" name="product[1][price]" /></td>
        </tr>
</table>

    <input type="submit" name="button" value="update" />
</form>

When you print the $_POST array you get:

Array
(
    [product] => Array
        (
            [0] => Array
                (
                    [id] => 23
                    [name] => Apples
                    [size] => 1
                    [qty] => 10
                    [price] => 6
                )

            [1] => Array
                (
                    [id] => 72
                    [name] => Oranges
                    [size] => 2
                    [qty] => 17
                    [price] => 8.90
                )

        )

    [button] => update
)

At this point you can loop $_POST['product'] to update each product separatedly:

foreach($_POST['product'] as $product)
{
    echo $product['id'] . $product['name'] . '... and so on';
}

Best would be to use prepared statements so you can create the update query and then just loop the execution with the parameters.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ron, if you are performing an ajax request within the modal window then show us the javascript code you're using, that way we can suggest an appropriate solution.

But diafol suggested that the error is already there, it does not depend on the execution of the modal window, because the undefined index error happens in the server side.

This error should say something else, not only undefined index but also the index name, the script name and line error, for example:

<?php

    $a = array();
    echo $a['id'];

Will generate a notice:

PHP Notice:  Undefined index: id in /tmp/test.php on line 4

By checking the html source received by the browser you should be able to see the entire error and understand if this is generated by the absence of $_GET['id'] or of a column requested from the query result set.

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you post the exact error? Undefined index regarding which array: $_GET, $_POST, $row?

cereal 1,524 Nearly a Senior Poster Featured Poster

I don't understand: you're talking about the data you want to save into the custreg table? If yes, where are the form, the insert query and the table definition?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi Dani, this is used in Windows 8.1 with IE 11 to add tiles to the desktop:

cereal 1,524 Nearly a Senior Poster Featured Poster

It happens! Just for the log, the value for pdo_mysql.default_socket must be a valid path to the socket file as in these examples:

So this pdo_mysql.default_socket="MySQL" is not correct. The path, by the way, can be defined even in the connection string:

$dbh = new PDO("mysql:dbname=testdb;unix_socket=/path/to/mysqld.sock", "user", "pwd");

Which can be useful when using multiple instances of MySQL in the same box. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Try also:

<?php

    $input    = "ls -lh";
    $command  = escapeshellcmd($input);
    $command .= '^M';

    shell_exec("screen -X stuff '$command'");

If the "stuff" screen is attached you should see the execution of the command.

But keep in mind this is really unsafe action, depending on configuration it can run with webserver privileges. It should be better to perform a regular expression to match the input with a precompiled list of allowed commands and parse the supported arguments for each command, through an array... A good library for this can be Console from Symfony framework:

cereal 1,524 Nearly a Senior Poster Featured Poster

Check if the MySQL daemon is up and if the path to the socket is correct: this is defined in the configuration file of MySQL, i.e. /etc/mysql/my.cnf, in distro-specific configuration files, like /etc/mysql/debian.cnf, and in the PHP configuration file through pdo_mysql.default_socket=.

Cascading rule is applied: the PHP configuration overrides debian.cnf which overrides my.cnf.

The socket file is used to connect to the local server without passing from the TCP protocol, but you can force it by changing the host to the local IP address:

$pdo = new PDO("mysql:dbname=database;host=127.0.0.1", "username", "password");

Test:

<?php

    try {
        $pdo = new PDO("mysql:dbname=test;host=127.0.0.1", "user", "pwd");
        echo $pdo->getAttribute(PDO::ATTR_CONNECTION_STATUS);
    }

    catch (PDOException $e) {
        echo 'Connection failed: ' . $e->getMessage();
    }

Should return: 127.0.0.1 via TCP/IP.

cereal 1,524 Nearly a Senior Poster Featured Poster

From require documentation:

require is identical to include except upon failure it will also produce a fatal E_COMPILE_ERROR level error. In other words, it will halt the script whereas include only emits a warning (E_WARNING) which allows the script to continue.

Links:

Please, next time write a more appropriate title, it will help users to find their answers.

diafol commented: agreed about the title +15
cereal 1,524 Nearly a Senior Poster Featured Poster

With .reload(), when possible, you can try to force the reload from the browser cache:

Reloads the resource from the current URL. Its optional unique parameter is a Boolean, which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache.

For more information check here:

Also .reload() is not part of JQuery, it's a method of the Location interface: