Re: [PHP-DB] mysql query

2013-08-22 Thread Michael Oki
Try the insertion like this:
$sql2 = mysql_query(insert into Inventory (`UPC`
, `quant`, `manuf`, `item`, `orderpt`, `ordrpt_flag`, `stock`)
.values ('$upc', $qnt,'$mnf','$itm',
'$odrpt', '0', '$stk')  ) or die(mysql_error());

On 22 August 2013 05:10, Daniel Krook kr...@us.ibm.com wrote:

 Ethan,

 What about:

 $result2 = mysqli_query(cxn, $sql2);

 Doesn't look like you're sending it a connection link as a variable ($cxn)
 and that's passed through as a literal?




 Thanks,


 Daniel Krook
 Software Engineer, Advanced Cloud Solutions, GTS

 IBM Senior Certified IT Specialist - L3 Thought Leader
 The Open Group Certified IT Specialist - L3 Distinguished
 Cloud, Java, PHP, BlackBerry, DB2  Solaris Certified






 Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote on 08/21/2013
 11:59:19 PM:

  From: Ethan Rosenberg erosenb...@hygeiabiomedical.com
  To: Daniel Krook/White Plains/IBM@IBMUS
  Cc: PHP Database List php-db@lists.php.net
  Date: 08/21/2013 11:59 PM
  Subject: Re: [PHP-DB] mysql query
 
  On 08/21/2013 11:30 PM, Daniel Krook wrote:
  Ethan,
 
  It's hard to tell from the code formatting in your email what the
  exact problem might be, but a few reasons that this might fail in
  PHP rather than when sent to MySQL with hardcoded values:
 
  1.  var_dump/print_r $_POST to see what you're getting as input is
  what you expect (and sanitize!).
 
  2.  Check that the SQL statement concatenation in PHP is building
  the string you're expecting. It looks like you're joining 2 strings
  when defining $sql2 that doesn't leave a space between the close
  parentheses and values. Compare this against what you're sending
  on the command line.
 
  3.  Get rid of all single quotes... escape your double quotes where
  needed. This will avoid any variable-in-string interpolation errors
  and may help you find the issue with input data. Same with your echo
  $sql2 statement... that's not going to give you the same thing as
  the print_r below it.
 
 
 
  Thanks,
 
 
  Daniel Krook
  Software Engineer, Advanced Cloud Solutions, GTS
 
  IBM Senior Certified IT Specialist - L3 Thought Leader
  The Open Group Certified IT Specialist - L3 Distinguished
  Cloud, Java, PHP, BlackBerry, DB2  Solaris Certified
 
 
 
 
  Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote on 08/21/
  2013 07:48:12 PM:
 
   From: Ethan Rosenberg erosenb...@hygeiabiomedical.com
   To: PHP Database List php-db@lists.php.net
   Date: 08/21/2013 07:48 PM
   Subject: [PHP-DB] mysql query
  
   Dear List -
  
   I can't figure this out
  
   mysql describe Inventory;
   +-+-+--+-+-+---+
   | Field   | Type| Null | Key | Default | Extra |
   +-+-+--+-+-+---+
   | UPC | varchar(14) | YES  | | NULL |   |
   | quant   | int(5)  | NO   | | NULL |   |
   | manuf   | varchar(20) | YES  | | NULL |   |
   | item| varchar(50) | YES  | | NULL |   |
   | orderpt | tinyint(4)  | NO   | | NULL |   |
   | ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
   | stock   | int(3)  | YES  | | NULL |   |
   +-+-+--+-+-+---+
  
   Here are code snippets -
  
  $upc   = $_SESSION['UPC'];
  $qnt   = $_POST['quant'];
  $mnf   = $_POST['manuf'];
  $itm   = $_POST['item'];
  $odrpt = $_POST['oderpt'];
  $opf   = $_POST['ordrpt_flag'];
  $stk= $_POST['stock'];
  
  $sql2 = insert into Inventory (UPC, quant,

   manuf, item, orderpt, ordrpt_flag, stock)
