Re: [PHP-DB] Subject Matter

2013-08-27 Thread Matijn Woudt
Op 27 aug. 2013 18:06 schreef "Daniel Brown"  het
volgende:
>
> On Fri, Aug 23, 2013 at 4:21 AM, Matijn Woudt  wrote:
> >
> > The problem is: there is no maintainer;)
>
> Sure there is.
>
> --
> 
> Network Infrastructure Manager
> http://www.php.net/

Uh, you're right. I meant moderator..


Re: [PHP-DB] Subject Matter

2013-08-23 Thread Matijn Woudt
On Fri, Aug 23, 2013 at 10:15 AM, Matt Pelmear  wrote:

> Hello all,
>
> I am subscribed to this list because of my interest in PHP's database
> integration. At this point only a small percentage of the messages are
> related to that.
>
> I am not sure who runs the list, whether they care about off-topic posts,
> or whether anyone else cares about it.
>
> I, however, do.
>
> Therefore, I would like to ask the group whether anyone else cares about
> this, or whether I should simply unsubscribe to reduce clutter in my inbox.
> One way or the other I would like to receive only messages of interest to
> me (i.e., those pertaining to the subject matter of the list I subscribed
> to).
>
> Thoughts appreciated.
>
> -Matt
>

The problem is: there is no maintainer;)


Re: [PHP-DB] oncurrence problem with PEAR:MDB2 + msqli driver in forked CLI environment

2013-07-04 Thread Matijn Woudt
On Thu, Jul 4, 2013 at 6:09 PM, Toni Moreno  wrote:

> Hi.
>
> I have a found a very strange and big "concurrence" problem after develop a
> CLI tool which  parallelizes  data processing  by using "pcntrl_fork", ( If
> we run the same executions sequentially the result is correct)
>
> The trouble appears when some of the child processes die while trying to
> access to DB , after child dies, parent process always get status  code of
> 1 or 255..
>
> We can reproduce problem but error messages are not the same always ( I
> attach 3 error log examples)
>
> It seems like a previously stablished connection exists to the bd before
> forking and child processes are working all over it.
>
> Anybody can say me  how can I force child processes to make their own new
> connections  to de BBDD ?
>
>
> Lots of Thanks!!
>
>
First of all, PHP is probably not the right language to do data processing,
but that's up to you.
Second, pcntl_fork is pretty experimental stuff, it's not very stable.

Now to answer your question, it's hard to say without seeing the code, but
I would suspect you only create the database connection once, and use it
from all forks.
The correct way is to create 1 connection per thread, so the threads will
not interfere with each other.

Hope this helps, if not, please show us a small example that demonstrates
the problem.

Regards,

Matijn


Re: [PHP-DB] Problem with query

2013-06-23 Thread Matijn Woudt
On Sun, Jun 23, 2013 at 8:31 PM, Ethan Rosenberg, PhD <
erosenb...@hygeiabiomedical.com> wrote:

> Dear List -
>
> There is an error in my query, and I cannot find it.
>
> This fails:
>
> $_SESSION['Cust_Num'] = $_REQUEST['cnum'];
> $_SESSION['CustNum'] = $_REQUEST['cnum'];
>
> echo "session"; //this has the proper values
> print_r($_SESSION);
>
> $sql10 = "select Balance, Payments, Charges, Date from Charges where
> Cust_Num = $_SESSION[Cust_Num] order by Date";
> echo $sql10; //echos the correct query
> $result10 = mysqli_query($cxn, $sql10);
> var_dump($result1); // this returns NULL
> echo "Current Results";
> echo "";
> echo " frame='box'>";
> echo "";
> echo "Balance";
> echo "Payments";
> echo "Charges";
> echo "Date";
> echo "";
> echo "row1";
>

$row10 is undefined here, so:
$row10 = mysqli_fetch_row($result10); ?

I would suggest using
while (($row1 = mysqli_fetch_row($result1))!= 0 ) { ... }

instead of
do { ... } while (($row1 = mysqli_fetch_row($result1))!= 0 );

This avoids the need of the extra mysqli_fetch_row before the do-while loop.

- Matijn


Re: [PHP-DB] excec / query on Sqlite3

2013-05-20 Thread Matijn Woudt
On Mon, May 20, 2013 at 2:35 PM, Gilles  wrote:

> Hello,
>
> I'm not sure if it's a bug :
>
> $o_sqlite3=new SQLite3('test.sqlite');
>
> $r=$o_sqlite3->exec('');
> echo'';var_dump($r);echo'**'; // bool(true)
>
> $r=$o_sqlite3->query('');
> echo'';var_dump($r);echo'**';  // bool(false)
>
> $r=$o_sqlite3->exec(false);
> echo'';var_dump($r);echo'**';  // bool(true)
>
> $r=$o_sqlite3->query(false);
> echo'';var_dump($r);echo'**';  // bool(false)
>


It makes sense in some way, query fails because the query didn't return any
result, exec succeeds because it does not require a result. The query
itself is valid.

- Matijn


Re: [PHP-DB] Probleme upper accents

2013-04-05 Thread Matijn Woudt
On Fri, Apr 5, 2013 at 3:19 PM, Toby Hart Dyke  wrote:

>
> It looks similar to this bug: 
> http://bugs.php.net/bug.php?**id=54379- 
> possibly fixed in a later version? Your PHP is pretty elderly.
>
>   Toby
>
>
>
I would suggest to upgrade the full system.
LC_* shows the OS is using ISO-8859-1, which is extremely outdated.  It
should use UTF-8 of course, or at least the ISO-8859-15.
The database uses ISO-8859-15, and then you output it to the browser
(without converting it I assume), and you tell the browser it is UTF-8 data?

About your problem, it seems Toby is right about the bug report. It seems
it has not been fixed yet, there is a patch but devs didn't find I good
enough it. You might want to look at the options to use an ISO-8859-15
connection instead of UTF-8 while the bug has not been fixed.

