[PHP-DB] Re: Remote ODBC Connection to IBMi Db2/iAccess Very Slow to Fetch Results

2024-03-20 Thread Zachary Menzies
Hello again,

It looks like the most recent PHP version (8.3.4) fixed this slow result 
fetching problem,
so long as the SQL_CUR_USE_ODBC option is passed to the odbc_connect() function.

I was going to post a bug report, when I tested it one last time, and 
lo-and-behold,
the fetching performance is back to normal.

So problem solved. Thank you, PHP developers.

Zachary

From: Zachary Menzies 
Sent: March 12, 2024 9:54 AM
To: php-db@lists.php.net 
Subject: Re: Remote ODBC Connection to IBMi Db2/iAccess Very Slow to Fetch 
Results

I found the options for "odbc.default_cursortype" here: 
https://www.php.net/manual/en/odbc.configuration.php (not sure why I didn't see 
it before). However, none of the options (0 to 3) made any difference.

Zachary

From: Zachary Menzies 
Sent: March 12, 2024 8:36 AM
To: php-db@lists.php.net 
Subject: [PHP-DB] Remote ODBC Connection to IBMi Db2/iAccess Very Slow to Fetch 
Results

Hello,

At work, we have an IBM Db2 database. Until recently, it lived within our local 
network,
but has since been moved off-site (to the cloud). We connect to it using an 
iSeries Access
ODBC driver. For communication, I typically use PHP's ODBC interface (sometimes 
other
languages).

When the database was local, everything seemed to run smoothly; but now that it 
is off-site,
fetching results from SELECT queries is very slow (12 seconds for 100 rows). I 
thought at first
it was an issue on our host's side (or even our network), but all tests 
indicated otherwise. A
proof of this is that I made a C program to run the same query (using the same 
driver), and it
fetched the results within milliseconds after the query completed.

I should perhaps point out that running the queries is fast, it's only fetching 
the result rows
that is slow.

The only comments I could find that mentioned a similar issue was for people 
that were using
a Db2 driver: if they passed the "SQL_CUR_USE_ODBC" option to the 
"odbc_connect" function,
then their result collection was sped up. I tried that, but it made no 
difference (perhaps because
I'm not using a Db2 driver, per se, but an iAccess driver).

I'm not so sure that this is an error with PHP so much as a setting that needs 
to be tweaked;
but I can't seem to find what setting that might be. I can see there is a 
default_cursortype option
in the php.ini file, but I don't know what options are available or how to 
properly set the value.

I also tried using PDO and ADOdb, but both resulted in the same slowness (I'm 
guessing because
they just wrap the ODBC interface).

So, as I my first choice is not to re-write a bunch of scripts into C, I was 
wondering if any of you might
know (or have ideas as to) what the issue might be.

The PHP versions I have been using are 8.3.2 and 8.3.3, and I've tried the test 
on both Windows and
Linux.

Thanks,

Zachary


Re: spam>[PHP-DB] Remove

2024-03-12 Thread Zachary Menzies
Yes, just send an e-mail to "php-db+unsubscr...@lists.php.net"
I imagine it will ask for confirmation.

From: Kevin McColl 
Sent: March 12, 2024 10:53 AM
To: php-db@lists.php.net 
Subject: spam>[PHP-DB] Remove

Is there a way to stop or remove receiving these emails?


[PHP-DB] Remove

2024-03-12 Thread Kevin McColl
Is there a way to stop or remove receiving these emails?


[PHP-DB] Re: Remote ODBC Connection to IBMi Db2/iAccess Very Slow to Fetch Results

2024-03-12 Thread Zachary Menzies
I found the options for "odbc.default_cursortype" here: 
https://www.php.net/manual/en/odbc.configuration.php (not sure why I didn't see 
it before). However, none of the options (0 to 3) made any difference.

Zachary

From: Zachary Menzies 
Sent: March 12, 2024 8:36 AM
To: php-db@lists.php.net 
Subject: [PHP-DB] Remote ODBC Connection to IBMi Db2/iAccess Very Slow to Fetch 
Results

Hello,

At work, we have an IBM Db2 database. Until recently, it lived within our local 
network,
but has since been moved off-site (to the cloud). We connect to it using an 
iSeries Access
ODBC driver. For communication, I typically use PHP's ODBC interface (sometimes 
other
languages).

When the database was local, everything seemed to run smoothly; but now that it 
is off-site,
fetching results from SELECT queries is very slow (12 seconds for 100 rows). I 
thought at first
it was an issue on our host's side (or even our network), but all tests 
indicated otherwise. A
proof of this is that I made a C program to run the same query (using the same 
driver), and it
fetched the results within milliseconds after the query completed.

I should perhaps point out that running the queries is fast, it's only fetching 
the result rows
that is slow.

The only comments I could find that mentioned a similar issue was for people 
that were using
a Db2 driver: if they passed the "SQL_CUR_USE_ODBC" option to the 
"odbc_connect" function,
then their result collection was sped up. I tried that, but it made no 
difference (perhaps because
I'm not using a Db2 driver, per se, but an iAccess driver).

I'm not so sure that this is an error with PHP so much as a setting that needs 
to be tweaked;
but I can't seem to find what setting that might be. I can see there is a 
default_cursortype option
in the php.ini file, but I don't know what options are available or how to 
properly set the value.

I also tried using PDO and ADOdb, but both resulted in the same slowness (I'm 
guessing because
they just wrap the ODBC interface).

So, as I my first choice is not to re-write a bunch of scripts into C, I was 
wondering if any of you might
know (or have ideas as to) what the issue might be.

The PHP versions I have been using are 8.3.2 and 8.3.3, and I've tried the test 
on both Windows and
Linux.

Thanks,

Zachary


[PHP-DB] Remote ODBC Connection to IBMi Db2/iAccess Very Slow to Fetch Results

2024-03-12 Thread Zachary Menzies
Hello,

At work, we have an IBM Db2 database. Until recently, it lived within our local 
network,
but has since been moved off-site (to the cloud). We connect to it using an 
iSeries Access
ODBC driver. For communication, I typically use PHP's ODBC interface (sometimes 
other
languages).

When the database was local, everything seemed to run smoothly; but now that it 
is off-site,
fetching results from SELECT queries is very slow (12 seconds for 100 rows). I 
thought at first
it was an issue on our host's side (or even our network), but all tests 
indicated otherwise. A
proof of this is that I made a C program to run the same query (using the same 
driver), and it
fetched the results within milliseconds after the query completed.

I should perhaps point out that running the queries is fast, it's only fetching 
the result rows
that is slow.