.values ('$upc', $qnt,'$mnf','$itm',

   odrpt, 0, $stk);
  $result2 = mysqli_query(cxn, $sql2);
  echo '$sql2br /';
  print_r($sql2);
  echo br /$upc $qnt $mnf $itm $odrpt $opf

   $stkkbr /;
  if (!$result2)
die('Could not enter data: ' .
   mysqli_error());
  
   The mysql query fails.  I cannot figure out why.  It works from the
   command line.
  
   TIA
  
   Ethan
  
  Daniel -
 
  Thanks.
 
  Tried all  your suggestions.
 
  Sorry, no luck.
 
  Ethan


Re: [PHP-DB] mysql query

2013-08-22 Thread Vinay Kannan
 $sql2 = insert into Inventory (UPC, quant, manuf, item, orderpt,
ordrpt_flag, stock)  values ('$upc', '$qnt','$mnf','$itm', '$odrpt', 0,
$stk);

Looks like, you have the ' ' missing for $qnt and odrpt had the $ and the
'' missing.
The above query should work, I haven't tested it though.
Also for no error, have you turned off the PHP error reporting?

It probably is working on the command line, since you posted actual values
there and in the PHP code, you are using the variables which I think were
not wrapped in the query correctly?


On Thu, Aug 22, 2013 at 12:51 PM, Michael Oki mikeoki@gmail.com wrote:

 Try the insertion like this:
 $sql2 = mysql_query(insert into Inventory (`UPC`
 , `quant`, `manuf`, `item`, `orderpt`, `ordrpt_flag`, `stock`)
 .values ('$upc', $qnt,'$mnf','$itm',
 '$odrpt', '0', '$stk')  ) or die(mysql_error());

 On 22 August 2013 05:10, Daniel Krook kr...@us.ibm.com wrote:

  Ethan,
 
  What about:
 
  $result2 = mysqli_query(cxn, $sql2);
 
  Doesn't look like you're sending it a connection link as a variable
 ($cxn)
  and that's passed through as a literal?
 
 
 
 
  Thanks,
 
 
  Daniel Krook
  Software Engineer, Advanced Cloud Solutions, GTS
 
  IBM Senior Certified IT Specialist - L3 Thought Leader
  The Open Group Certified IT Specialist - L3 Distinguished
  Cloud, Java, PHP, BlackBerry, DB2  Solaris Certified
 
 
 
 
 
 
  Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote on 08/21/2013
  11:59:19 PM:
 
   From: Ethan Rosenberg erosenb...@hygeiabiomedical.com
   To: Daniel Krook/White Plains/IBM@IBMUS
   Cc: PHP Database List php-db@lists.php.net
   Date: 08/21/2013 11:59 PM
   Subject: Re: [PHP-DB] mysql query
  
   On 08/21/2013 11:30 PM, Daniel Krook wrote:
   Ethan,
  
   It's hard to tell from the code formatting in your email what the
   exact problem might be, but a few reasons that this might fail in
   PHP rather than when sent to MySQL with hardcoded values:
  
   1.  var_dump/print_r $_POST to see what you're getting as input is
   what you expect (and sanitize!).
  
   2.  Check that the SQL statement concatenation in PHP is building
   the string you're expecting. It looks like you're joining 2 strings
   when defining $sql2 that doesn't leave a space between the close
   parentheses and values. Compare this against what you're sending
   on the command line.
  
   3.  Get rid of all single quotes... escape your double quotes where
   needed. This will avoid any variable-in-string interpolation errors
   and may help you find the issue with input data. Same with your echo
   $sql2 statement... that's not going to give you the same thing as
   the print_r below it.
  
  
  
   Thanks,
  
  
   Daniel Krook
   Software Engineer, Advanced Cloud Solutions, GTS
  
   IBM Senior Certified IT Specialist - L3 Thought Leader
   The Open Group Certified IT Specialist - L3 Distinguished
   Cloud, Java, PHP, BlackBerry, DB2  Solaris Certified
  
  
  
  
   Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote on 08/21/
   2013 07:48:12 PM:
  
From: Ethan Rosenberg erosenb...@hygeiabiomedical.com
To: PHP Database List php-db@lists.php.net
Date: 08/21/2013 07:48 PM
Subject: [PHP-DB] mysql query
   