- Matijn


Re: [PHP-DB] My Comments

2013-02-21 Thread Matijn Woudt
On Thu, Feb 21, 2013 at 10:08 PM, Ethan Rosenberg, PhD <
erosenb...@hygeiabiomedical.com> wrote:
>
> Dear List -
>
> I feel, and correct me if I am wrong, that a list as this or similar,
> should be devoted to help and not sarcasm.  I try to be quiet and to not
> "toot my horn", but as events have progressed, I feel I must.
> <<>>
> Ethan
>
>
Ethan,

First of all, Professors and PhD students get paid, we don't. There are
plenty of people that want to spends hours and hours with your PHP problems
if they get paid.
Second, the amount of questions on this list you ask are higher than
average.
Third, you have been given quite a lot tips on how to learn PHP better, how
to learn other things, including tips on how to make it easier for us to
answer your questions by providing better information your questions. But
somehow you seem to ignore those.

My third point is maybe the most important one. We all try to help, but if
the person asking questions does not take the effort to make it easier for
the ones that help (voluntary!), it's not worth the effort. You might have
noticed that I simply ignore the questions you ask, because of this.

- Matijn


Re: [PHP-DB] Firebird return wrong value

2013-01-18 Thread Matijn Woudt
On Fri, Jan 18, 2013 at 12:49 PM,  wrote:

> Dear List!
>
> i have a strange problem.
>
> I have a Firebird database (dialect 3). Firebird server: 2.0.6
> I create a table, and insert a row like that:
> CREATE TABLE PRICE (
>   ID INTEGER NOT NULL,
>   "NAME" VARCHAR(10),
>   COST NUMERIC(15, 2));
>
> INSERT INTO PRICE (ID, "NAME", COST)
>

You should not use double quotes around column names. Try to use backtick
operator instead:
INSERT INTO `PRICE` (`ID`, `NAME`, `COST`)
Don't know if that solves the problem, but it's atleast good practice.
Second, do you really need firebird database?
It's pretty outdated database, and there are much better alternatives.

- Matijn


Re: [PHP-DB] mysqldump

2013-01-01 Thread Matijn Woudt
On Wed, Jan 2, 2013 at 12:50 AM, Ethan Rosenberg, PhD <
erosenb...@hygeiabiomedical.com> wrote:

> Dear List -
>
> I am using the following command:
>
>  mysqldump -u root -p Store > StoreBkup.sql;
>
> to backup the database called Store.
>
> Mysql insists on giving a syntax error.
>
> Advice and help, please.
>
> Thanks.
>
> Ethan
> --
>

What error do you get, and when? There seems to be nothing wrong with the
command itself.

- Matijn


Re: [PHP-DB] Program Dies

2012-10-14 Thread Matijn Woudt
On Sun, Oct 14, 2012 at 11:57 PM, Ethan Rosenberg, PhD
 wrote:
> Dear List -
>
> Thank you ever so much for all your help.
>
> I apologize in advance for dumping all this code on you.  I cannot get any
> debugger to work for me [see my separate email on debuggers].  I placed
> numerous echo and print_r statements in the code, and could not find the
> error.
>
> The program worked perfectly previously, and now it dies.
>
> It mimic a doctor's office where a study is being performed on obesity.  The
> parameter is a calculated value called BMI.
>
> In the initial part of the program, a search is performed to obtain the
> medical record .  This works perfectly.  The second step is to obtain data
> at the patient visit, which is triggered by a button "Do you wish to enter
> visit data?"  If that button is clicked, the program returns to the original
> welcome screen.
>
> Advice and help, please.
>
> Here is the code:
>

Ethan,

I'd love to help you out, but you really can't expect anybody from
this mailing list to read through 633 lines of code...

- Matijn

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



Re: [PHP-DB] opening error messages in a new window

2012-09-26 Thread Matijn Woudt
On Wed, Sep 26, 2012 at 10:41 AM, Dr Vijay Kumar
 wrote:
> In filling a form, error messages should come in a new widow while
> retaining the  form filled on the screen. Coding in php is required.
>
> --

