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

2012-03-31 Thread Gonzalo
Why don´t you echo the $sql2 to see the query. That´s would be very
helpful. Also, are you closing the ')' in the 'values'?

Greetings

On Fri, Mar 30, 2012 at 3:55 PM, Gavin gavin.chalk...@gmail.com wrote:

 |DATE| 
 http://dev.mysql.com/doc/**refman/5.5/en/datetime.htmlhttp://dev.mysql.com/doc/refman/5.5/en/datetime.html
 = MySQL permits some keywords to be used as unquoted identifiers because
 many people previously used them. Examples are those in the following list:

  *

   |ACTION|

  *

   |BIT| 
 http://dev.mysql.com/doc/**refman/5.5/en/numeric-types.**htmlhttp://dev.mysql.com/doc/refman/5.5/en/numeric-types.html
 

  *

   |DATE| 
 http://dev.mysql.com/doc/**refman/5.5/en/datetime.htmlhttp://dev.mysql.com/doc/refman/5.5/en/datetime.html
 

  *

   |ENUM| 
 http://dev.mysql.com/doc/**refman/5.5/en/enum.htmlhttp://dev.mysql.com/doc/refman/5.5/en/enum.html
 

  *

   |NO|

  *

   |TEXT| 
 http://dev.mysql.com/doc/**refman/5.5/en/blob.htmlhttp://dev.mysql.com/doc/refman/5.5/en/blob.html
 

  *

   |TIME| 
 http://dev.mysql.com/doc/**refman/5.5/en/time.htmlhttp://dev.mysql.com/doc/refman/5.5/en/time.html
 

  *

   |TIMESTAMP| 
 http://dev.mysql.com/doc/**refman/5.5/en/datetime.htmlhttp://dev.mysql.com/doc/refman/5.5/en/datetime.html
 

 Best Regards,

 Gavin


 On 30/03/2012 19:48, Lars Nielsen wrote:

 fre, 30 03 2012 kl. 20:00 +0200, skrev Matijn Woudt:

 On Fri, Mar 30, 2012 at 7:49 PM, Jim Ginerjim.giner@**
 albanyhandball.com jim.gi...@albanyhandball.com  wrote:

 Jim Ginerjim.giner@**albanyhandball.comjim.gi...@albanyhandball.com
  wrote in message
 news:**E44A0D84E492452DAB2BDEBC4C4B8A**58@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 ?)

  Hi,

 Have you tried to write out the generated sql with var_dump() and then
 feed it to an SQL interface? By using Mysql Query Browser you can easily
 check it the sql-string is correct.

 Regards
 Lars Nielsenl...@lfweb.dk
 LFWeb



 --
 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 Jim Giner
I agree with Martin's assessment.  Took me awhile to always remember to have 
the date in the correct format. 



-- 
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 Ethan Rosenberg

At 07:15 PM 3/29/2012, Matijn Woudt wrote:

On Fri, Mar 30, 2012 at 1:10 AM, Ethan Rosenberg eth...@earthlink.net 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 br /;
 Â  Â $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 tr\n;

 echo td $Indx /td\n;
 echo td $Site /td\n;
 echo td $MedRec /td\n;
 echo td $Notes /td\n;
 echo td $Weight /td\n;
 echo td $BMI /td\n;
 echo td $Date /td\n;

 echo /tr\n;
 echo /table;

 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

==
Martijn  Jim -

Thanks.

I made the suggested changes.  The date still is not in the database.

Advice and help, please.

Ethan 




--
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 Jim Giner

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

Tru dat.  But mySql doesn't want the dashes embedded.  The format string 
should be Ymd instead.



-- 
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 Ethan Rosenberg

See below-
- Original Message - From: Ethan Rosenberg eth...@earthlink.net
Newsgroups: php.db
To: Matijn Woudt tijn...@gmail.com
Cc: php-db-lists.php.net 
php-db@lists.php.net; jim.gi...@albanyhandball.com

Sent: Friday, March 30, 2012 1:00 PM
Subject: Re: [PHP-DB] search of data base - again


At 07:15 PM 3/29/2012, Matijn Woudt wrote:

On Fri, Mar 30, 2012 at 1:10 AM, Ethan Rosenberg eth...@earthlink.net 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 br /;
 Â  Â $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 tr\n;

 echo td $Indx /td\n;
 echo td $Site /td\n;
 echo td $MedRec /td\n;
 echo td $Notes /td\n;
 echo td $Weight /td\n;
 echo td $BMI /td\n;
 echo td $Date /td\n;

 echo /tr\n;
 echo /table;

 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

==
Martijn  Jim -

Thanks.

I made the suggested changes.  The date still is not in the database.

Advice and help, please.

Ethan

===
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 




--
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 Jim Giner

===
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?





--
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 Jim Giner

Jim Giner jim.gi...@albanyhandball.com 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.



-- 
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 jim.gi...@albanyhandball.com wrote:

 Jim Giner jim.gi...@albanyhandball.com 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 eth...@earthlink.net 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 br /;
    $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 tr\n;

 echo td $Indx /td\n;
 echo td $Site /td\n;
 echo td $MedRec /td\n;
 echo td $Notes /td\n;
 echo td $Weight /td\n;
 echo td $BMI /td\n;
 echo td $Date /td\n;

 echo /tr\n;
 echo /table;

 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