Dear List -
   
I can't figure this out
   
mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+
   
Here are code snippets -
   
   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];
   
   $sql2 = insert into Inventory (UPC,
 quant,
 
manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc',
 $qnt,'$mnf','$itm',
 
odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt
 $opf
 
$stkkbr /;
   if (!$result2)
  

[PHP-DB] Re: mysql query

2013-08-22 Thread Jim Giner

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt $opf
$stkkbr /;
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan



Ethan - you are simply missing two dollar signs as pointed out.  Once 
you correct them, if there are any more errors you should then be seeing 
the message from mysqli_error.


And as for the advice to dump single quotes, I'd ignore it.  The use of 
double and single quotes is a very handy feature and makes for very 
readable code.  Escaping double quotes is such a royal pia and makes for 
more trouble deciphering code later on.  The sample you provided for us 
is some of the best and most understandable code you've ever showed us.



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



[PHP-DB] Re: mysql query

2013-08-22 Thread Jim Giner

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt $opf
$stkkbr /;
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan



Ethan - you are simply missing two dollar signs as pointed out.  Once 
you correct them, if there are any more errors you should then be seeing 
the message from mysqli_error.


And as for the advice to dump single quotes, I'd ignore it.  The use of 
double and single quotes is a very handy feature and makes for very 
readable code.  Escaping double quotes is such a royal pia and makes for 
more trouble deciphering code later on.  The sample you provided for us 
is some of the best and most understandable code you've ever showed us.



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



[PHP-DB] Re: mysql query

2013-08-22 Thread Jim Giner

On 8/22/2013 9:52 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt $opf
$stkkbr /;
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan




Ethan - you are simply missing two dollar signs as pointed out.  Once
you correct them, if there are any more errors you should then be seeing
the message from mysqli_error.

And as for the advice to dump single quotes, I'd ignore it.  The use of
double and single quotes is a very handy feature and makes for very
readable code.  Escaping double quotes is such a royal pia and makes for
more trouble deciphering code later on.  The sample you provided for us
is some of the best and most understandable code you've ever showed us.

Also - Ethan - if you used an editor that was designed for php you 
probably would have seen these missing $ signs since a good one would 
highlight php syntax and the lack of the $ would have produced a 
different color than you expected.


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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Vinay Kannan
Jim, I know this is a stupid question to be asking this far into PHP
Development, maybe was a bit lazy, or just got too used to Notepad++, which
editor for PHP are you using? The feature which you mentioned for a good
php editor, sounds exciting, offcourse i would be looking only at the free
ones :D


On Thu, Aug 22, 2013 at 9:24 PM, Jim Giner jim.gi...@albanyhandball.comwrote:

 On 8/22/2013 9:52 AM, Jim Giner wrote:

 On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

 Dear List -

 I can't figure this out

 mysql describe Inventory;
 +-+-+-**-+-+-+---+
 | Field   | Type| Null | Key | Default | Extra |
 +-+-+-**-+-+-+---+
 | UPC | varchar(14) | YES  | | NULL |   |
 | quant   | int(5)  | NO   | | NULL |   |
 | manuf   | varchar(20) | YES  | | NULL |   |
 | item| varchar(50) | YES  | | NULL |   |
 | orderpt | tinyint(4)  | NO   | | NULL |   |
 | ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
 | stock   | int(3)  | YES  | | NULL |   |
 +-+-+-**-+-+-+---+

 Here are code snippets -

$upc   = $_SESSION['UPC'];
$qnt   = $_POST['quant'];
$mnf   = $_POST['manuf'];
$itm   = $_POST['item'];
$odrpt = $_POST['oderpt'];
$opf   = $_POST['ordrpt_flag'];
$stk= $_POST['stock'];

$sql2 = insert into Inventory (UPC, quant,
 manuf, item, orderpt, ordrpt_flag, stock)
  .values ('$upc', $qnt,'$mnf','$itm',
 odrpt, 0, $stk);
$result2 = mysqli_query(cxn, $sql2);
echo '$sql2br /';
print_r($sql2);
echo br /$upc $qnt $mnf $itm $odrpt $opf
 $stkkbr /;
if (!$result2)
  die('Could not enter data: ' .
 mysqli_error());

 The mysql query fails.  I cannot figure out why.  It works from the
 command line.

 TIA

 Ethan



  Ethan - you are simply missing two dollar signs as pointed out.  Once
 you correct them, if there are any more errors you should then be seeing
 the message from mysqli_error.

 And as for the advice to dump single quotes, I'd ignore it.  The use of
 double and single quotes is a very handy feature and makes for very
 readable code.  Escaping double quotes is such a royal pia and makes for
 more trouble deciphering code later on.  The sample you provided for us
 is some of the best and most understandable code you've ever showed us.

  Also - Ethan - if you used an editor that was designed for php you
 probably would have seen these missing $ signs since a good one would
 highlight php syntax and the lack of the $ would have produced a different
 color than you expected.


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




Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Toby Hart Dyke


Notepad++ will do syntax highlighting. Go to Language  P  PHP with a 
PHP file open, and see the colours change! It should be automatic - are 
you using something other than 'php' as a file extension?


  Toby

On 8/22/2013 5:27 PM, Vinay Kannan wrote:

Jim, I know this is a stupid question to be asking this far into PHP
Development, maybe was a bit lazy, or just got too used to Notepad++, which
editor for PHP are you using? The feature which you mentioned for a good
php editor, sounds exciting, offcourse i would be looking only at the free
ones :D


On Thu, Aug 22, 2013 at 9:24 PM, Jim Giner jim.gi...@albanyhandball.comwrote:





  Also - Ethan - if you used an editor that was designed for php you
probably would have seen these missing $ signs since a good one would
highlight php syntax and the lack of the $ would have produced a different
color than you expected.





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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Vinay Kannan
Thanks Toby, Using Notepad ++ with the language selected to PHP, the syntax
coloring is on


On Thu, Aug 22, 2013 at 11:00 PM, Toby Hart Dyke t...@hartdyke.com wrote:


 Notepad++ will do syntax highlighting. Go to Language  P  PHP with a PHP
 file open, and see the colours change! It should be automatic - are you
 using something other than 'php' as a file extension?

   Toby


 On 8/22/2013 5:27 PM, Vinay Kannan wrote:

 Jim, I know this is a stupid question to be asking this far into PHP
 Development, maybe was a bit lazy, or just got too used to Notepad++,
 which
 editor for PHP are you using? The feature which you mentioned for a good
 php editor, sounds exciting, offcourse i would be looking only at the free
 ones :D


 On Thu, Aug 22, 2013 at 9:24 PM, Jim Giner jim.gi...@albanyhandball.com
 **wrote:



   Also - Ethan - if you used an editor that was designed for php you
 probably would have seen these missing $ signs since a good one would
 highlight php syntax and the lack of the $ would have produced a
 different
 color than you expected.




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




Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Lester Caine

Vinay Kannan wrote:

Jim, I know this is a stupid question to be asking this far into PHP
Development, maybe was a bit lazy, or just got too used to Notepad++, which
editor for PHP are you using? The feature which you mentioned for a good
php editor, sounds exciting, offcourse i would be looking only at the free
ones


There are a number of options for highlighting and error checking just about 
every language. Running Linux most of them are free ;)
gedit and kwrite highlight automatically and help identify problems. In the past 
I've been running on both linux and windows so something cross platform was 
essential, and it's still nice when I do have to worry about windows sites. 
Eclipse provides that base, and while PDT is the official plugin for PHP, I'm 
back on the older PHPEclipse as it fits much better with the way I work. With 
properly commented libraries it provides pop-up crib sheets onthe parameters for 
a selected function, and of cause the auto complete can be configured to match 
your preferred way of working ... I'm still on tabs for indenting