PHP can't do anything 'onscreen'. If you want to do anything onscreen,
you need to use javascript, probably in combination with AJAX (which
can in turn call PHP, but that's not related).
Also, you seem to have posted this message to the PHP DB list, while
it's not related to any database operation. You should've used the
php-general list.

- Matijn

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



Re: [PHP-DB] Prepared Statements Insert Problem - Any more ideas?

2012-09-02 Thread Matijn Woudt
On Sun, Sep 2, 2012 at 10:41 PM, Ethan Rosenberg, PhD
 wrote:
> On Sun, Sep 2, 2012 at 6:45 AM, Ethan Rosenberg, PhD
>  wrote:
>>
>> Dear List -
>>
>> I wish to accomplish the following with prepared statements:
>>
>>   $stmt = mysqli_stmt_init($cxn);
>>  if($stmt = mysqli_stmt_prepare($stmt, "INSERT INTO Intake3 (Site,
>> MedRec, Fname, Lname, Phone, Height, Sex, Hx, Bday, Age)
>> VALUES(?,?,?,?,?,?,?,?,?,?")!=0)
>
>
>
>> Help and advice, please.
>>
>> Ethan Rosenberg
>>
> *+
>
> Any more idead?

You're still missing the closing parenthesis here, and I told you that
mysqli_error should give you some more info. Did you try that? Your
reply with 'no error'  doesn't really make sense on it's own..

Also, IIRC, I think you need to use one extra set of parenthesis, like this:

if(($stmt = mysqli_stmt_prepare()) != 0)

- Matijn

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



Re: [PHP-DB] Prepared Statements Insert Problem

2012-09-02 Thread Matijn Woudt
On Sun, Sep 2, 2012 at 6:45 AM, Ethan Rosenberg, PhD
 wrote:
> Dear List -
>
> I wish to accomplish the following with prepared statements:
>
>   $stmt = mysqli_stmt_init($cxn);
>  if($stmt = mysqli_stmt_prepare($stmt, "INSERT INTO Intake3 (Site,
> MedRec, Fname, Lname, Phone, Height, Sex, Hx, Bday, Age)
> VALUES(?,?,?,?,?,?,?,?,?,?")!=0)
It seems you're missing a ')' here.


> Help and advice, please.
>
> Ethan Rosenberg
>

If that doesn't fix it, try printing mysqli_error($cxn) instead of "Ouch"..

- Matijn

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



Re: [PHP-DB] Stuck trying to upload and grab file name

2012-07-25 Thread Matijn Woudt
On Wed, Jul 25, 2012 at 12:21 PM, Tamara Temple
 wrote:
> Brad  wrote:
>> Here is where everything stands..   L
>>
>> http://pastie.org/4317155
>
> I feel strange bottom posting, somehow, BUT THAT'S THE RULE

It makes each individual message readable in a human readable order. That's why.


>
> You have never actually shown what your SQL statement is, because:
>
> line 33: echo '$sql';
>
> This will NOT interpolate the sql string. This is why you keep getting:
>
> line 57: array(1) { ["file"]=> array(5) { ["name"]=> string(14) 
> "emailsTest.txt" ["type"]=> string(10) "text/plain" ["tmp_name"]=> string(14) 
> "/tmp/phpcLtE6W" ["error"]=> int(0) ["size"]=> int(61) } } $sqlYou have an 
> error in your SQL syntax; check the manual that corresponds to your MySQL 
> server version for the right syntax to use near ''\' LINES TERMINATED BY 
> "\r\n" IGNORE 1 LINES' at line 3
>
> See where it says "$sqlYou have" after your vardump of $_FILES?
>
> Change:
> Line 33 to:
> echo $sql.PHP_EOL;
>
> then give it a go.

A quick guess, you probably need double escapes at OPTIONALLY ENCLOSED
BY '\\', like OPTIONALLY ENCLOSED BY ''

- Matijn

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



Re: [PHP-DB] SQL omit record if ever had value set

2012-06-18 Thread Matijn Woudt
On Mon, Jun 18, 2012 at 11:56 PM, Dee Ayy  wrote:
> I would like a query that lists records where a column has not taken
> on a specific value when grouped by another column.
>
> N  V
> n1 v1
> n1 v2
> n2 v1
> n2 v2
> n2 v3
> n3 v1
>
> If v3 has ever been set for N, do not list N.  So the result would be n1, n3
>
> If v2 has ever been set for N, do not list N.  So the result would be only n3
>
> MSSQL
>
> TIA
>

I guess this should work in MSSQL too:

SELECT N FROM table WHERE N NOT IN (SELECT N FROM table WHERE v = v3)

- Matijn

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



Re: [PHP-DB] Re: Database Problems

2012-06-17 Thread Matijn Woudt
On Sun, Jun 17, 2012 at 10:21 PM, Jim Giner
 wrote:
>
> "Ethan Rosenberg"  wrote in message
> news:0m5s00mgd2bh7...@mta1.srv.hcvlny.cv.net...
>> At 03:30 PM 6/17/2012, Jim Giner wrote:
>>>"Ethan Rosenberg"  wrote in message
>>>news:0m5r005qyzrnm...@mta6.srv.hcvlny.cv.net...
>>> > Dear List -
>>> >
>>>
>>> >
>>> > The same query in a PHP program will only give me results for MedRec
>>> > 10003
>>> >
>>>
>>>why the "where 1" clause?  Do you know what that is for?
>> =
>> Dear Jim
>>
>> Thanks
>>
>> As I understand, to enable me to concatenate phases to construct a query.
>>
>> The query does work in MySQL fro the terminal.
>>
>> Ethan
>>
>
> I don't think so.  All it does is return one record.  The where clause
> defines what you want returned.  A '1' returns one record, the first one.
> #10003
>
> I wonder why you think "where 1" enables concatenation??  A query (IN SIMPLE
> TERMS PEOPLE) is simply a SELECT ion of fields from a group of tables,with a
> WHERE clause to define the criteria to limit the rows, and an ORDER BY to
> sort the result set.  More complex queries can include GROUP BY when you are
> including summary operators such as SUM(fldname) or MAX(fldname), or a JOIN
> clause, or a host of other clauses that make sql so powerful.  In your case
> I think you copied a sample query that (they always seem to be displayed
> with a 'where 1' clause) and left the "1" on it.  To summarzie:
>
> SELECT a.fld1, a.fld2,b.fld1 from table1 as a, table2 as b WHERE a.key >100
> and a.key = b.key ORDER BY a.fld1
>
> I"m no expert, but hopefully this makes it a little less complex for you.
>

Right, Why would WHERE 1 return only 1 record? That makes no sense
and, no offense, it sounds like you really don't know where you're
talking about.

WHERE 1 is just a useless statement, but in his case makes it easier
to concatenate multiple "AND ..." statements.

As to the original problem, I guess that there might be something
wrong with your code later on that parses the result? Did you try to
use echo mysqli_num_rows($result1), just after the query to see how
many rows it returned?

- Matijn

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



Re: [PHP-DB] ERROR W/ SQLSRV, PHP 5.4 & SYMFONY!!!

2012-06-07 Thread Matijn Woudt
On Thu, Jun 7, 2012 at 7:42 AM, OJFR  wrote:
> HI,
>

> OSAIN.
>
>

Hi,

You might want to read the PHP mailing list rules[1] and RFC 1855[2]
before posting to this mailing list again.

- Matijn

[1] http://www.php.net/reST/php-src/trunk_README.MAILINGLIST_RULES
[2] http://www.faqs.org/rfcs/rfc1855.html

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



Re: [PHP-DB] Mysterious 5 second delay on sybase_connect()

2012-05-24 Thread Matijn Woudt
On Thu, May 24, 2012 at 10:51 AM, Tom Lloyd  wrote:
> Hi there.  I'm working on a PHP-driven project on Debian Squeeze that
> connects to an instance of Microsoft SQL Server on Windows Server 2008.
> I'm using the sybase extensions to PHP.
>
> Since I rebooted the webserver on the weekend, both the sybase_connect()
> and sybase_pconnect() commands will sometimes take exactly 5 seconds to
> execute.  It seems to be random whether they do this or not.  I can't
> think of anything that could have been changed by the reboot, unless a
> package was updated but its associated process never got restarted...
>
> Does anyone know what might cause this behaviour?
>
> Cheers,
> Tom Lloyd
>

It most likely has nothing to do with PHP, but is rather a routing
issue. 5 seconds is the default connection time out for TCP/IP, so it
probably makes sense that the connection is failing at a lower level.

- Matijn

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



Re: [PHP-DB] Multiple Database Connection Using Prepard Statements

2012-05-19 Thread Matijn Woudt
On Sat, May 19, 2012 at 8:36 PM, Ron Piggott
 wrote:
>
> How do I connect to multiple mySQL databases using Prepared Statements ?
>
> I have the syntax
>
> ===
> $dsh = 'mysql:host=localhost;dbname='.$database3;
> $dbh = new PDO($dsh, $username, $password);
> ===
>
> I want to connect to $database1 without loosing my $database3 connection
>

$dsh = 'mysql:host=localhost;dbname='.$database3;
$dbh = new PDO($dsh, $username, $password);
$dsh2 = 'mysql:host=localhost;dbname='.$database1;
$dbh2 = new PDO($dsh2, $username2, $password2);

Now you can use $dbh for $database3, and $dbh2 for $database1...

- Matijn

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



[PHP-DB] Re: [PHP] PHP & Database Problems -- Code Snippets

2012-05-05 Thread Matijn Woudt
On Thu, May 3, 2012 at 4:20 PM, Ethan Rosenberg  wrote:
> At 06:47 PM 5/2/2012, Matijn Woudt wrote:
>>
>> On Wed, May 2, 2012 at 11:43 PM, Ethan Rosenberg 
>> wrote: > Dear list - > > Sorry for the attachment. Â Here are code snippets
>> --- Ethan, I don't want to sound rude, but it appears to me you don't have
>> any understanding of what you're doing. It might help if you understand what
>> the code is doing... Let me explain. > > GET THE DATA FROM INTAKE3: > > Â  Â
>> function handle_data() > Â  Â { > Â  Â  Â  global $cxn; > Â  Â  Â  $query =
>> "select * from Intake3 where  1"; > > > >   Â  Â
>>  if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' ) $_Request does not
>> exists, you're looking for $_REQUEST. And why are you mixing $_REQUEST and
>> $_POST here? > Â  Â  Â  { > Â  Â  Â  Â  Â  Â if ($_REQUEST['Sex'] === "0") >
>> Â  Â  Â  Â  Â  Â { > Â  Â  Â  Â  Â  Â  Â  $sex = 'Male'; > Â  Â  Â  Â  Â  Â
>> } > Â  Â  Â  Â  Â  Â else > Â  Â  Â  Â  Â  Â { > Â  Â  Â  Â  Â  Â  Â  $sex =
>> 'Female'; > Â  Â  Â  Â  Â  Â } > Â  Â  Â  } > > Â  Â } What is the point of
>> the handle_data function above? It doesn't do anything. > Â  Â
>> $allowed_fields = array > Â  Â  Â  ( Â 'Site' =>$_POST['Site'], 'MedRec' =>
>> $_POST['MedRec'], 'Fname' => > $_POST['Fname'], 'Lname' => $_POST['Lname'] ,
>> > Â  Â  Â  Â  Â  Â  'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex'] Â ,
>> 'Height' > => $_POST['Height'] Â ); > > Â  Â if(empty($allowed_fields)) > Â
>>  Â { > Â  Â  Â  Â  Â echo "ouch"; > Â  Â } > > Â  Â $query = "select * from
>> Intake3  where  1 "; > >   Â foreach ( $allowed_fields as $key => $val )
>> > Â  Â { > Â  Â  Â  if ( (($val != '')) ) > > Â  Â { > Â  Â  Â  $query .= "
>> AND ($key  = '$val') "; >   Â } >   Â  Â  $result1 = mysqli_query($cxn,
>> $query); > Â  Â } First, this will allow SQL injections, because you insert
>> the values directly from the browser. Second, you should move the last line
>> ($result1=...), outside of the foreach loop, now you're executing the query
>> multiple times. Third, you should check if $result1 === FALSE, in case the
>> query fails > > Â  Â $num = mysqli_num_rows($result1); > Â  Â if(($num =
>> mysqli_num_rows($result1)) == 0) Doing the same thing twice? > Â  Â { > ?> >
>> Â  Â No
>> Records > Retrieved #1 >  Â  Â exit(); > Â
>>  Â } > > DISPLAY THE INPUT3 DATA: > >>>> THIS SEEMS TO BE THE ROUTINE THAT
>> IS FAILING <<< > > Â  Â Search Results > > Â
>>  Â > > Â frame="box"> > Â  Â  > Â  Â Site > Â  Â
>> Medical Record > Â  Â First Name > Â  Â Last Name
>> > Â  Â Phone > Â  Â Height > Â  Â Sex > Â  Â
>> History > Â  Â  > >  > Â  Â  Â  while ($row1 =
>> mysqli_fetch_array($result1, MYSQLI_BOTH)) > Â  Â  Â  { > Â  Â  Â  Â  Â  Â
>> print_r($_POST); Doesn't really make sense to print $_POST here.. > Â  Â  Â
>>  Â  Â  Â  Â  global $MDRcheck; > Â  Â  Â  Â  Â  Â  Â  $n1++; > Â  Â  Â  Â  Â
>>  Â  Â  echo "n1 ";echo $n1; > Â  Â  Â  Â  Â  Â { > Â  Â  Â  Â  Â
>>  Â  Â  if (($n1 > 2) && ($MDRcheck == $row1[1])) > Â  Â  Â  Â  Â  Â  Â  { >
>> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo ">2== Â "; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> echo $MDRcheck; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo " $row1[0] \n";
>> > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo " $row1[1] \n"; > Â  Â  Â  Â  Â
>>  Â  Â  Â  Â  Â echo " $row1[2] \n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> echo " $row1[3] \n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "
>> $row1[4] \n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo " $row1[5]
>> \n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo " $row1[6] \n"; > Â
>>  Â  Â  Â  Â  Â  Â  Â  Â  Â echo " $row1[7] \n"; > Â  Â  Â  Â  Â  Â
>>  Â  Â  Â  Â echo "\n"; > Â  Â  Â  Â  Â  Â  Â  } > Â  Â  Â  Â  Â  Â  Â
>>  elseif (($n1 > 2) && ($MDRcheck != $row1[1])) > Â  Â  Â  Â  Â  Â  Â  { > Â
>>  Â  Â  Â  Â  Â  Â  Â  Â  Â echo ">2!= Â "; > > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> echo $MDRcheck; > > > 

[PHP-DB] Re: [PHP] PHP & Database Problems -- Code Snippets

2012-05-02 Thread Matijn Woudt
On Wed, May 2, 2012 at 11:43 PM, Ethan Rosenberg  wrote:
> Dear list -
>
> Sorry for the attachment.  Here are code snippets ---

Ethan,

I don't want to sound rude, but it appears to me you don't have any
understanding of what you're doing. It might help if you understand
what the code is doing... Let me explain.

>
> GET THE DATA FROM INTAKE3:
>
>    function handle_data()
>    {
>       global $cxn;
>       $query = "select * from Intake3 where  1";
>
>
>
>       if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' )

$_Request does not exists, you're looking for $_REQUEST. And why are
you mixing $_REQUEST and $_POST here?

>       {
>            if ($_REQUEST['Sex'] === "0")
>            {
>               $sex = 'Male';
>            }
>            else
>            {
>               $sex = 'Female';
>            }
>       }
>
>    }

What is the point of the handle_data function above? It doesn't do anything.

>    $allowed_fields = array
>       (  'Site' =>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 'Fname' =>
> $_POST['Fname'], 'Lname' => $_POST['Lname'] ,
>             'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex']  , 'Height'
> => $_POST['Height']  );
>
>    if(empty($allowed_fields))
>    {
>          echo "ouch";
>    }
>
>    $query = "select * from Intake3  where  1 ";
>
>    foreach ( $allowed_fields as $key => $val )
>    {
>       if ( (($val != '')) )
>
>    {
>       $query .= " AND ($key  = '$val') ";
>    }
>       $result1 = mysqli_query($cxn, $query);
>    }

First, this will allow SQL injections, because you insert the values
directly from the browser.
Second, you should move the last line ($result1=...), outside of the
foreach loop, now you're executing the query multiple times.
Third, you should check if $result1 === FALSE, in case the query fails

>
>    $num = mysqli_num_rows($result1);
>    if(($num = mysqli_num_rows($result1)) == 0)

Doing the same thing twice?

>    {
> ?>
>    No Records
> Retrieved #1
>     exit();
>    }
>
> DISPLAY THE INPUT3 DATA:
>
 THIS SEEMS TO BE THE ROUTINE THAT IS FAILING <<<
>
>    Search Results
>
>      frame="box">
>    
>    Site
>    Medical Record
>    First Name
>    Last Name
>    Phone
>    Height
>    Sex
>    History
>    
>
> 
>       while ($row1 = mysqli_fetch_array($result1, MYSQLI_BOTH))
>       {
>            print_r($_POST);

Doesn't really make sense to print $_POST here..

>               global $MDRcheck;
>               $n1++;
>               echo "n1 ";echo $n1;
>            {
>               if (($n1 > 2) && ($MDRcheck == $row1[1]))
>               {
>                    echo ">2==  ";
>                    echo $MDRcheck;
>                    echo " $row1[0] \n";
>                    echo " $row1[1] \n";
>                    echo " $row1[2] \n";
>                    echo " $row1[3] \n";
>                    echo " $row1[4] \n";
>                    echo " $row1[5] \n";
>                    echo " $row1[6] \n";
>                    echo " $row1[7] \n";
>                    echo "\n";
>               }
>               elseif (($n1 > 2) && ($MDRcheck != $row1[1]))
>               {
>                    echo ">2!=  ";
>
>                    echo $MDRcheck;
>
>
>                    continue;

continue doesn't do anything here.


>               }
>               elseif ($n1 == 2)
>               {
>
>                    define( "MDR" ,  $row1[1]);
>                    echo "row1 ";echo $row1[1];
>                    echo "\n";
>
>                    $_GLOBALS['mdr']= $row1[1];
>                    $_POST['MedRec'] = $row1[1];

You're not supposed to set variables in $_POST...

>                    $MDRold = $_GLOBALS['mdr'];

It appears you want the old value of mdr, if so, then you should do
this before you set it again 2 lines above..

>                    echo " $row1[0] \n";
>                    echo " $row1[1] \n";
>                    echo " $row1[2] \n";
>                    echo " $row1[3] \n";
>                    echo " $row1[4] \n";
>                    echo " $row1[5] \n";
>                    echo " $row1[6] \n";
>                    echo " $row1[7] \n";
>                    echo "\n";
>               }
>
>            }
>       }
>
> ?>

You say this routine is probably the one that is failing.. but what is
going wrong? And how the heck are we supposed to know what this
function should do?
>
> SELECT AND DISPLAY DATA FROM VISIT3 DATABASE
>
>     $query2 = "select * from Visit3 where  1 AND (Site = 'AA')  AND (MedRec =
> $_GLOBALS[mdr])";

You're using mdr as a constant here, this will generate a warning, but
sadly enough it works.

>    $result2 = mysqli_query($cxn, $query2);

You should check if $result2 === FALSE, in case the query fails.

>    $num = mysqli_num_rows($result2);

You're counting the rows here, but you don't do anything with the result?
>
<< Snip the rest of this crappy code >>
>
> I hope this helps.
>
> Ethan
>
>

I think I made my point. I guess if I continued on the rest of the
code t

Re: [PHP-DB] Engine?

2012-04-16 Thread Matijn Woudt
On Mon, Apr 16, 2012 at 1:09 PM, Bastien  wrote:
>
>
> Bastien Koert
>
> On 2012-04-16, at 2:21 AM, Karl DeSaulniers  wrote:
>
>> On Apr 15, 2012, at 9:29 PM, Vinay Kannan wrote:
>>
>>> Hello,
>>>
>>> I've always been left wondering what Engine to use while creating tables,
>>> I've read quite a few times about the same on wiki, articles etcbut
>>> haven't actually been able to decide.
>>> I wanted to know whats the storage engine used on MySQL on big web
>>> application, the application i am developing currently, is kinda really big
>>> and data intensive, we are looking at about 1,00,000 registration atleast
>>> in the first few months, and their data lets say, each will have about
>>> 10-20 operations, accounts etc... So the data can get really big and
>>> troublesome to maintain, I am more concerned about the data safety, as in
>>> crash recovery or auto backups etc...
>>> Basically, if the MySQL DB crashes, we sholdnt be at a loss, and all the
>>> data till the very last operation should be available as a backup. Any
>>> headsup on this please?
>>>
>>>
>>> Thanks,
>>> Vinay Kannan.
>>
>>
>> Maybe google MySQL innodb.
>> I think they have rollback and table locking.
>> As well as foreign key capabilities.
>>
>> Limited exp. Sorry not much more help.
>>
>> Best,
>
> InnoDB with replication should get you close to what you need. But it sounds 
> like you are also requiring some High Availability architecture so you may 
> want to look at fail overs using Heartbeat or some other tool to 
> automatically switch over to a new master.
>
> Check out the http://www.mysql.com/products/enterprise/high_availability.html 
> or google 'MySQL high availability'
>

Or maybe you should look at a other databases than MySQL, there are a
few that scale much better. Google for scalable database, and you'll
find some.

- Matijn

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



Re: [PHP-DB] search of data base - again

2012-03-30 Thread Matijn Woudt
On Fri, Mar 30, 2012 at 7:49 PM, Jim Giner  wrote:
>
> ""Jim Giner""  wrote in message
> news:E44A0D84E492452DAB2BDEBC4C4B8A58@laptop2...
>> ===
>> Martijn & Jim -
>>
>> Is it just the date that is the problem?
>>
>> Yes.
>>
>> Tru dat.  But mySql doesn't want the dashes embedded.  The format string
>> should be "Ymd" instead.
>>
>> That's what I am doing.  No luck.
>>
>> Ethan
>>
>> *
>> You're using a format with just Ymd in it (no dashes)?  Can you post
>> *just* the query as it is looks in your php code?
>>
>>
>>
> While waiting - I looked at your code again.  What is the (greater than)
> symbol doing in front of your $Date var?
>> > Date) VALUES(null, '$Site', '$MedRec', '$Notes', $Weight, $BMI, >
>> > '$Date'";
>
> Also - is it valid to use the word 'Date' as a field name?  Just wondering.

It is valid, though It may require quotes (backtick ?)

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



Re: [PHP-DB] search of data base - again

2012-03-29 Thread Matijn Woudt
On Fri, Mar 30, 2012 at 1:10 AM, Ethan Rosenberg  wrote:
> Sending again, since no response on 1st try.
>
> Ethan
> ==
> Dear List
>
> I am trying to insert data into a table, with no success.
>
> I have two tables:
>
> mysql> describe Visit3;
> ++--+--+-+-++
> | Field  | Type         | Null | Key | Default | Extra          |
> ++--+--+-+-++
> | Indx   | int(4)       | NO   | PRI | NULL    | auto_increment |
> | Site   | varchar(6)   | YES  |     | NULL    |                |
> | MedRec | int(6)       | YES  |     | NULL    |                |
> | Notes  | text         | YES  |     | NULL    |                |
> | Weight | int(4)       | YES  |     | NULL    |                |
> | BMI    | decimal(3,1) | YES  |     | NULL    |                |
> | Date   | date         | YES  |     | NULL    |                |
> ++--+--+-+-++
>
> ++-+--+-+-+---+
> | Field  | Type        | Null | Key | Default | Extra |
> ++-+--+-+-+---+
> | Site   | varchar(6)  | NO   | PRI |         |       |
> | MedRec | int(6)      | NO   | PRI | NULL    |       |
> | Fname  | varchar(15) | YES  |     | NULL    |       |
> | Lname  | varchar(30) | YES  |     | NULL    |       |
> | Phone  | varchar(30) | YES  |     | NULL    |       |
> | Height | int(4)      | YES  |     | NULL    |       |
> | Sex    | char(7)     | YES  |     | NULL    |       |
> | Hx     | text        | YES  |     | NULL    |       |
> ++-+--+-+-+---+
>
> I calculate some values:
>
>    default_timezone_set('America/New_York');
>     $Date  = date('M d Y');
>     $sql1 = "select MedRec, Height from Intake3 where (MedRec =
> '$_POST[MedRec]')";
>     $result = mysqli_query($cxn, $sql1);
>    $row = mysqli_fetch_array($result);
>    $MedRec = $row[0];
>    $Height = $row[1];
>    $Weight = $_POST['Weight'];
>    $Notes  = $_POST['Notes'];
>    $sql4 = "select MedRec, Weight from Visit3 where (MedRec =
> $_POST[MedRec])";
>    $result4 = mysqli_query($cxn, $sql4);
>    $row4 = mysqli_fetch_array($result4);
>    $MedRec = $_POST['MedRec'];
>    $BMI = ($Weight*703)/($Height*$Height);
>    $BMI = round($BMI,1);
>    $fptr1 = fopen("/home/ethan/PHP/HRecnumSite", "r+");
>    fscanf($fptr1,"%d %s",$Num, $Site);
>    echo "$Site, $MedRec, $Notes, $Weight $BMI, $Date ";
>    $sql2 =  "INSERT INTO Visit3(Indx, Site, MedRec, Notes, Weight, BMI,
> Date) VALUES(null, '$Site', '$MedRec', '$Notes', $Weight, $BMI, '$Date'";
>    $result2 = mysqli_query($cxn, $sql2);
>
> They display properly.
>
> $sql3 = "select max(Indx) from Visit3";
> $result3 = mysqli_query($cxn, $sql3);
> var_dump($result3);
> echo "result3   ";
> print_r($result3);
> $row = mysqli_fetch_array($result3);
> $Indx = $row[0];
>
> echo "\n";
>
> echo " $Indx \n";
> echo " $Site \n";
> echo " $MedRec \n";
> echo " $Notes \n";
> echo " $Weight \n";
> echo " $BMI \n";
> echo " $Date \n";
>
> echo "\n";
> echo "";
>
> The date value is not inserted properly into the table:
>
> mysql> select * from Visit3;
> | 2416 | AA   |  10001 | uih s45t |    125 | 19.0 | -00-00 |
> | 2417 | AA   |  1 | bnkjlolk |    174 | 28.1 | -00-00 |
>
> Advice and help, please.
>
> Thanks.
>
> Ethan Rosenberg
>

I think MySQL wants the date in -M-D format, did you try changing
$Date  = date('M d Y');
to
$Date  = date('Y-m-d');

- Matijn

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



Re: [PHP-DB] Help with If else if

2012-03-13 Thread Matijn Woudt
On Tue, Mar 13, 2012 at 4:53 PM, Gu®u  wrote:
> No Michael, your code is also not working. What you have understood is
> correct. let me explain it to others too.
>
> If variable twitter and facebook are empty don't echo anything,
>
> if variable twitter has a value and facebook is empty echo out only twitter,
>
> if variable twitter has no value and facebook has a value echo out facebook
> only,
>
> and finally if both has values echo out both.
>
> Basically I want to echo out only if there is some value in the database.
> But in my case both the images are echoing out.
>

That's exactly what my code does too, except it's a bit simpler. If
mine isn't working too, then your input is probably different, try a
var_dump on the ListViewValue() items.

- Matijn

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



Re: [PHP-DB] Help with If else if

2012-03-13 Thread Matijn Woudt
On Tue, Mar 13, 2012 at 3:06 PM, Gu®u  wrote:
> The issue is both the images are echoing and no if else statement is
> working.
>

First of all, please bottom post on this (and probably any) mailing list.

You should perhaps provide what the contents of
$search->plugin->ListViewValue()=="" and
$search->facebook->ListViewValue()=="" is.
Though, if I understood you correctly, it would be as simple as:
$facebookEnabled = $search->facebook->ListViewValue()!="";
$twitterEnabled = $search->plugin->ListViewValue()!="";
if($facebookEnabled)
 {

  echo '';
 }
 if($twitterEnabled)
 {

 echo '';
 }

- Matijn

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



Re: [PHP-DB] Help with If else if

2012-03-13 Thread Matijn Woudt
On Tue, Mar 13, 2012 at 1:03 PM, Gu®u  wrote:
> Hi,
>
> Please help me with this code. I have 2 different fields in mysql table.
> What I want is if the field is empty don't show the image. Please look at
> the code below.

I have looked at it.

Maybe you should tell what is wrong, what it outputs currently, and
what it should output. Or perhaps, which errors you get if any?

- Matijn

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



Re: [PHP-DB] Select from multiple tables

2012-02-29 Thread Matijn Woudt
On Wed, Feb 29, 2012 at 3:01 PM, Kranthi Krishna  wrote:
> Hi all,
>
> Say I have an object like
>
> array
>    schoolName => string
>    board => array
>         string
>         string
>
> I generally create  two MySql tables
>
> schools: id PRIMARY KEY, SchoolName
> boards: id FOREGIN KEY refers Table A(id), board
>
> and then do two selects. The problem is that, the number of selects
> increase as the number of one-to-many relationships increase.
>
> Is there a better way to do this ? I have to extend an existing code
> so I cannot use any libraries like doctrine
>
> Kranthi.
> http://goo.gl/e6t3

You should look up at SQL joins. They will do what you want.

- Matijn

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



Re: [PHP-DB] Subscription Suspensions

2012-01-31 Thread Matijn Woudt
On Tue, Jan 31, 2012 at 6:35 PM, Ron Piggott
 wrote:
>
> Hi Everyone.
>
> I manage an e-mail list.  I am trying to add a new function into it: 
> suspensions.  The idea is that someone wouldn’t have to unsubscribe.  Instead 
> there would be a record of their suspension in the table 
> member_subscription_suspensions and their account wouldn’t be included as a 
> database query result when sending out the daily e-mail.
>
> There are three tables: Profile of the subscriber, subscriptions and 
> subscription suspensions:
>
>
> How do I change this query to exclude any one who has a suspension record for 
> “today”. IE CURDATE()
>
> Thanks for your help.  Ron
>
> Ron Piggott
>

Hi Ron,

I'm not sure why you posted your question here, it has no relation to
PHP whatsoever. And while you're not specifically asking, you cannot
assume people will start to write SQL for you.

It would've made sense if you mentioned what database you're using.
Some databases support the EXCEPT operator in SQL, though it seems
that the most popular one, MySQL, does not support it.
You can achieve the same with LEFT JOIN. Wikipedia has an example[1]
on how to replace the EXCEPT operator on databases that don't support
it.

Hope this will help you get started.

- Matijn

[1] http://en.wikipedia.org/wiki/Set_operations_(SQL)#EXCEPT_operator

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



Re: [PHP-DB] php & adodb book suggestins

2012-01-26 Thread Matijn Woudt
On Thu, Jan 26, 2012 at 12:06 PM, David McGlone  wrote:
> On Thu, 2012-01-26 at 08:45 +, Lester Caine wrote:
>> David McGlone wrote:
>> > can anyone suggest any good up to date books out there on php&  adodb.
>
>> The only documentation on ADOdb is the website
>> http://adodb.sourceforge.net/#docs ... has ANYBODY seen it described in a 
>> php book?
>> While I have bought a couple of php books, the on-line material is always 
>> more
>> up to date and asking often fills in gaps that one had not even thought of.

Yes, it is described in the book "Object-Oriented Programming with
PHP5", though it is pretty limited.

- Matijn

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



Re: [PHP-DB] Multiple Access to Database

2012-01-17 Thread Matijn Woudt
Ethan, you've send the same question a few days ago. There's no point
in asking the same question twice.

Matijn

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



Re: [PHP-DB] Set Mssql Application name in connection string

2011-12-13 Thread Matijn Woudt
On Tue, Dec 13, 2011 at 10:58 PM, Dan Rowe  wrote:
> Hey Matijn,
>
> Thanks for the tip. We did send it there the day we submitted it, so its
> good to know we were on the right track. Unfortunately it didn't gain any
> traction or any status updates on the bug tracker.
>
> Figured I would send to this list in case it was more applicable to the user
> base and now that we have had it in production for a while.

I don't think most users here know how to compile PHP from source,
which is required for your patch to be applied.

> One of those things where the time invested in trying to get it
> integrated/accepted is more then the actual development time for such a
> small patch :)
>
> Thanks again,
>
> -Dan

That's not very uncommon for open source projects, but you really
shouldn't give up on it.

Matijn

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



Re: [PHP-DB] Set Mssql Application name in connection string

2011-12-13 Thread Matijn Woudt
On Tue, Dec 13, 2011 at 1:33 PM, Dan Rowe  wrote:
> We needed to be able to set the application name in a mssql connection
> string, but php doesn't current toy support it.
>
> This can be very helpful while debugging/profiling php-mssql from the SQL
> server side of things.
>
> Without this patch all mssql connections have a hard coded application name
> of 'PHP 5'.
>
> https://bugs.php.net/bug.php?id=60124
>
> Please let me know if you have any problems applying the patch or comments
> on how we can make it better/get it added to the main codebase.
>
> Thanks,
>
> -Dan

Hi Dan,

You probably want to send this to the php-internals list instead.

Cheers,

Matijn

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



Re: [PHP-DB] Prepared Statements

2011-11-11 Thread Matijn Woudt
On Fri, Nov 11, 2011 at 5:41 PM, Ron Piggott
 wrote:
>
> I have two questions about Prepared Statements from the code below:
>
> #1:
> The purpose of the first $query is to determine if the authorization code 
> supplied is both accurate and also live
> - When the authorization code is generated it is given a time frame when it 
> must be used in.  The columns `start_date` and  `end_date` are both DATETIME. 
>  This is why I am using NOW() to check the “shelf life”.
>
> My question: Is there a better way to confirm the record was found than using:
>
> if ( $row['authorization_code'] == $authorization_code ) {

This check doesn't make sense, since you're SQL query already checks
this, and won't return rows where $row['authorization_code'] !=
$authorization_code

>
> In another way of executing a mySQL database query using PHP I can count the 
> # rows the result brought with the command “mysql_numrows”.  I don’t know how 
> to do this in Prepared Statements.  I wonder if comparing the # of rows found 
> is a better method? or what other programmers are using?

$stmt->rowCount(); will return the number of rows. I would recommend
this way of checking.

>
> #2:
> How can I tell if the UPDATE $query executed successfully?  I am wanting to 
> do something like:
>
> echo “Update Successful – No changes were required during this review”;
>
> if the UPDATE is successful --- otherwise I need to direct the user to try 
> again with a different message:
>
> echo “Update was unsuccessful – Follow this link to try again”;

$stmt->execute() will return either true or false, depending on if the
query was successfully executed. Currently, you're code will print an
error with some error info and terminate the script. You're probably
looking for something like this:
if($stmt->execute()) {
echo “Update Successful – No changes were required during this review”;
} else {
 echo “Update was unsuccessful – Follow this link to try again”;
}

>
>
>
> I am still getting use to Prepared Statements, this is why I am asking these 
> questions --- Thank you for helping me.  Ron

Hope this helps you out. Feel free to ask for more help.

Matijn

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



Re: [PHP-DB] Exporting mySQL to Excel

2011-11-09 Thread Matijn Woudt
On Thu, Nov 10, 2011 at 12:32 AM, Ron Piggott
 wrote:
>
> I am wondering how phpmyadmin makes Excel files "on the fly" --- Is it a
> class?
>

They used PHPExcel in the past, but they had to remove because of
license issues. Don't know what they're currently using, but if you
can live with LGPL, PHPExcel might be an option.

Matijn

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