The only comments I could find that mentioned a similar issue was for people 
that were using
a Db2 driver: if they passed the "SQL_CUR_USE_ODBC" option to the 
"odbc_connect" function,
then their result collection was sped up. I tried that, but it made no 
difference (perhaps because
I'm not using a Db2 driver, per se, but an iAccess driver).

I'm not so sure that this is an error with PHP so much as a setting that needs 
to be tweaked;
but I can't seem to find what setting that might be. I can see there is a 
default_cursortype option
in the php.ini file, but I don't know what options are available or how to 
properly set the value.

I also tried using PDO and ADOdb, but both resulted in the same slowness (I'm 
guessing because
they just wrap the ODBC interface).

So, as I my first choice is not to re-write a bunch of scripts into C, I was 
wondering if any of you might
know (or have ideas as to) what the issue might be.

The PHP versions I have been using are 8.3.2 and 8.3.3, and I've tried the test 
on both Windows and
Linux.

Thanks,

Zachary


[PHP-DB] Requesting a feature change to PHP mysqli

2024-01-27 Thread John Wythe
Hi

How should I go about requesting a feature change to mysqli.php.

When using mysql_real_connect with SSL and certificates.

The underlying libraries have the ability to disable certificate verification, 
peer name verification, and pass in a peer name to use in the verification.

Currently only the disable certificate verification is exposed, and it disables 
both certificate verification and peer name verification, and there is no way 
to pass in the peer name to use.
In C this can be done, but not PHP.

My request would be to expose the full functionality of the C libraries, by 
exposing the above parameters separately in mysqli PHP.

John Wythe
Software & Systems Engineer
Epicor Software Corporation
www.epicor.com
Ph: 250-260-6495
TF Support: 800-678-7423
E-Mail: jwy...@epicor.com
Support E-Mail: silksupp...@epicor.com
Support portal: https://epicorcs.service-now.com/epiccare/



Re: [PHP-DB] use php variable within postgresql query

2023-06-12 Thread Karl DeSaulniers
Oh I see now I am late to the conversation. Slow email load. Carry on.

> On Jun 12, 2023, at 1:42 PM, Karl DeSaulniers  wrote:
> 
> Hi,
> I am assuming this is just a typo in your post and not your code, correct? 
> (see quoted text below)
> If not, then try the other bracket?
> 
> $query=$_GET['databasecolumn'];
> 
> 
>> On Jun 9, 2023, at 4:05 AM, e-letter  wrote:
>> 
>> $query=$_GET['databasecolumn'[;
> 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] use php variable within postgresql query

2023-06-12 Thread Karl DeSaulniers
Hi,
I am assuming this is just a typo in your post and not your code, correct? (see 
quoted text below)
If not, then try the other bracket?

$query=$_GET['databasecolumn'];


> On Jun 9, 2023, at 4:05 AM, e-letter  wrote:
> 
> $query=$_GET['databasecolumn'[;



[PHP-DB] Re: use php variable within postgresql query

2023-06-12 Thread e-letter
Yes, aware but one step at a time, slowly(!)

As a non-programmer, want to test ability to comprehend the concepts
first, before security implementations.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] use php variable within postgresql query

2023-06-12 Thread Michael Oki
Meanwhile, you should probably use prepared statements to avoid SQL
injection.

On Mon, 12 Jun 2023 at 16:03, e-letter  wrote:

> First, sorry for the mistake to type a sanitised version of code.
> Should have been:
> "$query=$_GET['databasecolumn'];"
>
> After some rtfm, confused as a non-computer-programmer why it is
> necessary to set the $_GET parameter.
>
> The overall simple scenario is to view a postgresql database in a
> series of html web pages of more details of data ("drill down"?).
>
> php code within html file 1:
> "
> $databasequery=pg_query($databaseconnection,'SELECT
> databasecolumn1,
> databasecolumn2 FROM databasetable');
> if (!$databasequery) {
> echo 'rubbish code';
> exit;
> }
> while
> ($databasequery1=pg_fetch_assoc($databasequery)) {
> echo '
>  href="localfile.php?databasecolumn1='.$databasequery1['databasecolumn1'].'">'.$databasequery1['databasecolumn1'].'';
> echo ' '
> .$databasequery1['databasecolumn2'].'';
> ';
> }
> "
>
> The first html file shows successfully the a list of hyperlinks from
> the database, for tuples in 'databasecolumn1'. The desired behaviour
> is that the second html file shows another database query result for
> each tuple in the first html file, i.e. more detail from the database
> for each tuple in 'databasecolumn1'.
>
>
> php code within html file 2:
> "
> $databasequery2=pg_query($databasequery1);
> $databasequery3=pg_query("SELECT * FROM databasetable WHERE
> databasecolumn1='{$databasequery2['databasecolumn']}'");
> echo $databasequery3
> "
>
> The html file 2 shows:
> "
> resource id#3
> "
>
> The expected result was to show all columns for the row constraint
> (...WHERE ...)
>
> It seems that the use of a php variable within a postgresql query is
> not understood. What relevant terminology to read next please?
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
*Thanks In Advance,*

*Michael OKI*

*CBSA*
*Technologist*
*+34663549276*
*"Impossible Is Nothing"*

*Scan and share QR codes on the mycodescanner
app*


BTA Certified Blockchain Solution Architect & IEEE member
https://michaeloki.blogspot.com


Re: [PHP-DB] use php variable within postgresql query

2023-06-12 Thread e-letter
First, sorry for the mistake to type a sanitised version of code.
Should have been:
"$query=$_GET['databasecolumn'];"

After some rtfm, confused as a non-computer-programmer why it is
necessary to set the $_GET parameter.

The overall simple scenario is to view a postgresql database in a
series of html web pages of more details of data ("drill down"?).

php code within html file 1:
"
$databasequery=pg_query($databaseconnection,'SELECT databasecolumn1,
databasecolumn2 FROM databasetable');
if (!$databasequery) {
echo 'rubbish code';
exit;
}
while ($databasequery1=pg_fetch_assoc($databasequery)) {
echo '
'.$databasequery1['databasecolumn1'].'';
echo ' ' 
.$databasequery1['databasecolumn2'].'';
';
}
"

The first html file shows successfully the a list of hyperlinks from
the database, for tuples in 'databasecolumn1'. The desired behaviour
is that the second html file shows another database query result for
each tuple in the first html file, i.e. more detail from the database
for each tuple in 'databasecolumn1'.


php code within html file 2:
"
$databasequery2=pg_query($databasequery1);
$databasequery3=pg_query("SELECT * FROM databasetable WHERE
databasecolumn1='{$databasequery2['databasecolumn']}'");
echo $databasequery3
"

The html file 2 shows:
"
resource id#3
"

The expected result was to show all columns for the row constraint
(...WHERE ...)

It seems that the use of a php variable within a postgresql query is
not understood. What relevant terminology to read next please?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] use php variable within postgresql query

2023-06-09 Thread Aziz Saleh
That was a bad copy/paste on his part. Syntax errors will not allow PHP to
even run the code.

On Fri, Jun 9, 2023 at 11:14 AM G. Franklin  wrote:

> My friends,
>
> Would not the syntax of "$query=$_GET['databasecolumn'[;" be part of the
> issue?
>
> I believe the brackets should be closed like this, no?
> "$query=$_GET['databasecolumn'];"
>
> ~G.
>
>
>
> On Fri, 9 Jun 2023 at 10:53, Aziz Saleh  wrote:
>
> > Read and understand these, should help you:
> >
> > https://www.php.net/manual/en/language.types.array.php
> >
> > Basically its databasecolumnname get param is not defined (set) causing
> the
> > query to fail also.
> >
> > On Fri, Jun 9, 2023 at 5:06 AM e-letter  wrote:
> >
> > > Readers,
> > >
> > > Suppose:
> > >
> > > $query=$_GET['databasecolumn'[;
> > >
> > > $anotherquery=pg_query($databaseconnection, 'SELECT * FROM
> > > databasename WHERE databasecolumnname="'.$query.';"');
> > >
> > > Two errors are reported:
> > >
> > > PHP Notice:  Undefined index: databasecolumnname
> > >
> > > PHP Warning:  pg_query(): Query failed: ERROR:  column ";" does not
> exist
> > >
> > > Any advice please?
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>


Re: [PHP-DB] use php variable within postgresql query

2023-06-09 Thread G. Franklin
My friends,

Would not the syntax of "$query=$_GET['databasecolumn'[;" be part of the
issue?

I believe the brackets should be closed like this, no?
"$query=$_GET['databasecolumn'];"

~G.



On Fri, 9 Jun 2023 at 10:53, Aziz Saleh  wrote:

> Read and understand these, should help you:
>
> https://www.php.net/manual/en/language.types.array.php
>
> Basically its databasecolumnname get param is not defined (set) causing the
> query to fail also.
>
> On Fri, Jun 9, 2023 at 5:06 AM e-letter  wrote:
>
> > Readers,
> >
> > Suppose:
> >
> > $query=$_GET['databasecolumn'[;
> >
> > $anotherquery=pg_query($databaseconnection, 'SELECT * FROM
> > databasename WHERE databasecolumnname="'.$query.';"');
> >
> > Two errors are reported:
> >
> > PHP Notice:  Undefined index: databasecolumnname
> >
> > PHP Warning:  pg_query(): Query failed: ERROR:  column ";" does not exist
> >
> > Any advice please?
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>


Re: [PHP-DB] use php variable within postgresql query

2023-06-09 Thread Aziz Saleh
Read and understand these, should help you:

https://www.php.net/manual/en/language.types.array.php

Basically its databasecolumnname get param is not defined (set) causing the
query to fail also.

On Fri, Jun 9, 2023 at 5:06 AM e-letter  wrote:

> Readers,
>
> Suppose:
>
> $query=$_GET['databasecolumn'[;
>
> $anotherquery=pg_query($databaseconnection, 'SELECT * FROM
> databasename WHERE databasecolumnname="'.$query.';"');
>
> Two errors are reported:
>
> PHP Notice:  Undefined index: databasecolumnname
>
> PHP Warning:  pg_query(): Query failed: ERROR:  column ";" does not exist
>
> Any advice please?
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP-DB] use php variable within postgresql query

2023-06-09 Thread e-letter
Readers,

Suppose:

$query=$_GET['databasecolumn'[;

$anotherquery=pg_query($databaseconnection, 'SELECT * FROM
databasename WHERE databasecolumnname="'.$query.';"');

Two errors are reported:

PHP Notice:  Undefined index: databasecolumnname

PHP Warning:  pg_query(): Query failed: ERROR:  column ";" does not exist

Any advice please?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Imap-Connection fails, how do I have to define imap_open

2023-05-22 Thread Ruprecht Helms (privat)

Hi,

I want to connect within a php-Script to my Imapserver at all-inkl.

In my Thunderbird the account-settings are:

Server: w017fd8a.kasserver.com
Port: 993
Connecting-Way: SSL/TLS
Authication-Method: normal Password

this settings are function in the Thunderbird-Client.
But in the testing-scipt for Imap-Access I get an error that the access 
to the
All-inkl server fails. Does anyone have experience how I have to the 
fine the line

in imap_open?



$mbox=imap_open("{w017fd8a.kasserver.com:993/imap/ssl/novalidate-cert}", 
"" ,"");





if(!$mbox)
{
    echo "Imap-Zugriff gescheitert"; <-- In Englisch "Imap-Access 
fails"

}
//$mbox="INBOX.msf"

echo "Postfächer";   <-- In English Mailboxes

$folders=imap_listmailbox($mbox,"{w017fd8a.kasserver.com:993/imap/ssl/novalidate-cert}","*"); 


...
imap_close($mbox);
?>

Regards,
Ruprecht

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] PDO::quote is only *theoretically* safe ?

2023-03-24 Thread Tobias Petry
The documentation for PDO::quote [0] says that a processed string is 
"theoretically safe to pass into an SQL statement". Understandably, prepared 
statements should be preferred when possible. But I need to change some stuff 
where integrating them is impossible, and some values must be securely embedded 
into a query string.

There's only one stated problem of PDO::quote that could result in a SQL 
injection: When the charset has not been set for the connection. But as warned 
by the documentation, this will be guaranteed.

Neither mysql_real_escape_string [1] nor pg_escape_literal [2] which escape 
values for embedding into SQL query strings have a note about being only 
*theoretically* safe. Only PDO::quote has such a warning.

* Is there any reason PDO::quote should be less safe than 
mysql_real_escape_string or pg_escape_literal for embedding values in SQL 
queries?
* Is it just written in a very security-centric way so anyone sticks to 
prepared statements?

Although e.g. Wordpress is not known for the cleanest code, 
mysql_real_escape_string has been used for years without any known problems.

[0] https://www.php.net/manual/en/pdo.quote.php
[1] https://www.php.net/manual/en/function.mysql-real-escape-string
[2] https://www.php.net/manual/en/function.pg-escape-literal.php


RE: [PHP-DB] what does the mysqli real connect MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT flag do? How to disable only CN validation?

2023-03-23 Thread John Wythe
Thanks, I already saw that from the documentation. I wanted to know what is 
validation in this context?  Complete verification of the cert, or only CN 
verification.
Looking at the source it appears this flag disables both, in the underlying 
php/openssl, plus does something with ALLOW_SELF_SIGNED.

My problem now is:

  1.  Modify the C source code for mysqli to allow setting only the underlying 
php/openssl VERIFY_NAME only
  2.  Find a way to call the underlying PHP code outside mysqli  using the 
return value from DB:connect, or the passed in $dsn.  The functions are 
accessible, but I need to pass a context, and I don’t think $dsn gives me 
access to the context.  It maybe too late in the sequence of events to change 
any of that.  I was thinking of doing a context get, and a context set, i

John Wythe
Software & Systems Engineer
Epicor Software Corporation
www.epicor.com<http://www.epicor.com/>
Ph: 250-260-6495
E-Mail: jwy...@epicor.com

From: Aziz Saleh 
Sent: Wednesday, March 22, 2023 7:36 PM
To: John Wythe 
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] what does the mysqli real connect 
MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT flag do? How to disable only CN 
validation?

ATTENTION
This email originated outside of Epicor. Please exercise caution when clicking 
links, opening attachments, or responding to this email.
That flag uses SSL encryption but disables validation of the provided SSL 
certificate. This is only for installations using MySQL Native Driver and MySQL 
5.6 or later.

On Wed, Mar 22, 2023 at 4:50 PM John Wythe 
mailto:jwy...@epicor.com>> wrote:
mysqli_real_connect has a parameter called flags than can be passed to it.  One 
of the flags in MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT.

What does this flag do?  Does it only disable the CN validation, or does it 
also disable the certificate validation against a CA authority.

SSL_CONEXT talks about options

peer_name
peer_verify
peer_verify_name

I would like to use these to at least disable only the verify_name part, or 
maybe even set the peer_name and have both validations turned on.

Seems this context function is only available for streams and not mysqli.

Openssl seems to have the ability to do this, however it does not appear to be 
exposed via mysqli.  I am guessing the flag above equates to peer verify and 
not peer_verify_name, or equates to both.

I suppose I could download the source for php_pmysqli, and have a look, would 
that be the correct package to look at?


John Wythe
Software & Systems Engineer
Epicor Software Corporation
www.epicor.com<http://www.epicor.com/>
Ph: 250-260-6495
TF Support: 800-678-7423
E-Mail: jwy...@epicor.com<mailto:jwy...@epicor.com>
Support E-Mail: silksupp...@epicor.com<mailto:silksupp...@epicor.com>
Support portal: https://epicorcs.service-now.com/epiccare/
<http://www.epicor.com/services/default.aspx>
 <http://www.epicor.com/services/default.aspx>


Re: [PHP-DB] what does the mysqli real connect MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT flag do? How to disable only CN validation?

2023-03-22 Thread Aziz Saleh
That flag uses SSL encryption but disables validation of the provided SSL
certificate. This is only for installations using MySQL Native Driver and
MySQL 5.6 or later.

On Wed, Mar 22, 2023 at 4:50 PM John Wythe  wrote:

> mysqli_real_connect has a parameter called flags than can be passed to
> it.  One of the flags in *MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT.*
>
>
>
> What does this flag do?  Does it only disable the CN validation, or does
> it also disable the certificate validation against a CA authority.
>
>
>
> SSL_CONEXT talks about options
>
>
>
> peer_name
>
> peer_verify
>
> peer_verify_name
>
>
>
> I would like to use these to at least disable only the verify_name part,
> or maybe even set the peer_name and have both validations turned on.
>
>
>
> Seems this context function is only available for streams and not mysqli.
>
>
>
> Openssl seems to have the ability to do this, however it does not appear
> to be exposed via mysqli.  I am guessing the flag above equates to peer
> verify and not peer_verify_name, or equates to both.
>
>
>
> I suppose I could download the source for php_pmysqli, and have a look,
> would that be the correct package to look at?
>
>
>
>
>
> John Wythe
> Software & Systems Engineer
> Epicor Software Corporation
> www.epicor.com
>
> Ph: 250-260-6495
> TF Support: 800-678-7423
> E-Mail: jwy...@epicor.com
> Support E-Mail: *silksupp...@epicor.com *
>
> *Support portal:* *https://epicorcs.service-now.com/epiccare/
> *
>
> 
>
>
>


[PHP-DB] what does the mysqli real connect MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT flag do? How to disable only CN validation?

2023-03-22 Thread John Wythe
mysqli_real_connect has a parameter called flags than can be passed to it.  One 
of the flags in MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT.

What does this flag do?  Does it only disable the CN validation, or does it 
also disable the certificate validation against a CA authority.

SSL_CONEXT talks about options

peer_name
peer_verify
peer_verify_name

I would like to use these to at least disable only the verify_name part, or 
maybe even set the peer_name and have both validations turned on.

Seems this context function is only available for streams and not mysqli.

Openssl seems to have the ability to do this, however it does not appear to be 
exposed via mysqli.  I am guessing the flag above equates to peer verify and 
not peer_verify_name, or equates to both.

I suppose I could download the source for php_pmysqli, and have a look, would 
that be the correct package to look at?


John Wythe
Software & Systems Engineer
Epicor Software Corporation
www.epicor.com
Ph: 250-260-6495
TF Support: 800-678-7423
E-Mail: jwy...@epicor.com
Support E-Mail: silksupp...@epicor.com
Support portal: https://epicorcs.service-now.com/epiccare/
[cid:image001.jpg@01D95CC5.2F7DDA30]



[PHP-DB] Php mariadb unique field selection for index of query result.

2023-02-07 Thread cds1984.diagnostic.net.au via php-db
Hi,
Quick question.

I may be missing something but for years I've been processing the output of a 
query into a new array using the unique(normally primary key) field in the 
table as the index so I can pull data matches simply further into the script 
without another loop through all the returned data.

Is there an option I'm missing to assign a field as the output array index from 
a PHP based query?

Thanks,

--
Richard Scotford

[PHP-DB] Bolt and PDO Bolt support for CQL and graph databases

2023-01-25 Thread Michal Stefanak
Hi.
What is Bolt?
Bolt is specification made by Neo4j for communication with graph
databases and it runs over TCP socket which is uses for transfering
messages in binary. Currently this specification is used by Neo4j,
Memgraph and Amazon Neptune.
Documentation is available at: https://www.neo4j.com/docs/bolt/current/

Why adding Bolt?
Graph databases are becoming very popular even with PHP. I'm author of
Bolt php library https://github.com/neo4j-php/Bolt which is foundation
for the whole community and upon it are build another libraries.
I can see the impact. Also I have some information and dozens of
millions of people are going through my driver. I believe this
protocol should have place next to others as php extension.

How to make it possible?
There is no official C driver by Neo4j but Memgraph company has its
own as opensource. It's the best shot to start
https://github.com/memgraph/mgclient
Unfortunately I'm not a C developer. I can learn C but it will take
time and probably not the required quality.
I have made an experiment with pdo-bolt php library
https://github.com/stefanak-michal/pdo-bolt and it can provide some
insight about how it is possible.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] A pdo extension for TDengine database

2022-01-13 Thread 张 振强
Hi,
I use Swoole for IoT projects at work. I recently discovered an efficient IoT 
database TDengine, but found that there is no PHP extension. So based on the 
official C language document and the client source code, I  develop the PDO 
extension, hoping to publish it on PECL, so that more people can use it to 
solve the storage and analysis problem of IoT device logs.


URL: https://github.com/bearlord/pdo_taos


[PHP-DB] Re: [External] : [PHP-DB] PDO to Oracle db and secure external password store aka wallet for authentication

2021-09-28 Thread Christopher Jones



On 28/9/21 6:59 pm, Mathias Zarick wrote:

Hi there,

I am wondering how it would be possible to use authentication using a secure 
external password store aka wallet with PDO OCI.

See Oracle external authentication and OCI_CRED_EXT in the underground php 
oracle manual.

and

https://docs.oracle.com/en/database/oracle/oracle-database/19/dbseg/configuring-authentication.html#GUID-803496D2-19C7-4F02-94EC-C13EDD8FB17B
(jump to chapter 3.2.9)


Following works fine with oci8:
$conn = oci_connect('/', '', $db, 'UTF8',OCI_CRED_EXT);

note the OCI_CRED_EXT!

But how can pass that option to a PDO OCI connection?
Following might be close, but does not work:

   $opt = [
   PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
   PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_NUM,
   'session_mode' => OCI_CRED_EXT,

];

   try{
   $conn = new PDO("oci:dbname=".$db.';charset=UTF8', "/","", $opt);
   }
   catch(PDOException $e){
   echo ($e->getMessage());
   }

Is it possible at all?


You can see in the PDO_OCI source code there is no reference to the OCI_CRED_EXT constant which is needed to tell the Oracle client libraries to use 
external authentication.


PR's are welcome.

For the moment stick with OCI8.  In general, native drivers (e.g OCI8) will be 
better than any of the PDO abstractions.

Chris




Thanks in Advance
Mathias Zarick


--
https://twitter.com/ghrd

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] PDO to Oracle db and secure external password store aka wallet for authentication

2021-09-28 Thread Mathias Zarick
Hi there,

I am wondering how it would be possible to use authentication using a secure 
external password store aka wallet with PDO OCI.

See Oracle external authentication and OCI_CRED_EXT in the underground php 
oracle manual.

and

https://docs.oracle.com/en/database/oracle/oracle-database/19/dbseg/configuring-authentication.html#GUID-803496D2-19C7-4F02-94EC-C13EDD8FB17B
(jump to chapter 3.2.9)


Following works fine with oci8:
$conn = oci_connect('/', '', $db, 'UTF8',OCI_CRED_EXT);

note the OCI_CRED_EXT!

But how can pass that option to a PDO OCI connection?
Following might be close, but does not work:

  $opt = [
  PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_NUM,
  'session_mode' => OCI_CRED_EXT,

];

  try{
  $conn = new PDO("oci:dbname=".$db.';charset=UTF8', "/","", $opt);
  }
  catch(PDOException $e){
  echo ($e->getMessage());
  }

Is it possible at all?

Thanks in Advance
Mathias Zarick


Re: [PHP-DB] MySQLnd support for ed25519

2021-09-08 Thread dimi_php
Hi Ruprecht,

yes, if a provider not changed the default authentication 
(mysql_nativ_password) there is
nothing customers have to do, because the default authentication on mysql 5.7 
and 10.5 is
the same (SHA-1 based).
Mysql changed this starting from version 8, were the default authentication now 
is the plugin caching_sha2_password.
Mariadb not changed the default, but recommends to use a safer authentication 
method like the ed25519-plugin.

I would like to use it, but then i have the problem that PHP (the Mysql nativ 
driver) cames with an
error like "The server requested authentication method unknown to the client".

So i would be glad if this authentication method would be implemented.

Regards,
Dimi

RE: [PHP-DB] MySQLnd support for ed25519

2021-09-08 Thread Jonathan Aquilina via php-db
Mysql 8 is already the stable version and has been for a while. I for 
development use it on windows and its v8



-Original Message-
From: Ruprecht Helms  
Sent: 08 September 2021 16:02
To: php-db@lists.php.net
Subject: Re: [PHP-DB] MySQLnd support for ed25519

Hi Dimi,

I think mysql 8 is the new version of mysql. I don't know if there a exists a 
stable release or only a beta.
My thoughts are that the last php-version maybe can handle the mentioned 
authentication method or you have to try to compile the handling for the 
mysql-plugin in the php-mysqldriver.

Maybe the question about enhancing the php is relation on the 
Linuxdistribution.  Here I mean an additional rpm if you use Redhat, Fedora, 
Centos, Suse...
or .deb if you use Debian, Ubuntu or such of these.

To mix a tarball with one of these packages I think it is to difficult in this 
case.

Regards,
Ruprecht

Am 08.09.21 um 15:20 schrieb dimi_php:
> Hi Ruprecht,
>
> yes, if a provider not changed the default authentication 
> (mysql_nativ_password) there is nothing customers have to do, because 
> the default authentication on mysql 5.7 and 10.5 is the same (SHA-1 based).
> Mysql changed this starting from version 8, were the default authentication 
> now is the plugin caching_sha2_password.
> Mariadb not changed the default, but recommends to use a safer authentication 
> method like the ed25519-plugin.
>
> I would like to use it, but then i have the problem that PHP (the 
> Mysql nativ driver) cames with an error like "The server requested 
> authentication method unknown to the client".
>
> So i would be glad if this authentication method would be implemented.
>
> Regards,
> Dimi

--
PHP Database Mailing List 
(https://link.edgepilot.com/s/bc6bf762/v5jGKG7Xd0e-fT3zNkB0xg?u=http://www.php.net/)
To unsubscribe, visit: 
https://link.edgepilot.com/s/cb035ec6/Rl3bBHstt0_Aj5u5ZnK0vg?u=http://www.php.net/unsub.php



Re: [PHP-DB] MySQLnd support for ed25519

2021-09-08 Thread Ruprecht Helms

Hi Dimi,

I think mysql 8 is the new version of mysql. I don't know if there a 
exists a stable release or only a beta.
My thoughts are that the last php-version maybe can handle the mentioned 
authentication method or you have

to try to compile the handling for the mysql-plugin in the php-mysqldriver.

Maybe the question about enhancing the php is relation on the 
Linuxdistribution.  Here I mean an additional rpm if you use Redhat, 
Fedora, Centos, Suse...

or .deb if you use Debian, Ubuntu or such of these.

To mix a tarball with one of these packages I think it is to difficult 
in this case.


Regards,
Ruprecht

Am 08.09.21 um 15:20 schrieb dimi_php:

Hi Ruprecht,

yes, if a provider not changed the default authentication 
(mysql_nativ_password) there is
nothing customers have to do, because the default authentication on mysql 5.7 
and 10.5 is
the same (SHA-1 based).
Mysql changed this starting from version 8, were the default authentication now 
is the plugin caching_sha2_password.
Mariadb not changed the default, but recommends to use a safer authentication 
method like the ed25519-plugin.

I would like to use it, but then i have the problem that PHP (the Mysql nativ 
driver) cames with an
error like "The server requested authentication method unknown to the client".

So i would be glad if this authentication method would be implemented.

Regards,
Dimi


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] MySQLnd support for ed25519

2021-09-07 Thread dimi_php
Hi everyone,

i just wanted to ask if the authentication with ed25519 algorithm with the 
MySQLnd is maybe possible in the future?
I use mariadb which currently not support either the sha256_password or the 
caching_sha2_password,
therefore i have to use the standard mysql_native_password authentication, 
although i actually want to use
the ed25519 authentication-plugin in mariadb.

Best regards,

Dimi

Re: [PHP-DB] MySQLnd support for ed25519

2021-09-07 Thread Ruprecht Helms

Hi Dimi,
hi everyone,

I don't know about this algorithm. On one running server and on my local 
linuxbox there is Mysql running.
On another server the provider changed from mysql to mariadb. As reason 
for the change from mysql 5.7 to mariadb 10.5
the provider only told his customers that mariadb is an enlargement of 
the database and based on mysql. Nothing told about
better security or any more, only that the provider looked forward 
without problems in the changingprocess.


Regards,
Ruprecht

Am 07.09.21 um 17:04 schrieb dimi_php:

Hi everyone,

i just wanted to ask if the authentication with ed25519 algorithm with the 
MySQLnd is maybe possible in the future?
I use mariadb which currently not support either the sha256_password or the 
caching_sha2_password,
therefore i have to use the standard mysql_native_password authentication, 
although i actually want to use
the ed25519 authentication-plugin in mariadb.

Best regards,

Dimi


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] How to get mysqli to allow SQL-based User-Defined Variables as column aliases?

2021-06-10 Thread Philip Schlesinger
Hi all,

I’m able to get mysqli to set a user-defined variable and the use it later on 
either in a column value definition or a conditional, I.e. (semi-pseudocode 
since I’m not in front of my work computer)

First do mysqli $conn->query(‘Set @foo = “bar”;’);
…which will prepare the database session with the variable.

Then do a $stmt = $conn->stmt_init()

Then do a $stmt->prepare(‘Select @foo as “baz”;’);

Finally do a $stmt->execute();

That results in:

‘baz’
———
“bar”


_however_ if I want to use a SQL user-defined variable as a column alias, 
mysqli throws an error.  This does not work:

$conn->query(‘set @acolname = “aCol”;’);

$stmt = $conn->stmt_init()

$stmt->prepare(‘Select “data” as @acolname;’);

$stmt->execute();

If I ran the straight SQL in a SQL application, making the select statement a 
variable as well, and did a prepare and execute, it would work just fine

Mysqli however throws an error with the column alias being a SQL user-defined 
variable.

Help?

Get Outlook for iOS


Re: [PHP-DB] Realtime connection to postgres database

2020-11-09 Thread Karl DeSaulniers
Is this what you are looking for?

https://www.postgresql.org/docs/9.6/monitoring-stats.html 


or maybe this?

https://github.com/supabase/realtime 


Google Foo:  real-time connection to postgresql database (v9.6)

HTH,

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com 




> On Nov 9, 2020, at 11:41 PM, Rodrigo Sánchez  wrote:
> 
> connected to  postgresql
> database (v9.6)



[PHP-DB] Realtime connection to postgres database

2020-11-09 Thread Rodrigo Sánchez

Hi everyone,

  I have a table (html), that is connected to  postgresql
database (v9.6). I want that every time there is a change
in the database, the table changes immediately. I am talking
about a realtime connection between html table and postgres
database via php (v7.4).

(without having to refresh the web page by clicking on the browser)


Is there a way to do it ?


 Rodrigo Sánchez
 CSN, UCH

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Realtime connection to postgres database

2020-10-26 Thread Karl DeSaulniers
Sounds like a good cron job candidate. 

Best,
Karl

Sent from losPhone

> On Oct 25, 2020, at 4:43 PM, Aziz Saleh  wrote:
> 
> Another way to do this is to have an ajax call on timeout to an update
> endpoint, if there is an update inject that update on the page (or refresh
> it).
> 
> Some js examples (both short/long polling):
> 
> https://stackoverflow.com/questions/42825972/update-html-when-change-is-noticed-in-mysql-database
> https://stackoverflow.com/questions/22577457/update-data-on-a-page-without-refreshing
> https://stackoverflow.com/questions/8100594/refresh-content-automatically-if-the-database-changes
> 
> 
>> On Sun, Oct 25, 2020 at 5:18 PM Rodrigo Sánchez 
>> wrote:
>> 
>> Hi everyone,
>> 
>>  I made a table in html that reads a table from a postgres database
>> (easy part).  The postgres database grows every time an earthquake
>> occurs. What is the best way to keep the table updated automatically,
>> each time a new earthquake is added to the database? (I mean, not having
>> to update by clicking on the browser). The ugly way to do it is by using
>> something like header ("refresh: 3"); for example ... but isn't there
>> something better?
>> 
>>  Excuse the question if it is very obvious, but I am not a "full" time
>> php programmer.
>> 
>>  (PHP 7.4.11, postgresql 9.6.19)
>> 
>> 
>> --
>> 
>>  Rodrigo Sánchez-Olavarría
>>  CSN, Centro Sismologico Nacional
>>  Universidad de Chile
>>  Celular : +56 9 42137243
>> 
>> 
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Realtime connection to postgres database

2020-10-25 Thread Aziz Saleh
Another way to do this is to have an ajax call on timeout to an update
endpoint, if there is an update inject that update on the page (or refresh
it).

Some js examples (both short/long polling):

https://stackoverflow.com/questions/42825972/update-html-when-change-is-noticed-in-mysql-database
https://stackoverflow.com/questions/22577457/update-data-on-a-page-without-refreshing
https://stackoverflow.com/questions/8100594/refresh-content-automatically-if-the-database-changes


On Sun, Oct 25, 2020 at 5:18 PM Rodrigo Sánchez 
wrote:

> Hi everyone,
>
>   I made a table in html that reads a table from a postgres database
> (easy part).  The postgres database grows every time an earthquake
> occurs. What is the best way to keep the table updated automatically,
> each time a new earthquake is added to the database? (I mean, not having
> to update by clicking on the browser). The ugly way to do it is by using
> something like header ("refresh: 3"); for example ... but isn't there
> something better?
>
>   Excuse the question if it is very obvious, but I am not a "full" time
> php programmer.
>
>   (PHP 7.4.11, postgresql 9.6.19)
>
>
> --
> 
>   Rodrigo Sánchez-Olavarría
>   CSN, Centro Sismologico Nacional
>   Universidad de Chile
>   Celular : +56 9 42137243
> 
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP-DB] Realtime connection to postgres database

2020-10-25 Thread Rodrigo Sánchez

Hi everyone,

 I made a table in html that reads a table from a postgres database 
(easy part).  The postgres database grows every time an earthquake 
occurs. What is the best way to keep the table updated automatically, 
each time a new earthquake is added to the database? (I mean, not having 
to update by clicking on the browser). The ugly way to do it is by using 
something like header ("refresh: 3"); for example ... but isn't there 
something better?


 Excuse the question if it is very obvious, but I am not a "full" time 
php programmer.


 (PHP 7.4.11, postgresql 9.6.19)


--

 Rodrigo Sánchez-Olavarría
 CSN, Centro Sismologico Nacional
 Universidad de Chile
 Celular : +56 9 42137243


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Can connect to Mysql via command line but not via browser

2020-10-12 Thread Roberto Carlos Garcia Luis
Please try with this answer...

https://stackoverflow.com/questions/41178774/connect-database-error-type-2002-permission-denied


El jue., 3 sept. 2020 a las 17:23, Tai Larson ()
escribió:

> The are connected to the same network.  I’m setting up a development
> environment.
>
> From: Aziz Saleh 
> Sent: Thursday, September 3, 2020 3:09 PM
> To: Tai Larson 
> Cc: php-db@lists.php.net
> Subject: Re: [PHP-DB] Can connect to Mysql via command line but not via
> browser
>
> Are both connected to the same network? Just asking because I see a local
> ip for server ip/name. Maybe try with public IP instead see if it helps.
>
> On Thu, Sep 3, 2020 at 5:51 PM Tai Larson  tai.lar...@weierlaw.com>> wrote:
> I have a MySQL database server and a separate web sever running Apache.
> Both are running Centos 8.
>
> I can connect to my database server from my web server via the command
> line, but I get permission denied whenever I try to connect to the server
> via a browser.
>
> Here is the code I'm running:
>  $servername = "192.168.10.XXX";
> $username = "root";
> $password = "123456789";
> $conn = new mysqli($servername, $username, $password); if
> ($conn->connect_error) {
>   die("Connection failed: " . $conn->connect_error); } echo "Connected
> successfully"; ?>
>
> I SSH into my web server and run this command "php TestMySQL.php".  I
> receive the output of "Connected successfully".
>
> When I attempt through my browser or curl, I receive the output of
> "Connection failed: Permission denied".
>
> I can also connect to the remote database with the local mysql client.
>
> Thank you all in advance for your help.
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


RE: [PHP-DB] Can connect to Mysql via command line but not via browser

2020-09-03 Thread Tai Larson
The are connected to the same network.  I’m setting up a development 
environment.

From: Aziz Saleh 
Sent: Thursday, September 3, 2020 3:09 PM
To: Tai Larson 
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Can connect to Mysql via command line but not via browser

Are both connected to the same network? Just asking because I see a local ip 
for server ip/name. Maybe try with public IP instead see if it helps.

On Thu, Sep 3, 2020 at 5:51 PM Tai Larson 
mailto:tai.lar...@weierlaw.com>> wrote:
I have a MySQL database server and a separate web sever running Apache.  Both 
are running Centos 8.

I can connect to my database server from my web server via the command line, 
but I get permission denied whenever I try to connect to the server via a 
browser.

Here is the code I'm running:
connect_error) {
  die("Connection failed: " . $conn->connect_error); } echo "Connected 
successfully"; ?>

I SSH into my web server and run this command "php TestMySQL.php".  I receive 
the output of "Connected successfully".

When I attempt through my browser or curl, I receive the output of "Connection 
failed: Permission denied".

I can also connect to the remote database with the local mysql client.

Thank you all in advance for your help.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Can connect to Mysql via command line but not via browser

2020-09-03 Thread Aziz Saleh
Are both connected to the same network? Just asking because I see a local
ip for server ip/name. Maybe try with public IP instead see if it helps.

On Thu, Sep 3, 2020 at 5:51 PM Tai Larson  wrote:

> I have a MySQL database server and a separate web sever running Apache.
> Both are running Centos 8.
>
> I can connect to my database server from my web server via the command
> line, but I get permission denied whenever I try to connect to the server
> via a browser.
>
> Here is the code I'm running:
>  $servername = "192.168.10.XXX";
> $username = "root";
> $password = "123456789";
> $conn = new mysqli($servername, $username, $password); if
> ($conn->connect_error) {
>   die("Connection failed: " . $conn->connect_error); } echo "Connected
> successfully"; ?>
>
> I SSH into my web server and run this command "php TestMySQL.php".  I
> receive the output of "Connected successfully".
>
> When I attempt through my browser or curl, I receive the output of
> "Connection failed: Permission denied".
>
> I can also connect to the remote database with the local mysql client.
>
> Thank you all in advance for your help.
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP-DB] Can connect to Mysql via command line but not via browser

2020-09-03 Thread Tai Larson
I have a MySQL database server and a separate web sever running Apache.  Both 
are running Centos 8. 

I can connect to my database server from my web server via the command line, 
but I get permission denied whenever I try to connect to the server via a 
browser.

Here is the code I'm running:
connect_error) {
  die("Connection failed: " . $conn->connect_error); } echo "Connected 
successfully"; ?>

I SSH into my web server and run this command "php TestMySQL.php".  I receive 
the output of "Connected successfully".

When I attempt through my browser or curl, I receive the output of "Connection 
failed: Permission denied".

I can also connect to the remote database with the local mysql client.

Thank you all in advance for your help.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] MySQLi, MongoDB and MySQL work together

2019-07-17 Thread Matt Zand
Hi,

I have a large application that uses MySQLi and MySQL. We are planning to
add few custom plug-in written in MEAN stack with Node.JS and MongoDB.

Before integration, is there any precaution we should consider. Also, if
data is shared between MongoDB db and MySQLi, should I create an API to
synchronize data or what is best way to achieve that?

I have basic knowledge of MongoDB, so I appreciate your advice.

-- 
Cheers,

Matt Zand
Cell: 202-420-9192
Work: 240-200-6131
High School Technology Services 
DC Web Makers 
Coding Bootcamps 


Re: [PHP-DB] Getting PDO-OCI to work in PHP 7

2019-05-28 Thread christopher . jones

Possibly try a two stage build:

- build your main PHP without PDO_OCI

- build PDO_OCI as a shared library with a simplified configure command that 
doesn't have ldap.

Then move the resulting PDO_OCI library to your first PHP install and update 
php.ini.

Then test thoroughly.

I have had to do the same with PHP OCI8 in the past.  I don't recall trying it 
with PDO_OCI.

The ldap / Oracle Client header clash isn't new in PHP 7.

Chris

On 29/5/19 6:31 am, Stokes, John M via php-db wrote:

I have made multiple attempts to get PDO-OCI to work in PHP 7. Sometimes it
fails to compile at all, other times appears to compile correctly, but I
can't connect to any Oracle databases. Thus far, this has kept me stuck on
PHP 5.x.

The relevant part of my configure statement is:
./configure \
...
--with-mysqli=/usr/bin/mysql_config \
--with-pdo-mysql=/usr \
--with-pdo-odbc=unixODBC,/usr \
--with-pdo-oci=instantclient,/usr/lib/oracle/18.3/client64/lib/ \
--with-unixODBC=/usr \
...

The latest error is when I run "make":
...snip...
In file included from /root/php-7.2.4/ext/ldap/php_ldap.h:30:0,
  from main/internal_functions.c:50:
/usr/include/oracle/18.3/client64/ldap.h:988:18: error: conflicting types
for ‘ber_scanf’
  LDAPFUNCDECL int ber_scanf ( BerElement *ber, char * fmt, ... );
   ^
In file included from /root/php-7.2.4/ext/ldap/php_ldap.h:27:0,
  from main/internal_functions.c:50:
/usr/include/lber.h:335:1: note: previous declaration of ‘ber_scanf’ was
here
  ber_scanf LDAP_P((
  ^
make: *** [main/internal_functions.lo] Error 1

Can anyone offer me some ideas?
Thanks in advance.

-John

--

John Stokes – Certified Oracle of Security seeking Zend wearing a Red Hat.
(CISSP, ZCE, RHCSA)
Software Engineer
Verizon Wireless - West Territory Data Tools & Reporting

*Three Pillars: Humility, Communication, Balance*



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Getting PDO-OCI to work in PHP 7

2019-05-28 Thread Stokes, John M via php-db
I have made multiple attempts to get PDO-OCI to work in PHP 7. Sometimes it
fails to compile at all, other times appears to compile correctly, but I
can't connect to any Oracle databases. Thus far, this has kept me stuck on
PHP 5.x.

The relevant part of my configure statement is:
./configure \
...
--with-mysqli=/usr/bin/mysql_config \
--with-pdo-mysql=/usr \
--with-pdo-odbc=unixODBC,/usr \
--with-pdo-oci=instantclient,/usr/lib/oracle/18.3/client64/lib/ \
--with-unixODBC=/usr \
...

The latest error is when I run "make":
...snip...
In file included from /root/php-7.2.4/ext/ldap/php_ldap.h:30:0,
 from main/internal_functions.c:50:
/usr/include/oracle/18.3/client64/ldap.h:988:18: error: conflicting types
for ‘ber_scanf’
 LDAPFUNCDECL int ber_scanf ( BerElement *ber, char * fmt, ... );
  ^
In file included from /root/php-7.2.4/ext/ldap/php_ldap.h:27:0,
 from main/internal_functions.c:50:
/usr/include/lber.h:335:1: note: previous declaration of ‘ber_scanf’ was
here
 ber_scanf LDAP_P((
 ^
make: *** [main/internal_functions.lo] Error 1

Can anyone offer me some ideas?
Thanks in advance.

-John

--

John Stokes – Certified Oracle of Security seeking Zend wearing a Red Hat.
(CISSP, ZCE, RHCSA)
Software Engineer
Verizon Wireless - West Territory Data Tools & Reporting

*Three Pillars: Humility, Communication, Balance*


Re: [PHP-DB] PHP mysqli is NOT trapping some errors when calling stored procedure

2019-02-12 Thread Venkat Hariharan
Yes, I do have all reqd privs.

In fact, as long as a duplicate key situation isnt encountered, I am able
to invoke the stored proc from PHP alright and the record gets saved in the
database.

But when I try to re-do it using the same value (thereby I am expecting
that 1062-DUPLICATE KEY error will be thrown and caught by PHP), I dont get
any error from PHP!

In mysql client or MySQL Workbench, I do see the error. when I invoke the
stored proc.

Thanks,
Venkat


On Tue, Feb 12, 2019 at 9:56 PM Aziz Saleh  wrote:

> Do you have sufficient privileges to execute stored procedures
> (procs_priv) on PHP's end?
>
> On Tue, Feb 12, 2019 at 11:07 AM Venkat Hariharan 
> wrote:
>
>> Can you take a look at the issue that I've described at
>>
>> https://stackoverflow.com/questions/54643704/php-mysqli-is-not-trapping-some-errors-when-calling-stored-procedure
>> and tell me what I am missing in my PHP code ?
>>
>> To summarize: I am calling a MySQL stored procedure from PHP that does
>> some
>> DMLs (using mysqli). But the problem is that PHP is not able to get
>> intimated of some database error conditions raised by the stored proc
>> (which I know are raised, bcoz they do get flagged when invoked from a
>> mysql client)
>>
>> I've listed the relevant code fragments there. Am I not using mysqli
>> correctly?
>>
>> Thanks,
>> Venkat
>>
>


Re: [PHP-DB] PHP mysqli is NOT trapping some errors when calling stored procedure

2019-02-12 Thread Aziz Saleh
Do you have sufficient privileges to execute stored procedures (procs_priv)
on PHP's end?

On Tue, Feb 12, 2019 at 11:07 AM Venkat Hariharan 
wrote:

> Can you take a look at the issue that I've described at
>
> https://stackoverflow.com/questions/54643704/php-mysqli-is-not-trapping-some-errors-when-calling-stored-procedure
> and tell me what I am missing in my PHP code ?
>
> To summarize: I am calling a MySQL stored procedure from PHP that does some
> DMLs (using mysqli). But the problem is that PHP is not able to get
> intimated of some database error conditions raised by the stored proc
> (which I know are raised, bcoz they do get flagged when invoked from a
> mysql client)
>
> I've listed the relevant code fragments there. Am I not using mysqli
> correctly?
>
> Thanks,
> Venkat
>


[PHP-DB] [SOLVED] Re: Weird error... (after server crash @ISP)

2017-05-28 Thread Michelle Konzack
I have not remarked, that 

> [64]  function db_query($query, $link='db_link') {

was messed up.  It should be:

  function db_query($link='db_link', $query) {

Thanks

-- 
Michelle KonzackMiila ITSystems @ TDnet
GNU/Linux Developer 00372-54541400


signature.asc
Description: Digital signature


[PHP-DB] Weird error... (after server crash @ISP)

2017-05-28 Thread Michelle Konzack
Hello Guys,

I was just informed by a visitor, that  a  bunch  of  my  websites  show
PHP/pgsql errors...  Of course, they relay all  on   the  same  database
scripts and now I discovered, that the physical server had an error,  my
ISP replaced the harddisks and put a backup of the content on it!

Several month old!

WTF?

I am now for 6 month (or longer) in Estonia and have no physical  access
to my Backups in Strasbourg which really p..s me off!

However, the offending sniplet is:

8<--
[47]} elseif (DB_TYPE == 'pgsql') {
[48]
[49]  function db_connect($host=DB_HOST, $port=DB_PORT, $database=DB_NAME, 
$user=DB_USER, $pass=DB_PASS, $link='db_link') {
[50]global $$link;
[51]$$link = pg_pconnect("host=$host port=$port dbname=$database user=$user 
password=$pass");
[52]return $$link;
[53]  }
[54]
[55]  function db_close($link='db_link') {
[56]global $$link;
[57]return pg_close($link);
[58]  }
[59]
[60]  function db_error($query, $errno, $error) {
[61]die("Error $errno$error$query");
[62]  }
[63]
[64]  function db_query($query, $link='db_link') {
[65]global $$link;
[66]$result = pg_query($link, $query) or db_error($query, '', 
pg_last_error($link));
[67]return $result;
[68]  }
[69]
[70]  function db_fetch_array($db_query) {
[71]return pg_fetch_array($db_query);
[72]  }
[73]
[74]  function db_free_result($db_query) {
[75]return pg_free_result($db_query);
[76]
[77]  function db_fetch_fields($db_query) {
[78]return pg_fetch_fields($db_query);
[79]  }
[80]
[81]  function db_input($string, $link='db_link') {
[82]return pg_escape_string($link, $string);
[83]return addslashes($string);
[84]  }
8<--

[Sun May 28 12:14:20 2017] [error] [client 85.29.216.115] PHP Warning:  
pg_query() expects parameter 1 to be resource, string given in 
/srv/tdphp-vserver2/includes/01_database.inc on line 64
[Sun May 28 12:14:20 2017] [error] [client 85.29.216.115] PHP Warning:  
pg_last_error() expects parameter 1 to be resource, string given in 
/srv/tdphp-vserver2/includes/01_database.inc on line 64


The page show "Resource id #17".

This script was working 68 days ago (before the crash) but it  seems,  I
sit on my line and do not find the error.

Any suggestions?

Have a nice Sunday

-- 
Michelle KonzackMiila ITSystems @ TDnet
GNU/Linux Developer 00372-54541400


signature.asc
Description: Digital signature


Re: [PHP-DB] MySQL connection

2017-03-05 Thread Karl DeSaulniers
That makes complete sense. 
Thank you Joshua.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com




> On Mar 5, 2017, at 6:44 PM, Arneson, Joshua  wrote:
> 
> If you have multiple calls to the database that are grouped, definitely 
> perform them during the same connection session. The bottom line is unless 
> the overhead associated with opening and closing the connection is going to 
> be an issue programmatically, keep connections brief and group your 
> transactions where possible. A good example would be you have a group of 
> calls (A, B, C) that need to happen. Calls A and B can run one after the 
> other, but C has to wait on a user input (no matter how small/simple), you 
> should open the connection, run calls A and B, close the connection waiting 
> on user input, then reopen, run call C, then close the connection. A good 
> exception to this rule would be if you have calls that have to run every 'x' 
> milliseconds and you anticipate that you MIGHT at ANY point run into 
> concurrency issues, you would hold a single open connection for that specific 
> case and adhere to the 'open'-'run calls'-'close' standard for all other 
> cases. Remember, we rarely know what new tasks our programs will be doing in 
> the future so building for scalability is always a good bet. 
> 
> Respectfully,
> 
> Joshua D. Arneson
> Data Manager, Mount Sinai NIH Brain & Tissue Repository (NBTR)
> 130 W Kingsbridge Rd, Rm 5F-04
> Bronx, NY 10468
> Email: joshua.arne...@mssm.edu
> Office: 718-584-9000 ext 6094
> Mobile: 347-915-8911
> Fax: 718-741-4746
> 
>> On Mar 5, 2017, at 7:29 PM, Karl DeSaulniers  wrote:
>> 
>> Ah, thanks for the reply Joshua.
>> 
>> Duly noted. So when is it bad to make multiple open and close connections 
>> then?
>> I am guessing that could have some impact with lots of users too. Yes?
>> 
>> If the website in question does not have a lot of users (less than 1,000), 
>> is this still a bad call to keep an open connection?
>> If so, should I be closing the connection after each page load that has 
>> multiple calls on the database?
>> Or after each call to the database? 
>> 
>> I am wanting to make sure I am not doing something bad or dangerous when 
>> holding these sessions open.
>> If it is a matter of taste, I'll leave it, but if it is a matter of best 
>> practices to open and close, I will change the method I am using.
>> 
>> Again, TIA!
>> 
>> Best,
>> 
>> Karl DeSaulniers
>> Design Drumm
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__designdrumm.com=DwIFAg=shNJtf5dKgNcPZ6Yh64b-A=HSbgyt8GFSyWQ53Nxworjip-dgIKnMlPBkQ0VGj7tYk=w7VxdOhlxCY27A_sfaFCxntsWMG8ZDA3nukN6fBstsA=JzvStr8fa_OyNaHOUe0Xp8_o6aDzZSgZ6OXyEk6WyIM=
>> 
>> 
>> 
>> 
>>> On Mar 5, 2017, at 6:19 PM, Arneson, Joshua  wrote:
>>> 
>>> Right off the bat, you need to consider concurrency issues. Depending on 
>>> the size of your user base and level of activity this could become a major 
>>> issue. In the end, why hold an open connection for 15 minutes just to 
>>> process 20-30 transactions that take 20-30ms each? Just better (under most 
>>> circumstances) to open the connection, process your transaction , then 
>>> close the connection. 
>>> 
>>> Respectfully,
>>> 
>>> Joshua D. Arneson
>>> Data Manager, Mount Sinai NIH Brain & Tissue Repository (NBTR)
>>> 130 W Kingsbridge Rd, Rm 5F-04
>>> Bronx, NY 10468
>>> Email: joshua.arne...@mssm.edu
>>> Office: 718-584-9000 ext 6094
>>> Mobile: 347-915-8911
>>> Fax: 718-741-4746
>>> 
 On Mar 5, 2017, at 6:54 PM, Karl DeSaulniers  wrote:
 
 Hello everyone,
 Long time. Hope all are well.
 
 Quick question. How should MySQL connections be treated?
 Is it ok to leave them open or is it better to close them after 
 transactions?
 I have a website that uses sessions and was wondering if there was any 
 situations where I should be closing the connection.
 Either for performance reasons or security or best practices. 
 
 Just wondering your professional.
 
 TIA
 
 Best,
 
 Karl DeSaulniers
 Design Drumm
 https://urldefense.proofpoint.com/v2/url?u=http-3A__designdrumm.com=DwIFAg=shNJtf5dKgNcPZ6Yh64b-A=HSbgyt8GFSyWQ53Nxworjip-dgIKnMlPBkQ0VGj7tYk=09oI7Bn2rpePGXSl8CmHMTUqhm3Rjh676OnMYed0L_4=JBoK9bslzQegAxQDG_NbsuvcCBLw5_LIQkjMpEj4kE8=
  
 
 
 
 
 
>>> 
>>> --
>>> PHP Database Mailing List 
>>> (https://urldefense.proofpoint.com/v2/url?u=http-3A__www.php.net_=DwIFAg=shNJtf5dKgNcPZ6Yh64b-A=HSbgyt8GFSyWQ53Nxworjip-dgIKnMlPBkQ0VGj7tYk=w7VxdOhlxCY27A_sfaFCxntsWMG8ZDA3nukN6fBstsA=wWlQEGEfTaOWZtdTA776DTMosB5WtSX6K5iaiWM7J3A=
>>>  )
>>> To unsubscribe, visit: 
>>> 

Re: [PHP-DB] MySQL connection

2017-03-05 Thread Arneson, Joshua
If you have multiple calls to the database that are grouped, definitely perform 
them during the same connection session. The bottom line is unless the overhead 
associated with opening and closing the connection is going to be an issue 
programmatically, keep connections brief and group your transactions where 
possible. A good example would be you have a group of calls (A, B, C) that need 
to happen. Calls A and B can run one after the other, but C has to wait on a 
user input (no matter how small/simple), you should open the connection, run 
calls A and B, close the connection waiting on user input, then reopen, run 
call C, then close the connection. A good exception to this rule would be if 
you have calls that have to run every 'x' milliseconds and you anticipate that 
you MIGHT at ANY point run into concurrency issues, you would hold a single 
open connection for that specific case and adhere to the 'open'-'run 
calls'-'close' standard for all other cases. Remember, we rarely know what new 
tasks our programs will be doing in the future so building for scalability is 
always a good bet. 

Respectfully,

Joshua D. Arneson
Data Manager, Mount Sinai NIH Brain & Tissue Repository (NBTR)
130 W Kingsbridge Rd, Rm 5F-04
Bronx, NY 10468
Email: joshua.arne...@mssm.edu
Office: 718-584-9000 ext 6094
Mobile: 347-915-8911
Fax: 718-741-4746

> On Mar 5, 2017, at 7:29 PM, Karl DeSaulniers  wrote:
> 
> Ah, thanks for the reply Joshua.
> 
> Duly noted. So when is it bad to make multiple open and close connections 
> then?
> I am guessing that could have some impact with lots of users too. Yes?
> 
> If the website in question does not have a lot of users (less than 1,000), is 
> this still a bad call to keep an open connection?
> If so, should I be closing the connection after each page load that has 
> multiple calls on the database?
> Or after each call to the database? 
> 
> I am wanting to make sure I am not doing something bad or dangerous when 
> holding these sessions open.
> If it is a matter of taste, I'll leave it, but if it is a matter of best 
> practices to open and close, I will change the method I am using.
> 
> Again, TIA!
> 
> Best,
> 
> Karl DeSaulniers
> Design Drumm
> https://urldefense.proofpoint.com/v2/url?u=http-3A__designdrumm.com=DwIFAg=shNJtf5dKgNcPZ6Yh64b-A=HSbgyt8GFSyWQ53Nxworjip-dgIKnMlPBkQ0VGj7tYk=w7VxdOhlxCY27A_sfaFCxntsWMG8ZDA3nukN6fBstsA=JzvStr8fa_OyNaHOUe0Xp8_o6aDzZSgZ6OXyEk6WyIM=
> 
> 
> 
> 
>> On Mar 5, 2017, at 6:19 PM, Arneson, Joshua  wrote:
>> 
>> Right off the bat, you need to consider concurrency issues. Depending on the 
>> size of your user base and level of activity this could become a major 
>> issue. In the end, why hold an open connection for 15 minutes just to 
>> process 20-30 transactions that take 20-30ms each? Just better (under most 
>> circumstances) to open the connection, process your transaction , then close 
>> the connection. 
>> 
>> Respectfully,
>> 
>> Joshua D. Arneson
>> Data Manager, Mount Sinai NIH Brain & Tissue Repository (NBTR)
>> 130 W Kingsbridge Rd, Rm 5F-04
>> Bronx, NY 10468
>> Email: joshua.arne...@mssm.edu
>> Office: 718-584-9000 ext 6094
>> Mobile: 347-915-8911
>> Fax: 718-741-4746
>> 
>>> On Mar 5, 2017, at 6:54 PM, Karl DeSaulniers  wrote:
>>> 
>>> Hello everyone,
>>> Long time. Hope all are well.
>>> 
>>> Quick question. How should MySQL connections be treated?
>>> Is it ok to leave them open or is it better to close them after 
>>> transactions?
>>> I have a website that uses sessions and was wondering if there was any 
>>> situations where I should be closing the connection.
>>> Either for performance reasons or security or best practices. 
>>> 
>>> Just wondering your professional.
>>> 
>>> TIA
>>> 
>>> Best,
>>> 
>>> Karl DeSaulniers
>>> Design Drumm
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__designdrumm.com=DwIFAg=shNJtf5dKgNcPZ6Yh64b-A=HSbgyt8GFSyWQ53Nxworjip-dgIKnMlPBkQ0VGj7tYk=09oI7Bn2rpePGXSl8CmHMTUqhm3Rjh676OnMYed0L_4=JBoK9bslzQegAxQDG_NbsuvcCBLw5_LIQkjMpEj4kE8=
>>>  
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
>> --
>> PHP Database Mailing List 
>> (https://urldefense.proofpoint.com/v2/url?u=http-3A__www.php.net_=DwIFAg=shNJtf5dKgNcPZ6Yh64b-A=HSbgyt8GFSyWQ53Nxworjip-dgIKnMlPBkQ0VGj7tYk=w7VxdOhlxCY27A_sfaFCxntsWMG8ZDA3nukN6fBstsA=wWlQEGEfTaOWZtdTA776DTMosB5WtSX6K5iaiWM7J3A=
>>  )
>> To unsubscribe, visit: 
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.php.net_unsub.php=DwIFAg=shNJtf5dKgNcPZ6Yh64b-A=HSbgyt8GFSyWQ53Nxworjip-dgIKnMlPBkQ0VGj7tYk=w7VxdOhlxCY27A_sfaFCxntsWMG8ZDA3nukN6fBstsA=qSyyKaFDMntOGvbZ-jgs6sfh-DyfkxT3tTOLa-uFDDw=
>>  
> 
> 
> --
> PHP Database Mailing List 
> 

Re: [PHP-DB] MySQL connection

2017-03-05 Thread Karl DeSaulniers
Ah, thanks for the reply Joshua.

Duly noted. So when is it bad to make multiple open and close connections then?
I am guessing that could have some impact with lots of users too. Yes?

If the website in question does not have a lot of users (less than 1,000), is 
this still a bad call to keep an open connection?
If so, should I be closing the connection after each page load that has 
multiple calls on the database?
Or after each call to the database? 

I am wanting to make sure I am not doing something bad or dangerous when 
holding these sessions open.
If it is a matter of taste, I'll leave it, but if it is a matter of best 
practices to open and close, I will change the method I am using.

Again, TIA!

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com




> On Mar 5, 2017, at 6:19 PM, Arneson, Joshua  wrote:
> 
> Right off the bat, you need to consider concurrency issues. Depending on the 
> size of your user base and level of activity this could become a major issue. 
> In the end, why hold an open connection for 15 minutes just to process 20-30 
> transactions that take 20-30ms each? Just better (under most circumstances) 
> to open the connection, process your transaction , then close the connection. 
> 
> Respectfully,
> 
> Joshua D. Arneson
> Data Manager, Mount Sinai NIH Brain & Tissue Repository (NBTR)
> 130 W Kingsbridge Rd, Rm 5F-04
> Bronx, NY 10468
> Email: joshua.arne...@mssm.edu
> Office: 718-584-9000 ext 6094
> Mobile: 347-915-8911
> Fax: 718-741-4746
> 
>> On Mar 5, 2017, at 6:54 PM, Karl DeSaulniers  wrote:
>> 
>> Hello everyone,
>> Long time. Hope all are well.
>> 
>> Quick question. How should MySQL connections be treated?
>> Is it ok to leave them open or is it better to close them after transactions?
>> I have a website that uses sessions and was wondering if there was any 
>> situations where I should be closing the connection.
>> Either for performance reasons or security or best practices. 
>> 
>> Just wondering your professional.
>> 
>> TIA
>> 
>> Best,
>> 
>> Karl DeSaulniers
>> Design Drumm
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__designdrumm.com=DwIFAg=shNJtf5dKgNcPZ6Yh64b-A=HSbgyt8GFSyWQ53Nxworjip-dgIKnMlPBkQ0VGj7tYk=09oI7Bn2rpePGXSl8CmHMTUqhm3Rjh676OnMYed0L_4=JBoK9bslzQegAxQDG_NbsuvcCBLw5_LIQkjMpEj4kE8=
>>  
>> >  >
>> 
>> 
>> 
>> 
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL connection

2017-03-05 Thread Arneson, Joshua
Right off the bat, you need to consider concurrency issues. Depending on the 
size of your user base and level of activity this could become a major issue. 
In the end, why hold an open connection for 15 minutes just to process 20-30 
transactions that take 20-30ms each? Just better (under most circumstances) to 
open the connection, process your transaction , then close the connection. 

Respectfully,

Joshua D. Arneson
Data Manager, Mount Sinai NIH Brain & Tissue Repository (NBTR)
130 W Kingsbridge Rd, Rm 5F-04
Bronx, NY 10468
Email: joshua.arne...@mssm.edu
Office: 718-584-9000 ext 6094
Mobile: 347-915-8911
Fax: 718-741-4746

> On Mar 5, 2017, at 6:54 PM, Karl DeSaulniers  wrote:
> 
> Hello everyone,
> Long time. Hope all are well.
> 
> Quick question. How should MySQL connections be treated?
> Is it ok to leave them open or is it better to close them after transactions?
> I have a website that uses sessions and was wondering if there was any 
> situations where I should be closing the connection.
> Either for performance reasons or security or best practices. 
> 
> Just wondering your professional.
> 
> TIA
> 
> Best,
> 
> Karl DeSaulniers
> Design Drumm
> https://urldefense.proofpoint.com/v2/url?u=http-3A__designdrumm.com=DwIFAg=shNJtf5dKgNcPZ6Yh64b-A=HSbgyt8GFSyWQ53Nxworjip-dgIKnMlPBkQ0VGj7tYk=09oI7Bn2rpePGXSl8CmHMTUqhm3Rjh676OnMYed0L_4=JBoK9bslzQegAxQDG_NbsuvcCBLw5_LIQkjMpEj4kE8=
>  
>   >
> 
> 
> 
> 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] MySQL connection

2017-03-05 Thread Karl DeSaulniers
Hello everyone,
Long time. Hope all are well.

Quick question. How should MySQL connections be treated?
Is it ok to leave them open or is it better to close them after transactions?
I have a website that uses sessions and was wondering if there was any 
situations where I should be closing the connection.
Either for performance reasons or security or best practices. 

Just wondering your professional.

TIA

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com 






Re: [PHP-DB] Re: CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8PHP is loading white spaces

2016-11-22 Thread Lester Caine
On 22/11/16 18:01, Delmar Wichnieski wrote:
> 2016-11-22 12:42 GMT-02:00 Lester Caine :
> 
>> >  needs help to move
>> > the string to a variable that it can check if the UTF8 data is a single
>> > character or multiple characters.
>> >
>> >
> I believe it is a single byte, the goal is to simulate a boolean field,
> where I only use S for yes and N for no. (Idem/the same Y and N in English).
> 
> There is no operations like 'upper' and 'lower'. The script is very simple,
> according to pastebin links in the previous message.
> 
> S and N are in the range between 0 and 127 of the ASCII table and UTF-8
> says that only one byte is required to encode the first 128 ASCII
> characters (Unicode U +  to U + 007F).
> 
> But even if it consumed 2, 3 or 4 bytes, UNICODE should predict the end of
> the character, so it would be enough to find the end, apply the inverse
> algorithm to the encoding of the code point, and we would have the
> character back. This is just a dream.
> 
> 
> If the situation presented along the thread is a problem, then more people
> should report it. Let's wait. I'll use trim per hour, or cast
> 
> example
> 
> $q = $pdoconn->prepare("SELECT CODIGO, CAST(ACESSOSISTEMA AS VARCHAR(1)) AS
> ACESSOSISTEMA FROM USUARIO");
> 
> And the problem is solved. Or yet another solution not thought out.

That is perhaps the point. PHP on it's own can't decide if you need to
convert to an ASCII single byte, allow space for a multiple byte single
character or something else. All PHP sees is a buffer with a number of
bytes in, and what comes over the wire from Firebird even strips any
trailing space characters requiring the client end to untangle things.
If you want a unicode string you have to copy it to a mbstring variable
since the simple single byte buffer does not know that it is not just
256 bit data. Now a CHAR(1) could be treated as a special case, but
CHAR(2+) can not be so easily handled. This is one reason why the normal
'hack' to add a binary domain is to use a SMALLINT rather than a CHAR
and store NULL/0/1 ...

I'm not saying that the current results are correct, just that without a
native handling of unicode one has some edge cases which could be
resolved different ways. Returning a unicode CHAR field as a fixed
number of 32bit characters has an attraction when one needs to work with
particular fixed character positions in the string but while UNICODE_FSS
was designed with that in mind, UTF8 *IS* the right way forward once
everybody actually supports it ;)

One of my pet grips is that simple PHP variables do not play well with
database fields, and rather than having to pull in mbstring, extending
'string' so that it can be flagged as utf8 and handle a utf8 field
natively is what is needed. The fact that Firebird is capable of using a
different collation for each field is not something that PHP understands
and another reason I don't use PDO at all in production. With ADOdb one
has a bit more access to the metadata for the query.

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8PHP is loading white spaces

2016-11-22 Thread Delmar Wichnieski
2016-11-22 12:42 GMT-02:00 Lester Caine :

>  needs help to move
> the string to a variable that it can check if the UTF8 data is a single
> character or multiple characters.
>
>
I believe it is a single byte, the goal is to simulate a boolean field,
where I only use S for yes and N for no. (Idem/the same Y and N in English).

There is no operations like 'upper' and 'lower'. The script is very simple,
according to pastebin links in the previous message.

S and N are in the range between 0 and 127 of the ASCII table and UTF-8
says that only one byte is required to encode the first 128 ASCII
characters (Unicode U +  to U + 007F).

But even if it consumed 2, 3 or 4 bytes, UNICODE should predict the end of
the character, so it would be enough to find the end, apply the inverse
algorithm to the encoding of the code point, and we would have the
character back. This is just a dream.


If the situation presented along the thread is a problem, then more people
should report it. Let's wait. I'll use trim per hour, or cast

example

$q = $pdoconn->prepare("SELECT CODIGO, CAST(ACESSOSISTEMA AS VARCHAR(1)) AS
ACESSOSISTEMA FROM USUARIO");

And the problem is solved. Or yet another solution not thought out.

Thank you for the precious information.

Delmar Wichnieski


Re: [PHP-DB] Re: CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8PHP is loading white spaces

2016-11-22 Thread Lester Caine
On 22/11/16 13:56, Delmar Wichnieski wrote:
> But VARCHAR fields work correctly. Problem only in CHAR.

VARCHAR is trimmed to the number of bytes used ... not the number of
'characters'! CHAR is only designed for single byte characters IN PHP so
providing multi byte characters to a CHAR(1) field does not know how
many actual characters are displayed. I'm not saying what is currently
happening is right, but it is 'safe' since PHP then needs help to move
the string to a variable that it can check if the UTF8 data is a single
character or multiple characters.

> And it should not be gambol, because
> "Each UTF is reversible, thus every UTF supports lossless round tripping:
> mapping from any Unicode coded character sequence S to a sequence of bytes
> and back will produce S again."
> Source
> http://unicode.org/faq/utf_bom.html

Provided that there is no processing of the data then that is correct,
but operations like 'upper' and 'lower' can result in a change in number
of characters, and the addition of accent characters can also result in
differences. It is this area that basically stopped the development of a
UTF8 native PHP6. Normalization in http://www.unicode.org/reports/tr15/
is a minefield even for the Firebird collation process ... Just how long
is the normalized string?

> 2016-11-22 11:21 GMT-02:00 Lester Caine :
> 
>> > On 22/11/16 12:58, Delmar Wichnieski wrote:
>>> > > Since there was no answer here on the list, I was feeling alone and
>> > afraid
>>> > > and wondering why no one else has this problem.
>> >
>> > Delmar I must apologise as I HAD posted a reply, but it did not actually
>> > go through ... list in bounce emails mode which I missed ...
>> >
>> > The simple answer is that strings in PHP are not UTF8 so the 'bug' you
>> > are listing is actually that we need to make sure that the single byte
>> > buffer for a string is long enough. To ensure UTF8 strings to be handled
>> > properly since PHP6 is not going to happen, we have to transfer the
>> > simple php strings to mbstring objects. UTF8 is a gambol in PHP if it is
>> > going to be transferred properly as a simple string variable and will
>> > give string length as bytes rather than characters ...


-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8PHP is loading white spaces

2016-11-22 Thread Delmar Wichnieski
But VARCHAR fields work correctly. Problem only in CHAR.

And it should not be gambol, because
"Each UTF is reversible, thus every UTF supports lossless round tripping:
mapping from any Unicode coded character sequence S to a sequence of bytes
and back will produce S again."
Source
http://unicode.org/faq/utf_bom.html

2016-11-22 11:21 GMT-02:00 Lester Caine :

> On 22/11/16 12:58, Delmar Wichnieski wrote:
> > Since there was no answer here on the list, I was feeling alone and
> afraid
> > and wondering why no one else has this problem.
>
> Delmar I must apologise as I HAD posted a reply, but it did not actually
> go through ... list in bounce emails mode which I missed ...
>
> The simple answer is that strings in PHP are not UTF8 so the 'bug' you
> are listing is actually that we need to make sure that the single byte
> buffer for a string is long enough. To ensure UTF8 strings to be handled
> properly since PHP6 is not going to happen, we have to transfer the
> simple php strings to mbstring objects. UTF8 is a gambol in PHP if it is
> going to be transferred properly as a simple string variable and will
> give string length as bytes rather than characters ...
>
> --
> Lester Caine - G8HFL
> -
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk
> Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP-DB] Re: CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8PHP is loading white spaces

2016-11-22 Thread Lester Caine
On 22/11/16 12:58, Delmar Wichnieski wrote:
> Since there was no answer here on the list, I was feeling alone and afraid
> and wondering why no one else has this problem.

Delmar I must apologise as I HAD posted a reply, but it did not actually
go through ... list in bounce emails mode which I missed ...

The simple answer is that strings in PHP are not UTF8 so the 'bug' you
are listing is actually that we need to make sure that the single byte
buffer for a string is long enough. To ensure UTF8 strings to be handled
properly since PHP6 is not going to happen, we have to transfer the
simple php strings to mbstring objects. UTF8 is a gambol in PHP if it is
going to be transferred properly as a simple string variable and will
give string length as bytes rather than characters ...

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8PHP is loading white spaces

2016-11-22 Thread Delmar Wichnieski
For 30 days, I avoided opening as a bug, because I researched a lot, I
asked in some forums with more than 50 thousand users and I did not find
anyone else with this problem, so much so that in the initial post, I asked
if it could be a configuration problem, or bug or lack of full UFT8 support
with Firebir CHAR fields.

Since there was no answer here on the list, I was feeling alone and afraid
and wondering why no one else has this problem.

Environment test
Windows 10
PHP 7.1.0RC5+ x64 VC14 TS
Apache Lounge 2.4.23 x64 VC14
firebird 3.0.1 x64

configuration
php.ini
default_charset = "UTF-8"
PHP script file with the test in UFT-8



Example
CHAR SIZE 1
in the database
'S'
In php results
'S   ' instead of 'S'
vardump (char_field)
string (4) "S   "

(The issue is the same on ibase_query as PDO)

IMPORTANT
To isolate de problem, all create and insert were executed by isql


ALL DDL

DDL for all 5 collates

http://pastebin.com/0dK6xqS5



script test php

http://pastebin.com/ZRmMRiDy



script test php with PDO

http://pastebin.com/r7rErRyS

2016-11-22 10:05 GMT-02:00 Christoph M. Becker :

> On 22.11.2016 at 12:27, Delmar Wichnieski wrote:
>
> > This issue also occurs with folow PHP versions (for any collate - UTF8)
> > PHP 7.0.12+
> > PHP 7.1.0 RC4+
> > Firebir 2.5.5 + and Firebird-3.0.1.32609_0_x64
> > I have no test with other versions.
> >
> >
> > The driver could map the SQLVARs of SQL_TEXT to SQL_VARYING and adjust
> > offsets and lengths?
> >
> > Or else it has to do the manual work of identifying the charset (UTF8 =
> > number 4) and get byte by byte by mounting the string disregarding the
> > extra spaces.
> >
> > How to resolve without using trim or could there be a fix for an upcoming
> > release if the drive is not able to work with CHAR fields in UTF8?
> >
> > 2016-10-21 10:24 GMT-02:00 Delmar Wichnieski :
> >
> >> Subject:
> >> CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8 PHP is
> >> loading white spaces
> >> Example
> >> 'S   ' instead of 'S'
> >>
> >> Environment
> >> Windows 10
> >> PHP 7.0.12 x64 VC14 TS
> >> Apache Lounge 2.4.23 x64 VC14
> >> firebird 2.5.5
> >>
> >> configuration
> >> php.ini
> >> default_charset = "UTF-8"
> >> connection to the database
> >> ibase_connect ( "localhost:" DB, user, pw, "UTF8".
> >> connection PHP script file in UTF-8
> >> PHP script file with the test in UFT-8
> >> response header
> >>Content-Type: text / html; charset = UTF-8
> >> file.html
> >> 
> >>
> >> Migration in Firebird 2.5.5 charset ISO8859_1 collate PT_BR to UTF8 and
> >> UNICODE_CI_AI (firebird 2.5.5)
> >>
> >> DDL
> >>
> >> SET SQL DIALECT 3;
> >>
> >> SET NAMES UTF8;
> >>
> >> SET CLIENTLIB 'C:\Program Files\Firebird\Firebird_2_5_5\
> >> WOW64\fbclient.dll';
> >>
> >> CREATE DATABASE 'D:\MYDB_UTF8.FDB'
> >> USER 'SYSDBA' PASSWORD 'A'
> >> PAGE_SIZE 4096
> >> DEFAULT CHARACTER SET UTF8 COLLATION UNICODE_CI_AI;
> >>
> >> CREATE TABLE USUARIO (
> >> CODIGO INTEGER NOT NULL,
> >> USUARIOVARCHAR(20) CHARACTER SET UTF8 NOT NULL COLLATE
> >> UNICODE_CI_AI,
> >> SENHA  VARCHAR(10) CHARACTER SET UTF8 NOT NULL COLLATE
> >> UNICODE_CI_AI,
> >> CODCIDADE  INTEGER,
> >> ACESSOSISTEMA  CHAR(1) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI,
> >> CPFVARCHAR(12) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI
> >> );
> >>
> >>
> >>
> >> Example
> >> CHAR SIZE 1
> >> in the database
> >> 'S'
> >> In php results
> >> 'S   ' instead of 'S'
> >> vardump (char_field)
> >> string (4) "S   "
> >>
> >> (Both ibase_query as PDO)
> >>
> >> Its a configuration problem, bug or not full support to UFT-8?
>
> On a quick glance, it seems this issue has been reported as bug, see
> .
>
> --
> Christoph M. Becker
>
>


[PHP-DB] Re: CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8PHP is loading white spaces

2016-11-22 Thread Christoph M. Becker
On 22.11.2016 at 12:27, Delmar Wichnieski wrote:

> This issue also occurs with folow PHP versions (for any collate - UTF8)
> PHP 7.0.12+
> PHP 7.1.0 RC4+
> Firebir 2.5.5 + and Firebird-3.0.1.32609_0_x64
> I have no test with other versions.
> 
> 
> The driver could map the SQLVARs of SQL_TEXT to SQL_VARYING and adjust
> offsets and lengths?
> 
> Or else it has to do the manual work of identifying the charset (UTF8 =
> number 4) and get byte by byte by mounting the string disregarding the
> extra spaces.
> 
> How to resolve without using trim or could there be a fix for an upcoming
> release if the drive is not able to work with CHAR fields in UTF8?
> 
> 2016-10-21 10:24 GMT-02:00 Delmar Wichnieski :
> 
>> Subject:
>> CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8 PHP is
>> loading white spaces
>> Example
>> 'S   ' instead of 'S'
>>
>> Environment
>> Windows 10
>> PHP 7.0.12 x64 VC14 TS
>> Apache Lounge 2.4.23 x64 VC14
>> firebird 2.5.5
>>
>> configuration
>> php.ini
>> default_charset = "UTF-8"
>> connection to the database
>> ibase_connect ( "localhost:" DB, user, pw, "UTF8".
>> connection PHP script file in UTF-8
>> PHP script file with the test in UFT-8
>> response header
>>Content-Type: text / html; charset = UTF-8
>> file.html
>> 
>>
>> Migration in Firebird 2.5.5 charset ISO8859_1 collate PT_BR to UTF8 and
>> UNICODE_CI_AI (firebird 2.5.5)
>>
>> DDL
>>
>> SET SQL DIALECT 3;
>>
>> SET NAMES UTF8;
>>
>> SET CLIENTLIB 'C:\Program Files\Firebird\Firebird_2_5_5\
>> WOW64\fbclient.dll';
>>
>> CREATE DATABASE 'D:\MYDB_UTF8.FDB'
>> USER 'SYSDBA' PASSWORD 'A'
>> PAGE_SIZE 4096
>> DEFAULT CHARACTER SET UTF8 COLLATION UNICODE_CI_AI;
>>
>> CREATE TABLE USUARIO (
>> CODIGO INTEGER NOT NULL,
>> USUARIOVARCHAR(20) CHARACTER SET UTF8 NOT NULL COLLATE
>> UNICODE_CI_AI,
>> SENHA  VARCHAR(10) CHARACTER SET UTF8 NOT NULL COLLATE
>> UNICODE_CI_AI,
>> CODCIDADE  INTEGER,
>> ACESSOSISTEMA  CHAR(1) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI,
>> CPFVARCHAR(12) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI
>> );
>>
>>
>>
>> Example
>> CHAR SIZE 1
>> in the database
>> 'S'
>> In php results
>> 'S   ' instead of 'S'
>> vardump (char_field)
>> string (4) "S   "
>>
>> (Both ibase_query as PDO)
>>
>> Its a configuration problem, bug or not full support to UFT-8?

On a quick glance, it seems this issue has been reported as bug, see
.

-- 
Christoph M. Becker


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] RE: [PHP-WIN] Re: CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8 PHP is loading white spaces

2016-11-22 Thread Anatol Belski
Hi Delmar,

> -Original Message-
> From: Delmar Wichnieski [mailto:delmar.del...@gmail.com]
> Sent: Tuesday, November 22, 2016 12:27 PM
> To: php-wind...@lists.php.net; php-db@lists.php.net
> Subject: [PHP-WIN] Re: CHAR field with charset UTF8 and COLLATION
> UNICODE_CI_AI or UTF8 PHP is loading white spaces
> 
> This issue also occurs with folow PHP versions (for any collate - UTF8) PHP
> 7.0.12+ PHP 7.1.0 RC4+ Firebir 2.5.5 + and Firebird-3.0.1.32609_0_x64 I have 
> no
> test with other versions.
> 
Please file an issue to bugs.php.net with the complete reproduce case. Probably 
you could also try pdo_firebird, to check the difference.

Thanks

Anatol

> 
> The driver could map the SQLVARs of SQL_TEXT to SQL_VARYING and adjust
> offsets and lengths?
> 
> Or else it has to do the manual work of identifying the charset (UTF8 = number
> 4) and get byte by byte by mounting the string disregarding the extra spaces.
> 
> How to resolve without using trim or could there be a fix for an upcoming
> release if the drive is not able to work with CHAR fields in UTF8?
> 
> 2016-10-21 10:24 GMT-02:00 Delmar Wichnieski <delmar.del...@gmail.com>:
> 
> > Subject:
> > CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8 PHP
> > is loading white spaces Example
> > 'S   ' instead of 'S'
> >
> > Environment
> > Windows 10
> > PHP 7.0.12 x64 VC14 TS
> > Apache Lounge 2.4.23 x64 VC14
> > firebird 2.5.5
> >
> > configuration
> > php.ini
> > default_charset = "UTF-8"
> > connection to the database
> > ibase_connect ( "localhost:" DB, user, pw, "UTF8".
> > connection PHP script file in UTF-8
> > PHP script file with the test in UFT-8 response header
> >Content-Type: text / html; charset = UTF-8 file.html
> > 
> >
> > Migration in Firebird 2.5.5 charset ISO8859_1 collate PT_BR to UTF8
> > and UNICODE_CI_AI (firebird 2.5.5)
> >
> > DDL
> >
> > SET SQL DIALECT 3;
> >
> > SET NAMES UTF8;
> >
> > SET CLIENTLIB 'C:\Program Files\Firebird\Firebird_2_5_5\
> > WOW64\fbclient.dll';
> >
> > CREATE DATABASE 'D:\MYDB_UTF8.FDB'
> > USER 'SYSDBA' PASSWORD 'A'
> > PAGE_SIZE 4096
> > DEFAULT CHARACTER SET UTF8 COLLATION UNICODE_CI_AI;
> >
> > CREATE TABLE USUARIO (
> > CODIGO INTEGER NOT NULL,
> > USUARIOVARCHAR(20) CHARACTER SET UTF8 NOT NULL COLLATE
> > UNICODE_CI_AI,
> > SENHA  VARCHAR(10) CHARACTER SET UTF8 NOT NULL COLLATE
> > UNICODE_CI_AI,
> > CODCIDADE  INTEGER,
> > ACESSOSISTEMA  CHAR(1) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI,
> > CPFVARCHAR(12) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI
> > );
> >
> >
> >
> > Example
> > CHAR SIZE 1
> > in the database
> > 'S'
> > In php results
> > 'S   ' instead of 'S'
> > vardump (char_field)
> > string (4) "S   "
> >
> > (Both ibase_query as PDO)
> >
> > Its a configuration problem, bug or not full support to UFT-8?
> >
> > Thank you very much!
> >
> >
> >


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8 PHP is loading white spaces

2016-11-22 Thread Delmar Wichnieski
This issue also occurs with folow PHP versions (for any collate - UTF8)
PHP 7.0.12+
PHP 7.1.0 RC4+
Firebir 2.5.5 + and Firebird-3.0.1.32609_0_x64
I have no test with other versions.


The driver could map the SQLVARs of SQL_TEXT to SQL_VARYING and adjust
offsets and lengths?

Or else it has to do the manual work of identifying the charset (UTF8 =
number 4) and get byte by byte by mounting the string disregarding the
extra spaces.

How to resolve without using trim or could there be a fix for an upcoming
release if the drive is not able to work with CHAR fields in UTF8?

2016-10-21 10:24 GMT-02:00 Delmar Wichnieski :

> Subject:
> CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8 PHP is
> loading white spaces
> Example
> 'S   ' instead of 'S'
>
> Environment
> Windows 10
> PHP 7.0.12 x64 VC14 TS
> Apache Lounge 2.4.23 x64 VC14
> firebird 2.5.5
>
> configuration
> php.ini
> default_charset = "UTF-8"
> connection to the database
> ibase_connect ( "localhost:" DB, user, pw, "UTF8".
> connection PHP script file in UTF-8
> PHP script file with the test in UFT-8
> response header
>Content-Type: text / html; charset = UTF-8
> file.html
> 
>
> Migration in Firebird 2.5.5 charset ISO8859_1 collate PT_BR to UTF8 and
> UNICODE_CI_AI (firebird 2.5.5)
>
> DDL
>
> SET SQL DIALECT 3;
>
> SET NAMES UTF8;
>
> SET CLIENTLIB 'C:\Program Files\Firebird\Firebird_2_5_5\
> WOW64\fbclient.dll';
>
> CREATE DATABASE 'D:\MYDB_UTF8.FDB'
> USER 'SYSDBA' PASSWORD 'A'
> PAGE_SIZE 4096
> DEFAULT CHARACTER SET UTF8 COLLATION UNICODE_CI_AI;
>
> CREATE TABLE USUARIO (
> CODIGO INTEGER NOT NULL,
> USUARIOVARCHAR(20) CHARACTER SET UTF8 NOT NULL COLLATE
> UNICODE_CI_AI,
> SENHA  VARCHAR(10) CHARACTER SET UTF8 NOT NULL COLLATE
> UNICODE_CI_AI,
> CODCIDADE  INTEGER,
> ACESSOSISTEMA  CHAR(1) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI,
> CPFVARCHAR(12) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI
> );
>
>
>
> Example
> CHAR SIZE 1
> in the database
> 'S'
> In php results
> 'S   ' instead of 'S'
> vardump (char_field)
> string (4) "S   "
>
> (Both ibase_query as PDO)
>
> Its a configuration problem, bug or not full support to UFT-8?
>
> Thank you very much!
>
>
>


[PHP-DB] CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8 PHP is loading white spaces

2016-10-21 Thread Delmar Wichnieski
Subject:
CHAR field with charset UTF8 and COLLATION UNICODE_CI_AI or UTF8 PHP is
loading white spaces
Example
'S   ' instead of 'S'

Environment
Windows 10
PHP 7.0.12 x64 VC14 TS
Apache Lounge 2.4.23 x64 VC14
firebird 2.5.5

configuration
php.ini
default_charset = "UTF-8"
connection to the database
ibase_connect ( "localhost:" DB, user, pw, "UTF8".
connection PHP script file in UTF-8
PHP script file with the test in UFT-8
response header
   Content-Type: text / html; charset = UTF-8
file.html


Migration in Firebird 2.5.5 charset ISO8859_1 collate PT_BR to UTF8 and
UNICODE_CI_AI (firebird 2.5.5)

DDL

SET SQL DIALECT 3;

SET NAMES UTF8;

SET CLIENTLIB 'C:\Program Files\Firebird\Firebird_2_5_5\WOW64\fbclient.dll';

CREATE DATABASE 'D:\MYDB_UTF8.FDB'
USER 'SYSDBA' PASSWORD 'A'
PAGE_SIZE 4096
DEFAULT CHARACTER SET UTF8 COLLATION UNICODE_CI_AI;

CREATE TABLE USUARIO (
CODIGO INTEGER NOT NULL,
USUARIOVARCHAR(20) CHARACTER SET UTF8 NOT NULL COLLATE
UNICODE_CI_AI,
SENHA  VARCHAR(10) CHARACTER SET UTF8 NOT NULL COLLATE
UNICODE_CI_AI,
CODCIDADE  INTEGER,
ACESSOSISTEMA  CHAR(1) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI,
CPFVARCHAR(12) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI
);



Example
CHAR SIZE 1
in the database
'S'
In php results
'S   ' instead of 'S'
vardump (char_field)
string (4) "S   "

(Both ibase_query as PDO)

Its a configuration problem, bug or not full support to UFT-8?

Thank you very much!


[PHP-DB] Re: Re

2016-10-18 Thread Jigme Datse Yli-Rasku
Something up here...  Probably not fixable by me.  But this is the second of 
what appear to be identical messages. 
On 2016-10-17 23:51, php-db@lists.php.net wrote:
> "Re: [PHP-DB] SQL Injection"
> JigmeRasku doc
> <http://advancedsportstreatmentgroup.com/6QHrk9EBhrTHKZSeze9T4TYR6KHR3hE7GAfis3KN9yE98E4Fbhy4BhrTHKZSeze9T4TYR6KHR3hE7GAfis3KN9yE98E4Fbhy4/5bsSmlnbWUrRGF0c2UrWWxpLVJhc2t1/>
>

-- 
Jigme Datse Yli-Rasku
jigme.da...@datsemultimedia.com (Preferred address for new messages)
250-505-6117

Jigme Datse Yli-Rasku
PO Box 270
Rossland, BC V0G 1Y0
Canada

...
... This message should be electronically signed, and if the sender ...
... has your public key, may also be encrypted. ...
... If you have any questions about this, please email, or call. ...
... ...
... Note, unknown calls likely will go to voicemail. ...
... Please leave a message if you get voicemail. ...
...






signature.asc
Description: OpenPGP digital signature


Re: [PHP-DB] Any method to get primary key matching a given value ?

2016-10-14 Thread B. Aerts

Hi Ratin,

check out this FAQ : https://sqlite.org/faq.html#q7

SQlite has a read-only table that holds the creation query for each table.

By doing a text analysis of this query, you can find out which field is 
declared as primary key.


Regards,

Bert

On 11/10/16 02:12, Ratin wrote:

Sorry about my late reply but this was my function - a bit of a hack but
works properly on my version of php-sqlite3:


  function get_primary_key_name($table)
  {
   $primary_key='';
   $db = new MyDB();
   if(!$db)
   {
   echo $db->lastErrorMsg();
   }
   else
   {
   $qstr = "PRAGMA table_info(" . $table . ");" ;
   $query = $db->query($qstr);
   while ($result = $query->fetchArray())
   {
  if ($result['pk'] == 1)
  {
$primary_key=$result['name'];
   }
}
   }
   $db->close();
   return $primary_key;
   }


On Sat, Aug 20, 2016 at 3:35 AM, Karl DeSaulniers 
wrote:


This may also shed some light for you.
The accepted answer and possibly the one below it if you are on .NET

http://stackoverflow.com/questions/763516/information-
schema-columns-on-sqlite

HTH,

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com





On Aug 20, 2016, at 5:30 AM, Karl DeSaulniers 

wrote:


Hey Ratin,
Have you looked into the table column named 'pk' inside table_info?
That is where a column is indicated to be a primary key or not.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com 





On Aug 18, 2016, at 6:51 PM, Ratin  wrote:

Hi Karl, Thanks a lot for your response, I think  INFORMATION_SCHEMA is

not available for sqlite database. I had to built up the whole query with
php using PRAGMA table_info(tablename), looking at the pk entry, when its
1, get the column name, and then update the sql statement based on that. A
bit of work, wouldve been much simpler if a method was provided, but oh
well ..


Thanks again

Ratin

On Thu, Aug 18, 2016 at 2:53 PM, Karl DeSaulniers > wrote:

Hi Ratin,
Going to take a stab at this one.
Have you looked into INFORMATION_SCHEMA.COLUMNS for your query?
Might be where you want to look for what you are trying.
Sorry can't help more.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com 





On Aug 18, 2016, at 1:27 PM, Ratin > wrote:


I'm writing the generic get that works on different tables having

different

primary keys but the argument of get is always the primary key , i.e.

get

request is -

get (column name, value)

the value is always the primary key value.

It looks like it would be a pretty standard method but I cant find a

method

like that. Anybody have any clue?

Thanks

Ratin



--
PHP Database Mailing List (http://www.php.net/ )
To unsubscribe, visit: http://www.php.net/unsub.php <

http://www.php.net/unsub.php>








--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php







--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Any method to get primary key matching a given value ?

2016-10-10 Thread Karl DeSaulniers
You may be correct. Admittedly, I am stabbing in the dark here. I work on 
MySQL, not SQLite.
Just good at key word searches. :)  This link seems to be promising.

http://www.sqlite.org/c3ref/table_column_metadata.html

Sorry I can't help more.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com




> On Oct 10, 2016, at 7:48 PM, Ratin  wrote:
> 
> Hi Karl, Isnt it the same ? I am doing the check  if ($result['pk'] == 1),
> and you are doing  if ($result['pk'] !== null). I wanted to make sure I
> dont get false positives, what if $result['pk'] is set to zero, in your
> case it will be a match but thats probably not what we want, cuz the pk
> field is not set to 1..
> 
> Regards,
> Ratin
> 
> 
> On Mon, Oct 10, 2016 at 5:38 PM, Karl DeSaulniers 
> wrote:
> 
>> Hi Ratin,
>> I "think" you can just do this and not have to store the table name.
>> However, I have no way of testing this. You will have to test on your end.
>> 
>> while ($result = $query->fetchArray()) {
>>if ($result['pk'] !== null) {
>>$primary_key=$result['pk'];
>>}
>> }
>> 
>> Best,
>> 
>> Karl DeSaulniers
>> Design Drumm
>> http://designdrumm.com 
>> 
>> 
>> 
>> 
>>> On Oct 10, 2016, at 7:12 PM, Ratin  wrote:
>>> 
>>> Sorry about my late reply but this was my function - a bit of a hack but
>> works properly on my version of php-sqlite3:
>>> 
>>> 
>>>  function get_primary_key_name($table)
>>>  {
>>>   $primary_key='';
>>>   $db = new MyDB();
>>>   if(!$db)
>>>   {
>>>   echo $db->lastErrorMsg();
>>>   }
>>>   else
>>>   {
>>>   $qstr = "PRAGMA table_info(" . $table . ");" ;
>>>   $query = $db->query($qstr);
>>>   while ($result = $query->fetchArray())
>>>   {
>>>  if ($result['pk'] == 1)
>>>  {
>>>$primary_key=$result['name'];
>>>   }
>>>}
>>>   }
>>>   $db->close();
>>>   return $primary_key;
>>>   }
>>> 
>>> 
>>> On Sat, Aug 20, 2016 at 3:35 AM, Karl DeSaulniers > > wrote:
>>> This may also shed some light for you.
>>> The accepted answer and possibly the one below it if you are on .NET
>>> 
>>> http://stackoverflow.com/questions/763516/information-
>> schema-columns-on-sqlite > questions/763516/information-schema-columns-on-sqlite>
>>> 
>>> HTH,
>>> 
>>> Best,
>>> 
>>> Karl DeSaulniers
>>> Design Drumm
>>> http://designdrumm.com 
>>> 
>>> 
>>> 
>>> 
 On Aug 20, 2016, at 5:30 AM, Karl DeSaulniers > > wrote:
 
 Hey Ratin,
 Have you looked into the table column named 'pk' inside table_info?
 That is where a column is indicated to be a primary key or not.
 
 Best,
 
 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com  <
>> http://designdrumm.com/ >
 
 
 
 
> On Aug 18, 2016, at 6:51 PM, Ratin  rat...@gmail.com>> wrote:
> 
> Hi Karl, Thanks a lot for your response, I think  INFORMATION_SCHEMA
>> is not available for sqlite database. I had to built up the whole query
>> with php using PRAGMA table_info(tablename), looking at the pk entry, when
>> its 1, get the column name, and then update the sql statement based on
>> that. A bit of work, wouldve been much simpler if a method was provided,
>> but oh well ..
> 
> Thanks again
> 
> Ratin
> 
> On Thu, Aug 18, 2016 at 2:53 PM, Karl DeSaulniers <
>> k...@designdrumm.com  > k...@designdrumm.com >> wrote:
> Hi Ratin,
> Going to take a stab at this one.
> Have you looked into INFORMATION_SCHEMA.COLUMNS for your query?
> Might be where you want to look for what you are trying.
> Sorry can't help more.
> 
> Best,
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com  <
>> http://designdrumm.com/ >
> 
> 
> 
> 
>> On Aug 18, 2016, at 1:27 PM, Ratin  rat...@gmail.com> >>
>> wrote:
>> 
>> I'm writing the generic get that works on different tables having
>> different
>> primary keys but the argument of get is always the primary key ,
>> i.e. get
>> request is -
>> 
>> get (column name, value)
>> 
>> the value is always the primary key value.
>> 
>> It looks like it would be a pretty standard method but I cant find a
>> method
>> like that. Anybody have any clue?
>> 
>> Thanks
>> 
>> Ratin
> 
> 
> --
> PHP 

Re: [PHP-DB] Any method to get primary key matching a given value ?

2016-10-10 Thread Ratin
Hi Karl, Isnt it the same ? I am doing the check  if ($result['pk'] == 1),
and you are doing  if ($result['pk'] !== null). I wanted to make sure I
dont get false positives, what if $result['pk'] is set to zero, in your
case it will be a match but thats probably not what we want, cuz the pk
field is not set to 1..

Regards,
Ratin


On Mon, Oct 10, 2016 at 5:38 PM, Karl DeSaulniers 
wrote:

> Hi Ratin,
> I "think" you can just do this and not have to store the table name.
> However, I have no way of testing this. You will have to test on your end.
>
> while ($result = $query->fetchArray()) {
> if ($result['pk'] !== null) {
> $primary_key=$result['pk'];
> }
> }
>
> Best,
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com 
>
>
>
>
> > On Oct 10, 2016, at 7:12 PM, Ratin  wrote:
> >
> > Sorry about my late reply but this was my function - a bit of a hack but
> works properly on my version of php-sqlite3:
> >
> >
> >   function get_primary_key_name($table)
> >   {
> >$primary_key='';
> >$db = new MyDB();
> >if(!$db)
> >{
> >echo $db->lastErrorMsg();
> >}
> >else
> >{
> >$qstr = "PRAGMA table_info(" . $table . ");" ;
> >$query = $db->query($qstr);
> >while ($result = $query->fetchArray())
> >{
> >   if ($result['pk'] == 1)
> >   {
> > $primary_key=$result['name'];
> >}
> > }
> >}
> >$db->close();
> >return $primary_key;
> >}
> >
> >
> > On Sat, Aug 20, 2016 at 3:35 AM, Karl DeSaulniers  > wrote:
> > This may also shed some light for you.
> > The accepted answer and possibly the one below it if you are on .NET
> >
> > http://stackoverflow.com/questions/763516/information-
> schema-columns-on-sqlite  questions/763516/information-schema-columns-on-sqlite>
> >
> > HTH,
> >
> > Best,
> >
> > Karl DeSaulniers
> > Design Drumm
> > http://designdrumm.com 
> >
> >
> >
> >
> > > On Aug 20, 2016, at 5:30 AM, Karl DeSaulniers  > wrote:
> > >
> > > Hey Ratin,
> > > Have you looked into the table column named 'pk' inside table_info?
> > > That is where a column is indicated to be a primary key or not.
> > >
> > > Best,
> > >
> > > Karl DeSaulniers
> > > Design Drumm
> > > http://designdrumm.com  <
> http://designdrumm.com/ >
> > >
> > >
> > >
> > >
> > >> On Aug 18, 2016, at 6:51 PM, Ratin > wrote:
> > >>
> > >> Hi Karl, Thanks a lot for your response, I think  INFORMATION_SCHEMA
> is not available for sqlite database. I had to built up the whole query
> with php using PRAGMA table_info(tablename), looking at the pk entry, when
> its 1, get the column name, and then update the sql statement based on
> that. A bit of work, wouldve been much simpler if a method was provided,
> but oh well ..
> > >>
> > >> Thanks again
> > >>
> > >> Ratin
> > >>
> > >> On Thu, Aug 18, 2016 at 2:53 PM, Karl DeSaulniers <
> k...@designdrumm.com   k...@designdrumm.com >> wrote:
> > >> Hi Ratin,
> > >> Going to take a stab at this one.
> > >> Have you looked into INFORMATION_SCHEMA.COLUMNS for your query?
> > >> Might be where you want to look for what you are trying.
> > >> Sorry can't help more.
> > >>
> > >> Best,
> > >>
> > >> Karl DeSaulniers
> > >> Design Drumm
> > >> http://designdrumm.com  <
> http://designdrumm.com/ >
> > >>
> > >>
> > >>
> > >>
> > >>> On Aug 18, 2016, at 1:27 PM, Ratin  >>
> wrote:
> > >>>
> > >>> I'm writing the generic get that works on different tables having
> different
> > >>> primary keys but the argument of get is always the primary key ,
> i.e. get
> > >>> request is -
> > >>>
> > >>> get (column name, value)
> > >>>
> > >>> the value is always the primary key value.
> > >>>
> > >>> It looks like it would be a pretty standard method but I cant find a
> method
> > >>> like that. Anybody have any clue?
> > >>>
> > >>> Thanks
> > >>>
> > >>> Ratin
> > >>
> > >>
> > >> --
> > >> PHP Database Mailing List (http://www.php.net/ 
> >)
> > >> To unsubscribe, visit: http://www.php.net/unsub.php <
> http://www.php.net/unsub.php>  http://www.php.net/unsub.php>>
> > >>
> > >>
> > >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/ )
> > To unsubscribe, visit: 

[PHP-DB] Incorporating latest version of sqlite.c and making a sqlite3.so for php

2016-10-10 Thread Ratin
Trying to build the latest released version, how should I go about doing
it? Currently I installed the php5-sqlite package on ubuntu 14.04 but its a
bit outdated and its not working correctly with the c++ library properly
(can't open the DB while c++ app is running even when both parties opened
the DB in r/w mode).  Are there any official documentation on how to build
the so for php ?

Thanks all


Ratin


Re: [PHP-DB] Any method to get primary key matching a given value ?

2016-10-10 Thread Karl DeSaulniers
Hi Ratin,
I "think" you can just do this and not have to store the table name.
However, I have no way of testing this. You will have to test on your end. 

while ($result = $query->fetchArray()) {
if ($result['pk'] !== null) {
$primary_key=$result['pk'];
}
}

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com 




> On Oct 10, 2016, at 7:12 PM, Ratin  wrote:
> 
> Sorry about my late reply but this was my function - a bit of a hack but 
> works properly on my version of php-sqlite3:
> 
>  
>   function get_primary_key_name($table)
>   {
>$primary_key='';
>$db = new MyDB();
>if(!$db)
>{
>echo $db->lastErrorMsg();
>}
>else
>{
>$qstr = "PRAGMA table_info(" . $table . ");" ;
>$query = $db->query($qstr);
>while ($result = $query->fetchArray())
>{
>   if ($result['pk'] == 1)
>   {
> $primary_key=$result['name'];
>}
> }
>}
>$db->close();
>return $primary_key;
>}
> 
> 
> On Sat, Aug 20, 2016 at 3:35 AM, Karl DeSaulniers  > wrote:
> This may also shed some light for you.
> The accepted answer and possibly the one below it if you are on .NET
> 
> http://stackoverflow.com/questions/763516/information-schema-columns-on-sqlite
>  
> 
> 
> HTH,
> 
> Best,
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com 
> 
> 
> 
> 
> > On Aug 20, 2016, at 5:30 AM, Karl DeSaulniers  > > wrote:
> >
> > Hey Ratin,
> > Have you looked into the table column named 'pk' inside table_info?
> > That is where a column is indicated to be a primary key or not.
> >
> > Best,
> >
> > Karl DeSaulniers
> > Design Drumm
> > http://designdrumm.com   > >
> >
> >
> >
> >
> >> On Aug 18, 2016, at 6:51 PM, Ratin  >> > wrote:
> >>
> >> Hi Karl, Thanks a lot for your response, I think  INFORMATION_SCHEMA is 
> >> not available for sqlite database. I had to built up the whole query with 
> >> php using PRAGMA table_info(tablename), looking at the pk entry, when its 
> >> 1, get the column name, and then update the sql statement based on that. A 
> >> bit of work, wouldve been much simpler if a method was provided, but oh 
> >> well ..
> >>
> >> Thanks again
> >>
> >> Ratin
> >>
> >> On Thu, Aug 18, 2016 at 2:53 PM, Karl DeSaulniers  >>   >> >> wrote:
> >> Hi Ratin,
> >> Going to take a stab at this one.
> >> Have you looked into INFORMATION_SCHEMA.COLUMNS for your query?
> >> Might be where you want to look for what you are trying.
> >> Sorry can't help more.
> >>
> >> Best,
> >>
> >> Karl DeSaulniers
> >> Design Drumm
> >> http://designdrumm.com   >> >
> >>
> >>
> >>
> >>
> >>> On Aug 18, 2016, at 1:27 PM, Ratin  >>>   >>> >> wrote:
> >>>
> >>> I'm writing the generic get that works on different tables having 
> >>> different
> >>> primary keys but the argument of get is always the primary key , i.e. get
> >>> request is -
> >>>
> >>> get (column name, value)
> >>>
> >>> the value is always the primary key value.
> >>>
> >>> It looks like it would be a pretty standard method but I cant find a 
> >>> method
> >>> like that. Anybody have any clue?
> >>>
> >>> Thanks
> >>>
> >>> Ratin
> >>
> >>
> >> --
> >> PHP Database Mailing List (http://www.php.net/  
> >> >)
> >> To unsubscribe, visit: http://www.php.net/unsub.php 
> >>   >> >
> >>
> >>
> >
> 
> 
> --
> PHP Database Mailing List (http://www.php.net/ )
> To unsubscribe, visit: http://www.php.net/unsub.php 
> 
> 
> 



Re: [PHP-DB] Any method to get primary key matching a given value ?

2016-10-10 Thread Ratin
Sorry about my late reply but this was my function - a bit of a hack but
works properly on my version of php-sqlite3:


  function get_primary_key_name($table)
  {
   $primary_key='';
   $db = new MyDB();
   if(!$db)
   {
   echo $db->lastErrorMsg();
   }
   else
   {
   $qstr = "PRAGMA table_info(" . $table . ");" ;
   $query = $db->query($qstr);
   while ($result = $query->fetchArray())
   {
  if ($result['pk'] == 1)
  {
$primary_key=$result['name'];
   }
}
   }
   $db->close();
   return $primary_key;
   }


On Sat, Aug 20, 2016 at 3:35 AM, Karl DeSaulniers 
wrote:

> This may also shed some light for you.
> The accepted answer and possibly the one below it if you are on .NET
>
> http://stackoverflow.com/questions/763516/information-
> schema-columns-on-sqlite
>
> HTH,
>
> Best,
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
>
>
> > On Aug 20, 2016, at 5:30 AM, Karl DeSaulniers 
> wrote:
> >
> > Hey Ratin,
> > Have you looked into the table column named 'pk' inside table_info?
> > That is where a column is indicated to be a primary key or not.
> >
> > Best,
> >
> > Karl DeSaulniers
> > Design Drumm
> > http://designdrumm.com 
> >
> >
> >
> >
> >> On Aug 18, 2016, at 6:51 PM, Ratin  wrote:
> >>
> >> Hi Karl, Thanks a lot for your response, I think  INFORMATION_SCHEMA is
> not available for sqlite database. I had to built up the whole query with
> php using PRAGMA table_info(tablename), looking at the pk entry, when its
> 1, get the column name, and then update the sql statement based on that. A
> bit of work, wouldve been much simpler if a method was provided, but oh
> well ..
> >>
> >> Thanks again
> >>
> >> Ratin
> >>
> >> On Thu, Aug 18, 2016 at 2:53 PM, Karl DeSaulniers  > wrote:
> >> Hi Ratin,
> >> Going to take a stab at this one.
> >> Have you looked into INFORMATION_SCHEMA.COLUMNS for your query?
> >> Might be where you want to look for what you are trying.
> >> Sorry can't help more.
> >>
> >> Best,
> >>
> >> Karl DeSaulniers
> >> Design Drumm
> >> http://designdrumm.com 
> >>
> >>
> >>
> >>
> >>> On Aug 18, 2016, at 1:27 PM, Ratin > wrote:
> >>>
> >>> I'm writing the generic get that works on different tables having
> different
> >>> primary keys but the argument of get is always the primary key , i.e.
> get
> >>> request is -
> >>>
> >>> get (column name, value)
> >>>
> >>> the value is always the primary key value.
> >>>
> >>> It looks like it would be a pretty standard method but I cant find a
> method
> >>> like that. Anybody have any clue?
> >>>
> >>> Thanks
> >>>
> >>> Ratin
> >>
> >>
> >> --
> >> PHP Database Mailing List (http://www.php.net/ )
> >> To unsubscribe, visit: http://www.php.net/unsub.php <
> http://www.php.net/unsub.php>
> >>
> >>
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP-DB] Corn job anomaly

2016-09-27 Thread Karl DeSaulniers
> On Sep 27, 2016, at 2:24 AM, Ford, Mike <m.f...@leedsbeckett.ac.uk> wrote:
> 
>> -Original Message-
>> From: Karl DeSaulniers [mailto:k...@designdrumm.com]
>> Sent: 25 September 2016 09:59
>> To: PHP List Database <php-db@lists.php.net>
>> Subject: Re: [PHP-DB] Corn job anomaly
>> 
>> Now I am getting an error with mysql syntax.
>> 
>> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf
>> ON cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND
>> cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND
>> otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'"
>> 
>> is giving me this error:
>>  You have an error in your SQL syntax; check the manual that
>> corresponds to your MySQL server version for the right syntax to use near
>> '\"Shipping\" AND otn.Order_Status != \"Completed\"' at line 1
> 
> I don't think INTERVAL works like that - you probably need something like:
> 
>... cf.Earliest_Pickup <= DATE_ADD(CURDATE(), INTERVAL 
> ".($Num_Days_Away+1)." DAY) AND ...
> 
> Incidentally, as I understand it CURDATE() does exactly the same as 
> DATE(NOW()), and is probably more readable.
> 
> Cheers!
> 
> Mike
> 
> --
> Mike Ford,


Hi Mike,
I figured out what was wrong with my script on that error. 
I had mysqli_real_escape_string() wrapping the whole select statement. 
The INTERVAL part I got from PHP.net and it is working just fine. Just fyi.
Once I wrapped just ($Num_Days_Away+1) part it started working.

Thanks for responding!

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Corn job anomaly

2016-09-27 Thread Ford, Mike
> -Original Message-
> From: Karl DeSaulniers [mailto:k...@designdrumm.com]
> Sent: 25 September 2016 09:59
> To: PHP List Database <php-db@lists.php.net>
> Subject: Re: [PHP-DB] Corn job anomaly
>
> Now I am getting an error with mysql syntax.
>
> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf
> ON cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND
> cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND
> otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'"
>
> is giving me this error:
>   You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use near
> '\"Shipping\" AND otn.Order_Status != \"Completed\"' at line 1

I don't think INTERVAL works like that - you probably need something like:

... cf.Earliest_Pickup <= DATE_ADD(CURDATE(), INTERVAL 
".($Num_Days_Away+1)." DAY) AND ...

Incidentally, as I understand it CURDATE() does exactly the same as 
DATE(NOW()), and is probably more readable.

Cheers!

Mike

--
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
110 Queen Square House, 80 Woodhouse Lane,
Leeds Beckett University, Leeds LS2 8NU,  United Kingdom
E & S4B: m.f...@leedsbeckett.ac.uk T: +44 113 812 4730

To view the terms under which this email is distributed, please go to:-
http://disclaimer.leedsbeckett.ac.uk/disclaimer/disclaimer.html

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-25 Thread Karl DeSaulniers
Oops. I actually ran it with single and double quotes and got the same error 
both times. I am using single quotes originally. 

I think the query is getting the \ (backslash) read literally. I did not add 
those manually. 

Best,
Karl

Sent from losPhone

> On Sep 25, 2016, at 9:17 AM, Richard 
> <inbound-lists-...@listmail.innovate.net> wrote:
> 
> 
> 
>> Date: Sunday, September 25, 2016 08:37:14 -0400
>> From: Aziz Saleh <azizsa...@gmail.com>
>> Subject: Re: [PHP-DB] Corn job anomaly
>> 
>> On Sun, Sep 25, 2016 at 4:59 AM, Karl DeSaulniers
>> <k...@designdrumm.com> wrote:
>> 
>>>> On Sep 23, 2016, at 5:38 AM, Richard wrote:
>>>> 
>>>> -- Try the mysql access and commands directly from the command
>>>>   line (using the mysql cli).
>>>> 
>>>> -- Put debug/print statements in your code so you can clearly
>>>>   see where you are getting.
>>>> 
>>>>   -- This includes printing out your mysql statements so that
>>>>  you know exactly what is being passed to mysql (both when
>>>>  you run the script by hand and via cron).
>>>> 
>>> 
>>> Thanks Richard,
>>> That got me thinking and I figured out my access issue...
>>> HALELUYA!
>>> 
>>> Now I am getting an error with mysql syntax.
>>> 
>>> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN
>>> ".FIELDS_TABLE." cf ON cf.Order_ID = otn.Order_ID WHERE
>>> cf.Earliest_Pickup >= DATE(NOW()) AND cf.Earliest_Pickup <=
>>> DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND
>>> otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'"
>>> 
>>> is giving me this error:
>>>You have an error in your SQL syntax; check the manual that
>>> corresponds to your MySQL server version for the right syntax to
>>> use near '\"Shipping\" AND otn.Order_Status != \"Completed\"' at
>>> line 1
>>> 
>>> 
>> 
>> Echo out the query, then manually run it.
>> 
> 
> Based on the quoting, it doesn't appear that the error you are
> reporting is actually based on the command syntax you are showing.
> 
> If after echoing your mysql query, so that you see all substitutions,
> you are still having trouble, then take your query apart and simplify
> it. When you get a trimmed down version to work, then add complexity.
> 
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-25 Thread Richard


> Date: Sunday, September 25, 2016 08:37:14 -0400
> From: Aziz Saleh <azizsa...@gmail.com>
> Subject: Re: [PHP-DB] Corn job anomaly
>
> On Sun, Sep 25, 2016 at 4:59 AM, Karl DeSaulniers
> <k...@designdrumm.com> wrote:
> 
>> > On Sep 23, 2016, at 5:38 AM, Richard wrote:
>> > 
>> > -- Try the mysql access and commands directly from the command
>> >line (using the mysql cli).
>> > 
>> > -- Put debug/print statements in your code so you can clearly
>> >see where you are getting.
>> > 
>> >-- This includes printing out your mysql statements so that
>> >   you know exactly what is being passed to mysql (both when
>> >   you run the script by hand and via cron).
>> > 
>> 
>> Thanks Richard,
>> That got me thinking and I figured out my access issue...
>> HALELUYA!
>> 
>> Now I am getting an error with mysql syntax.
>> 
>> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN
>> ".FIELDS_TABLE." cf ON cf.Order_ID = otn.Order_ID WHERE
>> cf.Earliest_Pickup >= DATE(NOW()) AND cf.Earliest_Pickup <=
>> DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND
>> otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'"
>> 
>> is giving me this error:
>> You have an error in your SQL syntax; check the manual that
>> corresponds to your MySQL server version for the right syntax to
>> use near '\"Shipping\" AND otn.Order_Status != \"Completed\"' at
>> line 1
>> 
>> 
>
> Echo out the query, then manually run it.
>

Based on the quoting, it doesn't appear that the error you are
reporting is actually based on the command syntax you are showing.

If after echoing your mysql query, so that you see all substitutions,
you are still having trouble, then take your query apart and simplify
it. When you get a trimmed down version to work, then add complexity.




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-25 Thread Aziz Saleh
On Sun, Sep 25, 2016 at 4:59 AM, Karl DeSaulniers 
wrote:

> > On Sep 23, 2016, at 5:38 AM, Richard  innovate.net> wrote:
> >
> >
> >
> >> Date: Friday, September 23, 2016 03:28:47 -0500
> >> From: Karl DeSaulniers 
> >>
> >> Ok, so I have run down all the possible things (that I know of)
> >> that could be keeping this from working. I have checked with my
> >> hosting service that:
> >>
> >> 1. MySQL is accessible with the original user I started with (for
> >> this case were using db123456) via ssh. 2. The cron is accessing my
> >> php script fine.
> >> 3. The cron is running the script and is attempting to access MySQL
> >> but not allowing access still.
> >>
> >> I tried running the script via ssh and it is timing out. No error
> >> of not accessing MySQL, just telling me it is timing out.  This
> >> tells me (I could be wrong) that it is in fact accessing MySQL and
> >> that my calls to MySQL are making the script time out? What bothers
> >> me is that the cron errors out saying access denied but ssh says
> >> timeout error. Does anyone have any ideas for me to try at this
> >> point? If I don't get this to work in the next couple of days, I am
> >> toast!
> >>
> >
> > -- Try the mysql access and commands directly from the command
> >line (using the mysql cli).
> >
> > -- Put debug/print statements in your code so you can clearly
> >see where you are getting.
> >
> >-- This includes printing out your mysql statements so that
> >   you know exactly what is being passed to mysql (both when
> >   you run the script by hand and via cron).
> >
>
> Thanks Richard,
> That got me thinking and I figured out my access issue... HALELUYA!
>
> Now I am getting an error with mysql syntax.
>
> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf
> ON cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND
> cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND
> otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'"
>
> is giving me this error:
> You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use near
> '\"Shipping\" AND otn.Order_Status != \"Completed\"' at line 1
>
> I think at this point my brain is fried and I am not seeing what is wrong
> with this.
> Can anyone point out my folly? My guess is it is an obvious one, but I am
> not seeing it.
>
> Thanks again for your help everyone. I think I am almost there!
>
> Best,
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Echo out the query, then manually run it.


Re: [PHP-DB] Corn job anomaly

2016-09-25 Thread Karl DeSaulniers
> On Sep 23, 2016, at 5:38 AM, Richard 
>  wrote:
> 
> 
> 
>> Date: Friday, September 23, 2016 03:28:47 -0500
>> From: Karl DeSaulniers 
>> 
>> Ok, so I have run down all the possible things (that I know of)
>> that could be keeping this from working. I have checked with my
>> hosting service that:
>> 
>> 1. MySQL is accessible with the original user I started with (for
>> this case were using db123456) via ssh. 2. The cron is accessing my
>> php script fine.
>> 3. The cron is running the script and is attempting to access MySQL
>> but not allowing access still.
>> 
>> I tried running the script via ssh and it is timing out. No error
>> of not accessing MySQL, just telling me it is timing out.  This
>> tells me (I could be wrong) that it is in fact accessing MySQL and
>> that my calls to MySQL are making the script time out? What bothers
>> me is that the cron errors out saying access denied but ssh says
>> timeout error. Does anyone have any ideas for me to try at this
>> point? If I don't get this to work in the next couple of days, I am
>> toast!
>> 
> 
> -- Try the mysql access and commands directly from the command
>line (using the mysql cli).
> 
> -- Put debug/print statements in your code so you can clearly
>see where you are getting. 
> 
>-- This includes printing out your mysql statements so that
>   you know exactly what is being passed to mysql (both when
>   you run the script by hand and via cron).
> 

Thanks Richard,
That got me thinking and I figured out my access issue... HALELUYA!

Now I am getting an error with mysql syntax.

"SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf ON 
cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND 
cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND 
otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'"

is giving me this error:
You have an error in your SQL syntax; check the manual that corresponds 
to your MySQL server version for the right syntax to use near '\"Shipping\" AND 
otn.Order_Status != \"Completed\"' at line 1

I think at this point my brain is fried and I am not seeing what is wrong with 
this. 
Can anyone point out my folly? My guess is it is an obvious one, but I am not 
seeing it.

Thanks again for your help everyone. I think I am almost there!

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-23 Thread Richard


> Date: Friday, September 23, 2016 03:28:47 -0500
> From: Karl DeSaulniers 
>
> Ok, so I have run down all the possible things (that I know of)
> that could be keeping this from working. I have checked with my
> hosting service that:
> 
> 1. MySQL is accessible with the original user I started with (for
> this case were using db123456) via ssh. 2. The cron is accessing my
> php script fine.
> 3. The cron is running the script and is attempting to access MySQL
> but not allowing access still.
> 
> I tried running the script via ssh and it is timing out. No error
> of not accessing MySQL, just telling me it is timing out.  This
> tells me (I could be wrong) that it is in fact accessing MySQL and
> that my calls to MySQL are making the script time out? What bothers
> me is that the cron errors out saying access denied but ssh says
> timeout error. Does anyone have any ideas for me to try at this
> point? If I don't get this to work in the next couple of days, I am
> toast!
> 

 -- Try the mysql access and commands directly from the command
line (using the mysql cli).

 -- Put debug/print statements in your code so you can clearly
see where you are getting. 

-- This includes printing out your mysql statements so that
   you know exactly what is being passed to mysql (both when
   you run the script by hand and via cron).




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-23 Thread Karl DeSaulniers
Ok, so I have run down all the possible things (that I know of) that could be 
keeping this from working.
I have checked with my hosting service that:

1. MySQL is accessible with the original user I started with (for this case 
were using db123456) via ssh.
2. The cron is accessing my php script fine.
3. The cron is running the script and is attempting to access MySQL but not 
allowing access still.

I tried running the script via ssh and it is timing out. No error of not 
accessing MySQL, just telling me it is timing out. 
This tells me (I could be wrong) that it is in fact accessing MySQL and that my 
calls to MySQL are making the script time out?
What bothers me is that the cron errors out saying access denied but ssh says 
timeout error.
Does anyone have any ideas for me to try at this point? If I don't get this to 
work in the next couple of days, I am toast!

TIA,

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers

> On Sep 20, 2016, at 10:09 PM, Peter Beckman  wrote:
> 
> I suspect you are taking the pipe or semicolon literally.
> 
> Drop the pipe and semicolon entirely. This should work:
> 
>/usr/bin/php5 -c /home/123456/etc/php.ini -f 
> /home/123456/data/auto_reminder.php
> 
> The "pipe" (|) in unix (and I assume this is unix) means to pipe the output
> of php5 -c config to the command "-f /home...php". Which (-f) isn't a command.
> 
> The "semicolon" (;) in unix means "do this command first; then do this 
> command"
> so in your second part it is running /home/123456/data/auto_reminder.php 
> -udb123456  after it runs php5.
> 
> Usually php5 -c php.ini will run PHP in interactive mode, and sits and
> waits for input. When run from cron, there is no input, so it dies, unable
> to pipe the output (there is none) or just run the next command.
> 
> So -- lose the pipe, lose the semicolon, just run the command above in cron
> (and on the command line) and it should "just work."
> 
> Beckman
> 
> 


Hey thanks Peter for clearing that up. Yes, I was taking the pipe and semicolon 
literally.
I have since found this out on my own that my original code works. It is as 
Richard and Bert had said.
My cron runs under the server admin user and so I have to contact my client to 
find out what that password is or change it.

Much thanks to everyone for your time and responses with my issue. You guys are 
invaluable!

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Peter Beckman

I suspect you are taking the pipe or semicolon literally.

Drop the pipe and semicolon entirely. This should work:

/usr/bin/php5 -c /home/123456/etc/php.ini -f 
/home/123456/data/auto_reminder.php

The "pipe" (|) in unix (and I assume this is unix) means to pipe the output
of php5 -c config to the command "-f /home...php". Which (-f) isn't a command.

The "semicolon" (;) in unix means "do this command first; then do this command"
so in your second part it is running 
/home/123456/data/auto_reminder.php -udb123456  after it runs php5.


Usually php5 -c php.ini will run PHP in interactive mode, and sits and
waits for input. When run from cron, there is no input, so it dies, unable
to pipe the output (there is none) or just run the next command.

So -- lose the pipe, lose the semicolon, just run the command above in cron
(and on the command line) and it should "just work."

Beckman

On Tue, 20 Sep 2016, Karl DeSaulniers wrote:


Hi Richard & Bert,
Thanks for the responses. I think I understand what you are both saying.

Not sure where my database is housed as I am using a hosting provider 
(Mediatemple)
and they allow limited access to such things or I am unaware how to access them.

For my current issue, lets just say my username is  db123456
db123456 is the root user who has access to all databases
However I am not sure if the cron job runs under this user.

This is the command line I have currently that is not working

/usr/bin/php5 -c /home/123456/etc/php.ini | -f 
/home/123456/data/auto_reminder.php

My hosting company says I can force my php.ini with -c |
but this errors out saying -f command can not be found.

I tried this:

/usr/bin/php5 -c /home/123456/etc/php.ini | /home/123456/data/auto_reminder.php

but then I get the same error I originally had saying php doesn't exist.
I tried a semicolon like I had seen on some message boards and the double &&
but still no dice.

I even tried to set the user in the args like so

/usr/bin/php5 -c /home/123456/etc/php.ini ; /home/123456/data/auto_reminder.php 
-udb123456

again, no dice.

@Bert
I think it may be that the cron is under another user and that my original CL 
works, just not sure how to find out.
I would call my hosting provider to ask, but I always get the same response ...

We don't troubleshoot peoples code it is out of our scope of support.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com





On Sep 20, 2016, at 1:07 PM, Richard  
wrote:



 Original Message 

Date: Tuesday, September 20, 2016 12:54:38 -0500
From: Karl DeSaulniers 

On Sep 20, 2016, at 7:21 AM, Richard
 wrote:





Date: Tuesday, September 20, 2016 03:26:39 -0500
From: Karl DeSaulniers 


On Sep 20, 2016, at 3:22 AM, Lester Caine 
wrote:


On 20/09/16 09:14, Karl DeSaulniers wrote:
Pardon my ignorance, but what do you mean full path?

Full path to php application.
Cron jobs run as 'root' and so need and user account settings
added manually if they do not match the 'root' environment.



OH, ok, I did read something about root earlier.
I think it was something like:

root /usr/bin/php5 /home/(directory name
removed)/auto_reminder.php

But not positive. I will have to research that more.
Thank you.




Whether cron jobs run as root or a standard user depends on how
they are set up. If set up under a user -- which is the better
approach for general use -- they will run as that user. Really only
system-type cron jobs (that require root access) should be set up
to run as root.

If you use the command:

 crontab -e

from a user account, then the crontab is set up as that user. The
first 5 fields/values are time/date related, followed by the
command to be invoked. See: man -s5 crontab  for more details.

In that case, the user that mysql sees is the user that is running
the job. So, if your mysql authentication is set to accept
connections/give access to say the user your web server is running
as (which is how php will show by default), then you will either
need to pass those credentials in your cron job php script or,
give the user that's running the cron job access.



Again, thank you for the response Richard.

Would you possibly have a link to how to set that up? I mean the
actual commands. My trouble is I don't know what commands and how
to write them. Like including a user, forcing the PHP.ini and
executing the script. All in one line. That is what I am trying to
accomplish and not sure how. Need to read up on the proper way to
do this.



The php.ini that is used will be based on the php rules for the
path(s) (and order) it searches for that file.

The user that is running the script will be the user that the cron
job is set up under. If you set up a cron job as a standard user you
can't assign it to run as a different user. If the issue is mysql
access, you do that just the way you would in a 

Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
Hi Richard & Bert,
Thanks for the responses. I think I understand what you are both saying. 

Not sure where my database is housed as I am using a hosting provider 
(Mediatemple)
and they allow limited access to such things or I am unaware how to access them.

For my current issue, lets just say my username is  db123456
db123456 is the root user who has access to all databases
However I am not sure if the cron job runs under this user.

This is the command line I have currently that is not working

/usr/bin/php5 -c /home/123456/etc/php.ini | -f 
/home/123456/data/auto_reminder.php

My hosting company says I can force my php.ini with -c |
but this errors out saying -f command can not be found.

I tried this:

/usr/bin/php5 -c /home/123456/etc/php.ini | /home/123456/data/auto_reminder.php

but then I get the same error I originally had saying php doesn't exist.
I tried a semicolon like I had seen on some message boards and the double &&
but still no dice.

I even tried to set the user in the args like so

/usr/bin/php5 -c /home/123456/etc/php.ini ; /home/123456/data/auto_reminder.php 
-udb123456

again, no dice.

@Bert  
I think it may be that the cron is under another user and that my original CL 
works, just not sure how to find out.
I would call my hosting provider to ask, but I always get the same response ... 

We don't troubleshoot peoples code it is out of our scope of support.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com




> On Sep 20, 2016, at 1:07 PM, Richard 
>  wrote:
> 
> 
> 
>  Original Message 
>> Date: Tuesday, September 20, 2016 12:54:38 -0500
>> From: Karl DeSaulniers 
>> 
>> On Sep 20, 2016, at 7:21 AM, Richard
>>  wrote:
>>> 
>>> 
>>> 
 Date: Tuesday, September 20, 2016 03:26:39 -0500
 From: Karl DeSaulniers 
 
> On Sep 20, 2016, at 3:22 AM, Lester Caine 
> wrote:
> 
>> On 20/09/16 09:14, Karl DeSaulniers wrote:
>> Pardon my ignorance, but what do you mean full path?
> Full path to php application.
> Cron jobs run as 'root' and so need and user account settings
> added manually if they do not match the 'root' environment.
> 
 
 OH, ok, I did read something about root earlier.
 I think it was something like:
 
 root /usr/bin/php5 /home/(directory name
 removed)/auto_reminder.php
 
 But not positive. I will have to research that more.
 Thank you.
 
 
>>> 
>>> Whether cron jobs run as root or a standard user depends on how
>>> they are set up. If set up under a user -- which is the better
>>> approach for general use -- they will run as that user. Really only
>>> system-type cron jobs (that require root access) should be set up
>>> to run as root.
>>> 
>>> If you use the command: 
>>> 
>>>  crontab -e
>>> 
>>> from a user account, then the crontab is set up as that user. The
>>> first 5 fields/values are time/date related, followed by the
>>> command to be invoked. See: man -s5 crontab  for more details.
>>> 
>>> In that case, the user that mysql sees is the user that is running
>>> the job. So, if your mysql authentication is set to accept
>>> connections/give access to say the user your web server is running
>>> as (which is how php will show by default), then you will either
>>> need to pass those credentials in your cron job php script or,
>>> give the user that's running the cron job access.
>>> 
>> 
>> Again, thank you for the response Richard.
>> 
>> Would you possibly have a link to how to set that up? I mean the
>> actual commands. My trouble is I don't know what commands and how
>> to write them. Like including a user, forcing the PHP.ini and
>> executing the script. All in one line. That is what I am trying to
>> accomplish and not sure how. Need to read up on the proper way to
>> do this. 
>> 
> 
> The php.ini that is used will be based on the php rules for the
> path(s) (and order) it searches for that file.
> 
> The user that is running the script will be the user that the cron
> job is set up under. If you set up a cron job as a standard user you
> can't assign it to run as a different user. If the issue is mysql
> access, you do that just the way you would in a [web]server parsed
> php file.
> 
> The script is whatever you put on the crontab line.
> 
> The script you reference from the crontab entry can be a shell script
> that does some setup, and then calls your php script.  Your php
> script can have include files (e.g., for mysql connection setup) just
> as you might have in a [web]server parsed php file.
> 
> 
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread B. Aerts

On 20/09/16 10:06, Lester Caine wrote:

On 20/09/16 06:16, Karl DeSaulniers wrote:

Was probably a newb question, however, now it is saying that my database user 
is not allowed access.
I have a mysql connection inside my script that reads the database to get user 
email addresses to send a reminder email to.

Is there supposed to be a call or directive to load mysql in my command line as 
well?
Man this is frustrating.


The user name and password you are using from the web scripts SHOULD
work in the script you are using on the cron job. Although mysql does
seem to have a few extra security features that cut in. Are they listed
in the script, or loaded from the environment ... which is of cause
different for the cron jobs ... and why you needed the full path.



Karl,

is your MySQL database located on the machine itsself where you run the 
Cron job ?
If so, does your Cron user have read/write/execute permissions on either 
the DB directory, and the DB itsself ?


Regards, Bert

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Richard


 Original Message 
> Date: Tuesday, September 20, 2016 12:54:38 -0500
> From: Karl DeSaulniers 
>
> On Sep 20, 2016, at 7:21 AM, Richard
>  wrote:
>> 
>> 
>> 
>>> Date: Tuesday, September 20, 2016 03:26:39 -0500
>>> From: Karl DeSaulniers 
>>> 
 On Sep 20, 2016, at 3:22 AM, Lester Caine 
 wrote:
 
> On 20/09/16 09:14, Karl DeSaulniers wrote:
> Pardon my ignorance, but what do you mean full path?
 Full path to php application.
 Cron jobs run as 'root' and so need and user account settings
 added manually if they do not match the 'root' environment.
 
>>> 
>>> OH, ok, I did read something about root earlier.
>>> I think it was something like:
>>> 
>>> root /usr/bin/php5 /home/(directory name
>>> removed)/auto_reminder.php
>>> 
>>> But not positive. I will have to research that more.
>>> Thank you.
>>> 
>>> 
>> 
>> Whether cron jobs run as root or a standard user depends on how
>> they are set up. If set up under a user -- which is the better
>> approach for general use -- they will run as that user. Really only
>> system-type cron jobs (that require root access) should be set up
>> to run as root.
>> 
>> If you use the command: 
>> 
>>   crontab -e
>> 
>> from a user account, then the crontab is set up as that user. The
>> first 5 fields/values are time/date related, followed by the
>> command to be invoked. See: man -s5 crontab  for more details.
>> 
>> In that case, the user that mysql sees is the user that is running
>> the job. So, if your mysql authentication is set to accept
>> connections/give access to say the user your web server is running
>> as (which is how php will show by default), then you will either
>> need to pass those credentials in your cron job php script or,
>> give the user that's running the cron job access.
>> 
> 
> Again, thank you for the response Richard.
> 
> Would you possibly have a link to how to set that up? I mean the
> actual commands. My trouble is I don't know what commands and how
> to write them. Like including a user, forcing the PHP.ini and
> executing the script. All in one line. That is what I am trying to
> accomplish and not sure how. Need to read up on the proper way to
> do this. 
> 

The php.ini that is used will be based on the php rules for the
path(s) (and order) it searches for that file.

The user that is running the script will be the user that the cron
job is set up under. If you set up a cron job as a standard user you
can't assign it to run as a different user. If the issue is mysql
access, you do that just the way you would in a [web]server parsed
php file.

The script is whatever you put on the crontab line.

The script you reference from the crontab entry can be a shell script
that does some setup, and then calls your php script.  Your php
script can have include files (e.g., for mysql connection setup) just
as you might have in a [web]server parsed php file.





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
On Sep 20, 2016, at 7:21 AM, Richard  
wrote:
> 
> 
> 
>> Date: Tuesday, September 20, 2016 03:26:39 -0500
>> From: Karl DeSaulniers 
>> 
>>> On Sep 20, 2016, at 3:22 AM, Lester Caine 
>>> wrote:
>>> 
 On 20/09/16 09:14, Karl DeSaulniers wrote:
 Pardon my ignorance, but what do you mean full path?
>>> Full path to php application.
>>> Cron jobs run as 'root' and so need and user account settings added
>>> manually if they do not match the 'root' environment.
>>> 
>> 
>> OH, ok, I did read something about root earlier.
>> I think it was something like:
>> 
>> root /usr/bin/php5 /home/(directory name removed)/auto_reminder.php
>> 
>> But not positive. I will have to research that more.
>> Thank you.
>> 
>> 
> 
> Whether cron jobs run as root or a standard user depends on how they
> are set up. If set up under a user -- which is the better approach
> for general use -- they will run as that user. Really only
> system-type cron jobs (that require root access) should be set up to
> run as root.
> 
> If you use the command: 
> 
>   crontab -e
> 
> from a user account, then the crontab is set up as that user. The
> first 5 fields/values are time/date related, followed by the command
> to be invoked. See: man -s5 crontab  for more details.
> 
> In that case, the user that mysql sees is the user that is running
> the job. So, if your mysql authentication is set to accept
> connections/give access to say the user your web server is running as
> (which is how php will show by default), then you will either need to
> pass those credentials in your cron job php script or, give the user
> that's running the cron job access.
> 

Again, thank you for the response Richard.

Would you possibly have a link to how to set that up? I mean the actual 
commands. My trouble is I don't know what commands and how to write them. Like 
including a user, forcing the PHP.ini and executing the script. All in one 
line. That is what I am trying to accomplish and not sure how. Need to read up 
on the proper way to do this. 

TIA,

Best,
Karl

Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Richard


> Date: Tuesday, September 20, 2016 03:26:39 -0500
> From: Karl DeSaulniers 
>
>> On Sep 20, 2016, at 3:22 AM, Lester Caine 
>> wrote:
>> 
>> On 20/09/16 09:14, Karl DeSaulniers wrote:
>>> Pardon my ignorance, but what do you mean full path?
>> Full path to php application.
>> Cron jobs run as 'root' and so need and user account settings added
>> manually if they do not match the 'root' environment.
>> 
> 
> OH, ok, I did read something about root earlier.
> I think it was something like:
> 
> root /usr/bin/php5 /home/(directory name removed)/auto_reminder.php
> 
> But not positive. I will have to research that more.
> Thank you.
> 
>

Whether cron jobs run as root or a standard user depends on how they
are set up. If set up under a user -- which is the better approach
for general use -- they will run as that user. Really only
system-type cron jobs (that require root access) should be set up to
run as root.

If you use the command: 

   crontab -e

from a user account, then the crontab is set up as that user. The
first 5 fields/values are time/date related, followed by the command
to be invoked. See: man -s5 crontab  for more details.

In that case, the user that mysql sees is the user that is running
the job. So, if your mysql authentication is set to accept
connections/give access to say the user your web server is running as
(which is how php will show by default), then you will either need to
pass those credentials in your cron job php script or, give the user
that's running the cron job access.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Lester Caine
On 20/09/16 09:19, Karl DeSaulniers wrote:
> The command line I am using is as follows.
> 
> /usr/bin/php5 /home/(directory name removed)/auto_reminder.php

Which runs when entered on YOUR command line, but fails in the cron job?
Something in auto_reminder.php needs replacing with the 'full' text as
it is getting information from the local user settings.

> The time stamps (minute, hour, day, etc) that precede the /usr are loaded by 
> my host. just fyi.

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
> On Sep 20, 2016, at 3:22 AM, Lester Caine  wrote:
> 
> On 20/09/16 09:14, Karl DeSaulniers wrote:
>> Pardon my ignorance, but what do you mean full path?
> Full path to php application.
> Cron jobs run as 'root' and so need and user account settings added
> manually if they do not match the 'root' environment.
> 
> -- 
> Lester Caine - G8HFL
> -


OH, ok, I did read something about root earlier.
I think it was something like:

root /usr/bin/php5 /home/(directory name removed)/auto_reminder.php

But not positive. I will have to research that more.
Thank you.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Cron job anomaly

2016-09-20 Thread Karl DeSaulniers

> On Sep 20, 2016, at 3:20 AM, Lester Caine  wrote:
> 
> On 20/09/16 09:10, Karl DeSaulniers wrote:
>> Hi Lester,
>> They are listed inside the php file.
>> 
>> The error message I get is:
>> 
>> Access denied for user '(user name removed)'@'%' to database '(database name 
>> removed)'
>> 
>> Thanks for your response.
> 
> Need a mysql guy to deal with that ;)
> I have seen it myself when trying to use mysql and it's to do with the
> 'network path' but I'm on firebird which simply uses the
> '(user name removed)'
> 
> -- 
> Lester Caine - G8HFL


G, ok, thanks for the input. (: ))

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Lester Caine
On 20/09/16 09:14, Karl DeSaulniers wrote:
> Pardon my ignorance, but what do you mean full path?
Full path to php application.
Cron jobs run as 'root' and so need and user account settings added
manually if they do not match the 'root' environment.

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Cron job anomaly

2016-09-20 Thread Lester Caine
On 20/09/16 09:10, Karl DeSaulniers wrote:
> Hi Lester,
> They are listed inside the php file.
> 
> The error message I get is:
> 
> Access denied for user '(user name removed)'@'%' to database '(database name 
> removed)'
> 
> Thanks for your response.

Need a mysql guy to deal with that ;)
I have seen it myself when trying to use mysql and it's to do with the
'network path' but I'm on firebird which simply uses the
'(user name removed)'

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
> On Sep 20, 2016, at 3:14 AM, Karl DeSaulniers  wrote:
> 
>> On Sep 20, 2016, at 3:06 AM, Lester Caine  wrote:
>> 
>> On 20/09/16 06:16, Karl DeSaulniers wrote:
>>> Was probably a newb question, however, now it is saying that my database 
>>> user is not allowed access.
>>> I have a mysql connection inside my script that reads the database to get 
>>> user email addresses to send a reminder email to.
>>> 
>>> Is there supposed to be a call or directive to load mysql in my command 
>>> line as well?
>>> Man this is frustrating.
>> 
>> The user name and password you are using from the web scripts SHOULD
>> work in the script you are using on the cron job. Although mysql does
>> seem to have a few extra security features that cut in. Are they listed
>> in the script, or loaded from the environment ... which is of cause
>> different for the cron jobs ... and why you needed the full path.
>> 
>> -- 
>> Lester Caine - G8HFL
>> -
> 
> 
> Pardon my ignorance, but what do you mean full path?
> Full path of the host name?
> 
> Best,
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com



The command line I am using is as follows.

/usr/bin/php5 /home/(directory name removed)/auto_reminder.php

The time stamps (minute, hour, day, etc) that precede the /usr are loaded by my 
host. just fyi.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
> On Sep 20, 2016, at 3:06 AM, Lester Caine  wrote:
> 
> On 20/09/16 06:16, Karl DeSaulniers wrote:
>> Was probably a newb question, however, now it is saying that my database 
>> user is not allowed access.
>> I have a mysql connection inside my script that reads the database to get 
>> user email addresses to send a reminder email to.
>> 
>> Is there supposed to be a call or directive to load mysql in my command line 
>> as well?
>> Man this is frustrating.
> 
> The user name and password you are using from the web scripts SHOULD
> work in the script you are using on the cron job. Although mysql does
> seem to have a few extra security features that cut in. Are they listed
> in the script, or loaded from the environment ... which is of cause
> different for the cron jobs ... and why you needed the full path.
> 
> -- 
> Lester Caine - G8HFL
> -


Pardon my ignorance, but what do you mean full path?
Full path of the host name?

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers

> On Sep 20, 2016, at 3:06 AM, Lester Caine  wrote:
> 
> On 20/09/16 06:16, Karl DeSaulniers wrote:
>> Was probably a newb question, however, now it is saying that my database 
>> user is not allowed access.
>> I have a mysql connection inside my script that reads the database to get 
>> user email addresses to send a reminder email to.
>> 
>> Is there supposed to be a call or directive to load mysql in my command line 
>> as well?
>> Man this is frustrating.
> 
> The user name and password you are using from the web scripts SHOULD
> work in the script you are using on the cron job. Although mysql does
> seem to have a few extra security features that cut in. Are they listed
> in the script, or loaded from the environment ... which is of cause
> different for the cron jobs ... and why you needed the full path.
> 
> -- 
> Lester Caine - G8HFL
> -

Hi Lester,
They are listed inside the php file.

The error message I get is:

Access denied for user '(user name removed)'@'%' to database '(database name 
removed)'

Thanks for your response.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Lester Caine
On 20/09/16 06:16, Karl DeSaulniers wrote:
> Was probably a newb question, however, now it is saying that my database user 
> is not allowed access.
> I have a mysql connection inside my script that reads the database to get 
> user email addresses to send a reminder email to.
> 
> Is there supposed to be a call or directive to load mysql in my command line 
> as well?
> Man this is frustrating.

The user name and password you are using from the web scripts SHOULD
work in the script you are using on the cron job. Although mysql does
seem to have a few extra security features that cut in. Are they listed
in the script, or loaded from the environment ... which is of cause
different for the cron jobs ... and why you needed the full path.

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Karl DeSaulniers
> On Sep 20, 2016, at 12:16 AM, Karl DeSaulniers  wrote:
> 
>> On Sep 19, 2016, at 6:14 AM, Richard 
>>  wrote:
>> 
>> 
>> 
>>> Date: Monday, September 19, 2016 03:26:54 -0500
>>> From: Karl DeSaulniers 
>>> 
>>> I am hoping someone can enlighten me on this issue I am having.
>>> I am trying to set up a cron job to run a php file.
>>> I am getting a strange error though.
>>> 
>>> /home/(protected directory)/auto_reminder.php: line 1: ?php: No
>>> such file or directory /home/(protected
>>> directory)/auto_reminder.php: line 2: =: command not found
>>> /home/(protected directory)/auto_reminder.php: line 3: /*WordPress:
>>> No such file or directory
>>> 
>>> This is lines 1, 2 and 3 from my code.
>>> 
>>> >> $error_log = "";
>>> /*WordPress Optons Table*/
>>> 
>>> Am I correct in thinking that the error is saying that php doesn't
>>> exist? Has anyone ever experienced this? Is this a server related
>>> issue? Any clue on how to fix?
>> 
>> What do you have on the "command-line" part of your crontab entry?
>> Your php script will need to be called as a php cgi or cli. Because
>> of the way things get set up via cron, it's best to include the full
>> path to the php binary on the cron command-line.
>> 
> 
> Hey thanks Richard. That was the problem.
> Sorry, I am new to command line and cron jobs. 
> Was probably a newb question, however, now it is saying that my database user 
> is not allowed access.
> I have a mysql connection inside my script that reads the database to get 
> user email addresses to send a reminder email to.
> 
> Is there supposed to be a call or directive to load mysql in my command line 
> as well?
> Man this is frustrating.
> 
> Much thanks for your input!
> 
> Best,
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
> 

Heh, I just noticed the subject line. Got to love auto-correct!
I feel like a corn job at this point...  (:  /)

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL two tables and an uneven number of rows

2016-09-19 Thread Karl DeSaulniers
Thanks Bert,
Sorry for late response, but I had to step away from this for a moment to work 
on other things.
Will most likely be back though as things are not working still.

Thank you for your responses.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com




> On Sep 13, 2016, at 2:15 AM, B. Aerts  wrote:
> 
> On 13/09/16 08:42, Karl DeSaulniers wrote:
>>> On Sep 12, 2016, at 2:53 PM, B. Aerts  wrote:
>>> 
>>> On 12/09/16 05:24, Karl DeSaulniers wrote:
 Hello All,
 Hoping you can help clear my head on this. I have two MySQL tables for 
 custom fields data to be stored.
 
custom_fields   custom_fields_meta
 
 custom_fields is the info for the actual field displayed in the html and 
 custom_fields_meta is the data stored from entering a value on said field 
 in the form.
 
 Custom fields can be added and removed at will by the user and so when for 
 instance, adding a field,
 it currently creates an uneven number of rows in the custom_fields_meta if 
 there were any entries with fields create prior to this new one.
 
 Currently I have this code:
 
 $SQL = "SELECT ft.*, mt.Meta_Value
FROM `CUSTOM_FIELDS` ft
LEFT JOIN `CUSTOM_FIELDS_META` mt
ON mt.Field_ID = ft.Field_ID
WHERE mt.Order_ID=%d
ORDER BY ft.Field_ID ASC";
 
 I have tried JOIN, FULL JOIN, FULL OUTER JOIN, OUTER JOIN and LEFT JOIN.
 If I manually put in the missing rows in the meta table, left join works.
 However, manually updating prior entries is not going to happen.
 
 So my question is how do I get all the table rows in both tables even if 
 there is not a row to match on the meta table?
 or
 How would I update the prior entries to include this new field in the meta 
 table and keep things orderly?
 The meta is stored per order id and so there is groups of meta data per 
 order id. I would like to avoid scattered data.
 Is there a way to push the index down to fit them in or is this just going 
 to be too costly on server resources?
 
 TIA,
 
 Best,
 
 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com 
 
 
 
 
 
>>> Hi Karl,
>>> 
>>> I can't really follow your problem ... Any chance to post 2 dummy table 
>>> layouts to show what you want, and what you get ?
>>> 
>>> And it isn't something you could solve with a UNION ?
>>> 
>>> 
>> 
>> 
>> Hello,
>> Thanks fro your reply. I can try. :)
>> 
>> BEFORE:
>> 
>> CUSTOM_FIELDS:
>> 
>> `Field_ID`, `Field_Group`, `Field_Label`, `Field_Name`, `Field_Slug`, 
>> `Field_Type`, `Field_Description`, `Field_Values`, `Field_Display`, 
>> `Field_Required`, `Field_Date_Created`
>> ||
>> (1, 'Pickup Info', 'Phone 1', 'Origin_Phone1', 'origin-phone1', 'phone', 
>> 'Pickup Main phone number', '', 'Yes', 'No', '2015-04-19 08:46:10'),
>> (2, 'Pickup Info', 'Phone 2', 'Origin_Phone2', 'origin-phone2', 'phone', 
>> 'Pickup alternate phone number 1', '', 'Yes', 'No', '2015-04-19 08:46:11'),
>> (3, 'Pickup Info', 'Phone 3', 'Origin_Phone3', 'origin-phone3', 'phone', 
>> 'Pickup alternate phone number 2', '', 'Yes', 'No', '2015-04-19 08:46:12')
>> 
>> CUSTOM_FIELDS_META:
>> 
>> `Meta_ID`, `Field_ID`, `Order_ID`, `Meta_Value`
>> |—|
>> (1, 1, 1003, '555-123-4567'),
>> (2, 2, 1003, ''),
>> (3, 3, 1003, '')
>> 
>> 
>> Then lets say the user wants to add a cell phone field.
>> 
>> AFTER:
>> 
>> CUSTOM_FIELDS:
>> 
>> `Field_ID`, `Field_Group`, `Field_Label`, `Field_Name`, `Field_Slug`, 
>> `Field_Type`, `Field_Description`, `Field_Values`, `Field_Display`, 
>> `Field_Required`, `Field_Date_Created`
>> ||
>> (1, 'Pickup Info', 'Phone 1', 'Origin_Phone1', 'origin-phone1', 'phone', 
>> 'Pickup Main phone number', '', 'Yes', 'No', '2015-04-19 08:46:10'),
>> (2, 'Pickup Info', 'Phone 2', 'Origin_Phone2', 'origin-phone2', 'phone', 
>> 'Pickup alternate phone number 1', '', 'Yes', 'No', '2015-04-19 08:46:11'),
>> (3, 'Pickup Info', 'Phone 3', 'Origin_Phone3', 'origin-phone3', 'phone', 
>> 'Pickup alternate phone number 2', '', 'Yes', 'No', '2015-04-19 08:46:12'),
>> (4, 'Pickup Info', 'Cell', 'Origin_Cell', 'origin-cell', 'phone', 'Pickup 
>> cell phone number', '', 'Yes', 'No', '2015-04-19 08:46:13')
>> 
>> CUSTOM_FIELDS_META:
>> 
>> `Meta_ID`, `Field_ID`, `Order_ID`, `Meta_Value`
>> |—|
>> (1, 1, 1003, '555-123-4567'),
>> (2, 2, 1003, ''),
>> (3, 3, 1003, '')
>> 
>> The 4th field id is not in the meta table. So when I read out what is in the 
>> custom fields and matching meta data, cell phone does not show up for order 
>> that were processed before adding the custom field cell 

Re: [PHP-DB] Corn job anomaly

2016-09-19 Thread Karl DeSaulniers
> On Sep 19, 2016, at 6:14 AM, Richard 
>  wrote:
> 
> 
> 
>> Date: Monday, September 19, 2016 03:26:54 -0500
>> From: Karl DeSaulniers 
>> 
>> I am hoping someone can enlighten me on this issue I am having.
>> I am trying to set up a cron job to run a php file.
>> I am getting a strange error though.
>> 
>> /home/(protected directory)/auto_reminder.php: line 1: ?php: No
>> such file or directory /home/(protected
>> directory)/auto_reminder.php: line 2: =: command not found
>> /home/(protected directory)/auto_reminder.php: line 3: /*WordPress:
>> No such file or directory
>> 
>> This is lines 1, 2 and 3 from my code.
>> 
>> > $error_log = "";
>> /*WordPress Optons Table*/
>> 
>> Am I correct in thinking that the error is saying that php doesn't
>> exist? Has anyone ever experienced this? Is this a server related
>> issue? Any clue on how to fix?
> 
> What do you have on the "command-line" part of your crontab entry?
> Your php script will need to be called as a php cgi or cli. Because
> of the way things get set up via cron, it's best to include the full
> path to the php binary on the cron command-line.
> 

Hey thanks Richard. That was the problem.
Sorry, I am new to command line and cron jobs. 
Was probably a newb question, however, now it is saying that my database user 
is not allowed access.
I have a mysql connection inside my script that reads the database to get user 
email addresses to send a reminder email to.

Is there supposed to be a call or directive to load mysql in my command line as 
well?
Man this is frustrating.

Much thanks for your input!

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Corn job anomaly

2016-09-19 Thread Richard


> Date: Monday, September 19, 2016 03:26:54 -0500
> From: Karl DeSaulniers 
>
> I am hoping someone can enlighten me on this issue I am having.
> I am trying to set up a cron job to run a php file.
> I am getting a strange error though.
> 
> /home/(protected directory)/auto_reminder.php: line 1: ?php: No
> such file or directory /home/(protected
> directory)/auto_reminder.php: line 2: =: command not found
> /home/(protected directory)/auto_reminder.php: line 3: /*WordPress:
> No such file or directory
> 
> This is lines 1, 2 and 3 from my code.
> 
>  $error_log = "";
> /*WordPress Optons Table*/
> 
> Am I correct in thinking that the error is saying that php doesn't
> exist? Has anyone ever experienced this? Is this a server related
> issue? Any clue on how to fix?

What do you have on the "command-line" part of your crontab entry?
Your php script will need to be called as a php cgi or cli. Because
of the way things get set up via cron, it's best to include the full
path to the php binary on the cron command-line.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] ANN: PHP Generator 16.9 released

2016-09-19 Thread SQL Maestro Group

Hi!

SQL Maestro Group announces the release of PHP Generator 16.9, a family of 
GUI frontends for Windows that allow you to generate feature-rich CRUD web 
applications for your databases. There are versions for MySQL, MS SQL 
Server, PostgreSQL, Oracle, SQLite, Firebird, DB2, SQL Anywhere and MaxDB.

http://www.sqlmaestro.com/news/company/php_generators_16_9_released/

Online demos:
http://demo.sqlmaestro.com/feature_demo/
http://demo.sqlmaestro.com/nba/

Top 20 new features:


1. Column Filtering.
2. Custom Form Layouts.
3. Enhanced Master/Detail Views.
4. Record comparison.
5. Multi-Row Column Headers.
6. Breadcrumb navigation.
7. Automatic generation of index pages.
8. On-the-Fly Adding New Items to Lookup Controls.
9. Improved Filter Builder.
10. Quick Edit.
11. Adding multiple records from a single Insert form.
12. Geo Charts.
13. Permissions and RLS for all-level Details.
14. Flexible card views.
15. Enhanced JavaScript API.
16. OnGetCustomExportOptions event.
17. OnGetCustomUploadFileName event.
18. Built-in Lightbox component for external images.
19. Simple Data Grid Styling.
20. A number of GUI improvements.

Background information:
---
SQL Maestro Group offers complete database management and web development 
tools for MySQL, SQL Server, PostgreSQL, Oracle, DB2, SQLite, SQL Anywhere, 
Firebird and MaxDB providing the highest performance, scalability and 
reliability to meet the requirements of today's database applications.


Sincerely yours,
The SQL Maestro Group Team
http://www.sqlmaestro.com 



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Corn job anomaly

2016-09-19 Thread Karl DeSaulniers
I am hoping someone can enlighten me on this issue I am having.
I am trying to set up a cron job to run a php file.
I am getting a strange error though.

/home/(protected directory)/auto_reminder.php: line 1: ?php: No such file or 
directory
/home/(protected directory)/auto_reminder.php: line 2: =: command not found
/home/(protected directory)/auto_reminder.php: line 3: /*WordPress: No such 
file or directory

This is lines 1, 2 and 3 from my code.

http://designdrumm.com 






Re: [PHP-DB] MySQL two tables and an uneven number of rows

2016-09-13 Thread B. Aerts

On 13/09/16 08:42, Karl DeSaulniers wrote:

On Sep 12, 2016, at 2:53 PM, B. Aerts  wrote:

On 12/09/16 05:24, Karl DeSaulniers wrote:

Hello All,
Hoping you can help clear my head on this. I have two MySQL tables for custom 
fields data to be stored.

custom_fields   custom_fields_meta

custom_fields is the info for the actual field displayed in the html and 
custom_fields_meta is the data stored from entering a value on said field in 
the form.

Custom fields can be added and removed at will by the user and so when for 
instance, adding a field,
it currently creates an uneven number of rows in the custom_fields_meta if 
there were any entries with fields create prior to this new one.

Currently I have this code:

$SQL = "SELECT ft.*, mt.Meta_Value
FROM `CUSTOM_FIELDS` ft
LEFT JOIN `CUSTOM_FIELDS_META` mt
ON mt.Field_ID = ft.Field_ID
WHERE mt.Order_ID=%d
ORDER BY ft.Field_ID ASC";

I have tried JOIN, FULL JOIN, FULL OUTER JOIN, OUTER JOIN and LEFT JOIN.
If I manually put in the missing rows in the meta table, left join works.
However, manually updating prior entries is not going to happen.

So my question is how do I get all the table rows in both tables even if there 
is not a row to match on the meta table?
or
How would I update the prior entries to include this new field in the meta 
table and keep things orderly?
The meta is stored per order id and so there is groups of meta data per order 
id. I would like to avoid scattered data.
Is there a way to push the index down to fit them in or is this just going to 
be too costly on server resources?

TIA,

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com 






Hi Karl,

I can't really follow your problem ... Any chance to post 2 dummy table layouts 
to show what you want, and what you get ?

And it isn't something you could solve with a UNION ?





Hello,
Thanks fro your reply. I can try. :)

BEFORE:

CUSTOM_FIELDS:

`Field_ID`, `Field_Group`, `Field_Label`, `Field_Name`, `Field_Slug`, 
`Field_Type`, `Field_Description`, `Field_Values`, `Field_Display`, 
`Field_Required`, `Field_Date_Created`
||
(1, 'Pickup Info', 'Phone 1', 'Origin_Phone1', 'origin-phone1', 'phone', 
'Pickup Main phone number', '', 'Yes', 'No', '2015-04-19 08:46:10'),
(2, 'Pickup Info', 'Phone 2', 'Origin_Phone2', 'origin-phone2', 'phone', 
'Pickup alternate phone number 1', '', 'Yes', 'No', '2015-04-19 08:46:11'),
(3, 'Pickup Info', 'Phone 3', 'Origin_Phone3', 'origin-phone3', 'phone', 
'Pickup alternate phone number 2', '', 'Yes', 'No', '2015-04-19 08:46:12')

CUSTOM_FIELDS_META:

`Meta_ID`, `Field_ID`, `Order_ID`, `Meta_Value`
|—|
(1, 1, 1003, '555-123-4567'),
(2, 2, 1003, ''),
(3, 3, 1003, '')


Then lets say the user wants to add a cell phone field.

AFTER:

CUSTOM_FIELDS:

`Field_ID`, `Field_Group`, `Field_Label`, `Field_Name`, `Field_Slug`, 
`Field_Type`, `Field_Description`, `Field_Values`, `Field_Display`, 
`Field_Required`, `Field_Date_Created`
||
(1, 'Pickup Info', 'Phone 1', 'Origin_Phone1', 'origin-phone1', 'phone', 
'Pickup Main phone number', '', 'Yes', 'No', '2015-04-19 08:46:10'),
(2, 'Pickup Info', 'Phone 2', 'Origin_Phone2', 'origin-phone2', 'phone', 
'Pickup alternate phone number 1', '', 'Yes', 'No', '2015-04-19 08:46:11'),
(3, 'Pickup Info', 'Phone 3', 'Origin_Phone3', 'origin-phone3', 'phone', 
'Pickup alternate phone number 2', '', 'Yes', 'No', '2015-04-19 08:46:12'),
(4, 'Pickup Info', 'Cell', 'Origin_Cell', 'origin-cell', 'phone', 'Pickup cell 
phone number', '', 'Yes', 'No', '2015-04-19 08:46:13')

CUSTOM_FIELDS_META:

`Meta_ID`, `Field_ID`, `Order_ID`, `Meta_Value`
|—|
(1, 1, 1003, '555-123-4567'),
(2, 2, 1003, ''),
(3, 3, 1003, '')

The 4th field id is not in the meta table. So when I read out what is in the 
custom fields and matching meta data, cell phone does not show up for order 
that were processed before adding the custom field cell phone. I am trying to 
show the cell phone field on old orders as well even if there is not a row 
representing data in the meta table.

Hope that clears it up and not mud it up.. :P

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com



Hi Karl,

indeed this should work with a left JOIN. Did a quick test in SQLite, 
and got this to work (just to indicate that your principle is correct) :


sqlite> select * from table1 ;
1|100
2|200
4|400
sqlite> select * from table2 ;
1|1000
2|2000
3|3000
sqlite> select * from table1 join table2 on table1.ID = table2.ID ;
1|100|1|1000
2|200|2|2000
sqlite> select * from table1 left join table2 on table1.ID = table2.ID ;
1|100|1|1000
2|200|2|2000
4|400||
sqlite> select * from table1 right join table2 on table1.ID = table2.ID;

  1   2   3   4   5   6   7   8   9   10   >