--
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: mysql query

2013-08-22 Thread Ethan Rosenberg, PhD

On 08/22/2013 09:51 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt $opf
$stkkbr /;
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan



Ethan - you are simply missing two dollar signs as pointed out. Once 
you correct them, if there are any more errors you should then be 
seeing the message from mysqli_error.


And as for the advice to dump single quotes, I'd ignore it.  The use 
of double and single quotes is a very handy feature and makes for very 
readable code.  Escaping double quotes is such a royal pia and makes 
for more trouble deciphering code later on.  The sample you provided 
for us is some of the best and most understandable code you've ever 
showed us.

Jim -

Thanks for the complement.

Ethan


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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Ethan Rosenberg

On 08/22/2013 11:54 AM, Jim Giner wrote:

On 8/22/2013 9:52 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt $opf
$stkkbr /;
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan




Ethan - you are simply missing two dollar signs as pointed out. Once
you correct them, if there are any more errors you should then be seeing
the message from mysqli_error.

And as for the advice to dump single quotes, I'd ignore it.  The use of
double and single quotes is a very handy feature and makes for very
readable code.  Escaping double quotes is such a royal pia and makes for
more trouble deciphering code later on.  The sample you provided for us
is some of the best and most understandable code you've ever showed us.

Also - Ethan - if you used an editor that was designed for php you 
probably would have seen these missing $ signs since a good one would 
highlight php syntax and the lack of the $ would have produced a 
different color than you expected.



Jim -

I  used Netbeans.  All it said is variable unused is scope, which is 
a  error that I often find does not mean anything.  I am as pressurized 
as you are.  Any suggestions as to an editor?


Ethan



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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Ethan Rosenberg


Ethan Rosenberg, PhD
/Pres/CEO/
*Hygeia Biomedical Research, Inc*
2 Cameo Ridge Road
Monsey, NY 10952
T: 845 352-3908
F: 845 352-7566
erosenb...@hygeiabiomedical.com
On 08/22/2013 06:56 PM, Jim Giner wrote:

On 8/22/2013 4:14 PM, Ethan Rosenberg wrote:

On 08/22/2013 11:54 AM, Jim Giner wrote:

On 8/22/2013 9:52 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = insert into Inventory (UPC, 
quant,

manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc', 
$qnt,'$mnf','$itm',

odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt 
$opf

$stkkbr /;
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan




Ethan - you are simply missing two dollar signs as pointed out. Once
you correct them, if there are any more errors you should then be 
seeing

the message from mysqli_error.

And as for the advice to dump single quotes, I'd ignore it. The use of
double and single quotes is a very handy feature and makes for very
readable code.  Escaping double quotes is such a royal pia and 
makes for
more trouble deciphering code later on.  The sample you provided 
for us
is some of the best and most understandable code you've ever showed 
us.



Also - Ethan - if you used an editor that was designed for php you
probably would have seen these missing $ signs since a good one would
highlight php syntax and the lack of the $ would have produced a
different color than you expected.


Jim -

I  used Netbeans.  All it said is variable unused is scope, which is
a  error that I often find does not mean anything.  I am as pressurized
as you are.  Any suggestions as to an editor?

Ethan


Did you mean to say unused IN scope?  That would be telling you that 
it is not yet defined and that could be a problem if you expect to be 
already defined.


Several other posts here have listed their favorites.  Notepad ++ 
seems to be a favorite.  I use HTML-kit Tools as my developing 
environment. Handles highlighting for php, html and js, as well as 
project organization.  Also includes an ftp engine to allow me to 
modify, upload and then go test my code very quickly. (I don't run php 
or apache locally.)

Jim -

Thanks.

unused IN scope - correct.

There are lots of editors mentioned in this email trail.  I thank all 
for the suggestions.


Netbeans, Aptana Studio, etc will all highlight code and show the errors 
the code would generate in a browse. The problem here was two missing $ 
signs.


I'm probably wrong, but in some contexts; eg, sql query, $ signs are not 
used.  I tried and added the incorrect $ sign, and Netbeans did not 
complain.  If anyone knows of an editor that will able to spot this kind 
of error, please inform the list.


Ethan


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



[PHP-DB] Bluefish for PHP

2013-08-22 Thread Ethan Rosenberg

Dear List -

How do I configure Bluefish for PHP?  I am running version 2.2.4 of 
Bluefish.


TIA

Ethan

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