Re: [PHP-DB] Re: mysql query

2013-08-23 Thread Jim Giner

On 8/23/2013 4:32 AM, Lester Caine wrote:

Karl DeSaulniers wrote:

If your on a PC I would just get Eclipse. But if you have netbeans,
you can set the syntax highlighting for the different scripts you
write in the preferences. PHP, java, javascript, etc...


But the problem tha5 has been identified will never be flagged by simple
highlighting. Debugging complex SQL queries is possibly better done
outside of the PHP pages. Not sure exactly what SQL plug-in I've got
running on Eclipse at the moment, but as Ethan identified earlier, the
SQL script ran from the command line. It was passing the variables into
it which was wrong.

I'm with him on the statement that MySQL should have returned an error.
Certainly Firebird would have done and so identifying the problem might
have been easier.

I think the reason he didn't get the error was cause of his lack of a 
connection which never allowed it to run.


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

On 8/22/2013 8:08 PM, Ethan Rosenberg wrote:


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 '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt
$opf
$stk";
   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

Wrong in one sense - all php vars must have a $ sign.  When building a 
query statemtent, if the editor doesn't tell you something (by not 
colorizing it) Sql is going to tell you when you attempt to run it. 
That's why one should ALWAYS include an error check after any operation.


BTW - this line
echo '$sql2';

isn't going to give you what you want.

--
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-23 Thread Lester Caine

Karl DeSaulniers wrote:

If your on a PC I would just get Eclipse. But if you have netbeans, you can set 
the syntax highlighting for the different scripts you write in the preferences. 
PHP, java, javascript, etc...


But the problem tha5 has been identified will never be flagged by simple 
highlighting. Debugging complex SQL queries is possibly better done outside of 
the PHP pages. Not sure exactly what SQL plug-in I've got running on Eclipse at 
the moment, but as Ethan identified earlier, the SQL script ran from the command 
line. It was passing the variables into it which was wrong.


I'm with him on the statement that MySQL should have returned an error. 
Certainly Firebird would have done and so identifying the problem might have 
been easier.


--
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-23 Thread Karl DeSaulniers
If your on a PC I would just get Eclipse. But if you have netbeans, you can set 
the syntax highlighting for the different scripts you write in the preferences. 
PHP, java, javascript, etc...

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

2013-08-23 Thread Lester Caine

Ethan Rosenberg wrote:

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.


You do need to take a little more care when using variables IN strings and watch 
that they are highlighted. As you say, the parsing is not actually wrong as it 
is valid 'text' and adding SQL parsers for every database is not really 
practical and probably would not fix the problem anyway? Personally I use 
Firebird, and have always built the SQL using parameters, so that the SQL is 
pure text, and values are passed in an array. This is something MySQL was a lot 
later in catching onto, but many of the simple security problems are totally 
eliminated using that approach.


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


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 '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt 
$opf

$stk";
   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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Jim Giner

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 '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt $opf
$stk";
   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.)


--
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 '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt $opf
$stk";
   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, 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 '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt $opf
$stk";
   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 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 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  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 
>> **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 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 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 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 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 '$sql2';
>>>print_r($sql2);
>>>echo "$upc $qnt $mnf $itm $odrpt $opf
>>> $stk";
>>>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
>
>


[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 '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt $opf
$stk";
   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



[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 '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt $opf
$stk";
   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 '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt $opf
$stk";
   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



Re: [PHP-DB] Re: MySQL Query on the Fly

2007-05-13 Thread Steven Cruz
You can the entire thing in Java script with Style sheets. Depends on 
what he wants to do. iframes could be far simpler. :)



itoctopus wrote:

You have to use an iframe to do what you want. Once the user select
something, you referesh the iframe and you pass specific parameters to it
based on the user's choice.

  


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



[PHP-DB] Re: MySQL Query on the Fly

2007-05-12 Thread itoctopus
You have to use an iframe to do what you want. Once the user select
something, you referesh the iframe and you pass specific parameters to it
based on the user's choice.

-- 
itoctopus - http://www.itoctopus.com
""Todd A. Dorschner"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
Good Morning,



I've been searching and toying with this solution for some time but
can't find that right answer.  Looking for solutions/suggestions to the
following:



I created a program that will allow people to track sales and depending
on what they've sold, they will either get a set bonus, or a bonus based
on a percentage.  I have no problem creating a drop down box for them to
select from, and I could probably create a select button that would do
the action, but I'd rather have it in one step.  So what I'm trying to
do is somehow when they select from the drop down (via a JavaScript
onchange or something) I'd like it to pull data from the MySQL database.
I'd like it to pull the amount and then each or per based on the ID of
what they've selected from the drop down.  If it was always based on
each sale or based on a percentage, that would be easy as I could code
that into the drop box, but I'd like to keep it based on the ID so that
it can pull out of the database the name, and then when changed pull the
info.  Any ideas?  Thanks in advance for the help.  If you have any
questions or it seems like I left something out, please let me know.





Thank you for your time,


Todd Dorschner

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



[PHP-DB] Re: MySQL Query Help

2006-03-23 Thread João Cândido de Souza Neto
Mark Dyer wrote:

> 
> Hello, I'm unsure how to write the follow query, Please can someone
> assist.
> 
> I am writing in short hand the basis of the two queries I would like to
> combine. The object is to select all the products that have not meet the
> min sale requirements so I can send myself a reminder email.
> 
> The first table products contains the product information and how ofter
> the stores must purchase and at what period ie, Weekly or Monthly by
> product.
> 
> First Query gives me all the products that must check to see if they have
> meet the min sales.
> 
> Select store_id,product_id, min_level, reoirder_period from products db
> where monthly_order_required > 0
> 
> 
> Second Query is then run to test to see if they have meet the min sales.
> 
> Php: If reorder period = weekly then backdate = 7 days elseif period =
> monthly then backdate = 30
> 
> Select sum(sale_product_qty) as sale_period_total from sales db where
> store = store_id and product = product_id and date <= now and date >
> backdate and sale_period_total > min_level
> 
> 
> Result: sum of sales in the last week or month period for that product
> from that store. If no result then sale level ok. If result then the
> difference from min_level is what is require for the store to make asap.
> 
> Php: if sale_period_total < min_level then email low order email.
> 
> 
> Any assistance to combine to the queries instead of hundreds of individual
> would be grateful.
> 
> Regards
> Mark Dyer
> NZ

Please, could you putting your real code here to us?


-- 
---
João Cândido de Souza Neto
Web Developer

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



[PHP-DB] Re: MySQL query problems...

2005-03-24 Thread Frank M Flynn
The error message and  when I have problems I find it's very helpful to 
print  the  actual value of the $query  variable.

In your case it looks like
		   AND acct_db.key1 LIKE \"%\".AllMid_Data.CPU_Hostname
is adding   AND acct_db.key1 LIKE "%".AllMid_Data.CPU_Hostname
and you can't join two strings in SQL with a '.' like you can in PHP 
you should use a + for the  two strings.  I think what  you want is:

  AND acct_db.key1 LIKE \"%\" + AllMid_Data.CPU_Hostname
Good Luck,
Frank
On Mar 24, 2005, at 1:33 AM, [EMAIL PROTECTED] wrote:
From: "NIPP, SCOTT V \(SBCSI\)" <[EMAIL PROTECTED]>
Date: March 23, 2005 3:18:44 PM PST
To: 
Subject: MySQL query problems...
I am getting errors for the following queries.  This query seems
to work fine in phpMyAdmin.
$query2 = "SELECT AllMid_Data.CPU_Hostname FROM AllMid_Data, accounts
   WHERE AllMid_Data.CPU_IN_SVC = \"Y\"
   AND AllMid_Data.CPU_DNS = \"sbcld.sbc.com\"
   AND accounts.sbcuid = $sbcuid
   AND accounts.system = AllMid_Data.CPU_Hostname
   AND accounts.ctime IS NULL
   ORDER BY CPU_Hostname ASC";
$results2 = mysql_query($query2, $Prod) or die(mysql_error());
$system2 = mysql_fetch_assoc($results2);
$query3 = "SELECT AllMid_Data.CPU_Hostname FROM AllMid_Data, acct_db
   WHERE AllMid_Data.CPU_IN_SVC = \"Y\"
   AND AllMid_Data.CPU_DNS = \"sbcld.sbc.com\"
   AND acct_db.key1 LIKE \"$sbcuid%\"
   AND acct_db.key1 LIKE \"%\".AllMid_Data.CPU_Hostname
   ORDER BY CPU_Hostname ASC";
$results3 = mysql_query($query3, $Prod) or die(mysql_error());
$system3 = mysql_fetch_assoc($results3);
I am assuming that I have an issue with query3.  Thanks in
advance.
Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com


[PHP-DB] Re: MySQL query, using DISTINCT...

2004-07-07 Thread Rui Cunha
i don't know if someone already gave you a suggestion such as: 

select distinct mail
from (
select mail , filename,  count(*)
from table
having count(*) > 1
group by mail,filename
); 

i presume that you're looking for disctinct mails of users that downloaded 
the same file more than once. 

hope it helps 

Rui Cunha 

[EMAIL PROTECTED] writes: 

I have a system that tracks downloads, capturing loadsa info, but of 
interest here, is email and filename.
Simply put, I wanna show all results where file name AND email are unique.
(so if email '[EMAIL PROTECTED]' has filename 'word.doc' 5 times in a table, 
I want to only see it once.) 

What am I doing wrong...? 

SELECT DISTINCT(file_name, email) FROM `completed_downloads` WHERE `bu`  = 
 'reech' AND date BETWEEN '2004-06-01' AND '2004-06-30' 

Tris... 

*
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
*** 

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


Re[2]: [PHP-DB] Re: MySQL query, using DISTINCT...

2004-07-06 Thread Pablo M. Rivas
Hello Tristan,
 Select count(id) as howmany, file_name, email from  `completed_downloads`
 where bu='reech' and date  BETWEEN '2004-06-01' AND '2004-06-30'
 group by file_name, email

 

>> > I have a system that tracks downloads, capturing loadsa info, but of
>> > interest here, is email and filename.
>> > Simply put, I wanna show all results where file name AND email are 
TPrsc> unique.
>> > (so if email '[EMAIL PROTECTED]' has filename 'word.doc' 5 times in a 
TPrsc> table,
>> > I want to only see it once.)
>> >
>> > What am I doing wrong...?
>> >
>> > SELECT DISTINCT(file_name, email) FROM `completed_downloads` WHERE 
TPrsc> `bu`  =
>> >  'reech' AND date BETWEEN '2004-06-01' AND '2004-06-30'
>> >
>> > Tris...



-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Re: MySQL query, using DISTINCT...

2004-07-06 Thread zareef ahmed
Hi,

 using "group by" can also be usefull.

zareef ahmed  

--- Torsten Roehr <[EMAIL PROTECTED]> wrote:
> "Tristan Pretty" <[EMAIL PROTECTED]>
> wrote in message
>
news:[EMAIL PROTECTED]
> com...
> > I have a system that tracks downloads, capturing
> loadsa info, but of
> > interest here, is email and filename.
> > Simply put, I wanna show all results where file
> name AND email are unique.
> > (so if email '[EMAIL PROTECTED]' has filename
> 'word.doc' 5 times in a table,
> > I want to only see it once.)
> >
> > What am I doing wrong...?
> >
> > SELECT DISTINCT(file_name, email) FROM
> `completed_downloads` WHERE `bu`  =
> >  'reech' AND date BETWEEN '2004-06-01' AND
> '2004-06-30'
> >
> > Tris...
> 
> Hi Tristan,
> 
> I'm not an MySQL expert but DISTINCT removes
> duplicate *rows* from your
> result set. As you select email AND file_name you
> will always have a unique
> row (combination of email and file_name). Try
> without specifying file_name:
> 
> SELECT DISTINCT email FROM `completed_downloads`
> WHERE `bu` = 'reech' AND
> date BETWEEN '2004-06-01' AND '2004-06-30'
> 
> Regards, Torsten Roehr
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


=
Zareef Ahmed :: A PHP Developer in Delhi(India).
Homepage :: http://www.zasaifi.com



__
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

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



Re: [PHP-DB] Re: MySQL query, using DISTINCT...

2004-07-06 Thread Tristan . Pretty
> > I have a system that tracks downloads, capturing loadsa info, but of
> > interest here, is email and filename.
> > Simply put, I wanna show all results where file name AND email are 
unique.
> > (so if email '[EMAIL PROTECTED]' has filename 'word.doc' 5 times in a 
table,
> > I want to only see it once.)
> >
> > What am I doing wrong...?
> >
> > SELECT DISTINCT(file_name, email) FROM `completed_downloads` WHERE 
`bu`  =
> >  'reech' AND date BETWEEN '2004-06-01' AND '2004-06-30'
> >
> > Tris...
> 
> Hi Tristan,
> 
> I'm not an MySQL expert but DISTINCT removes duplicate *rows* from your
> result set. As you select email AND file_name you will always have a 
unique
> row (combination of email and file_name). Try without specifying 
file_name:
> 
> SELECT DISTINCT email FROM `completed_downloads` WHERE `bu` = 'reech' 
AND
> date BETWEEN '2004-06-01' AND '2004-06-30'
> 
> Regards, Torsten Roehr

Ah...
But if the user has downloaded 3 files, I need to know that.
distinct email alone, wouldn't pick that up...
Cheers for your help though, I'm getting there...!
Any other ideas?

*
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
***

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



[PHP-DB] Re: MySQL query, using DISTINCT...

2004-07-06 Thread Torsten Roehr
"Tristan Pretty" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
com...
> I have a system that tracks downloads, capturing loadsa info, but of
> interest here, is email and filename.
> Simply put, I wanna show all results where file name AND email are unique.
> (so if email '[EMAIL PROTECTED]' has filename 'word.doc' 5 times in a table,
> I want to only see it once.)
>
> What am I doing wrong...?
>
> SELECT DISTINCT(file_name, email) FROM `completed_downloads` WHERE `bu`  =
>  'reech' AND date BETWEEN '2004-06-01' AND '2004-06-30'
>
> Tris...

Hi Tristan,

I'm not an MySQL expert but DISTINCT removes duplicate *rows* from your
result set. As you select email AND file_name you will always have a unique
row (combination of email and file_name). Try without specifying file_name:

SELECT DISTINCT email FROM `completed_downloads` WHERE `bu` = 'reech' AND
date BETWEEN '2004-06-01' AND '2004-06-30'

Regards, Torsten Roehr

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



[PHP-DB] RE: MySQL query failing on apostrophe in data

2003-08-27 Thread Dillon, John
Seemingly:

http://www.php.net/manual/en/function.mysql-escape-string.php

-Original Message-
From: Dillon, John 
Sent: 27 August 2003 17:59
To: 'PHP-DB'
Subject: MySQL query failing on apostrophe in data 


How do I avoid the problem in the subject hereto?  SELECT query uses
variable in the WHERE clause.  Fails on the following query:

SELECT Tbl.fld FROM Tbl WHERE Tbl.fld2='11301201 0603A HKA 3902 #3708_JD's
AE Exp' AND ...

John











































   http://www.cantor.com
CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are 
confidential. If you are not the named recipient please notify the sender and 
immediately delete it. You may not disseminate, distribute, or forward this e-mail 
message or disclose its contents to anybody else. Copyright and any other intellectual 
property rights in its contents are the sole property of Cantor Fitzgerald.
 E-mail transmission cannot be guaranteed to be secure or error-free. The sender 
therefore does not accept liability for any errors or omissions in the contents of 
this message which arise as a result of e-mail transmission.  If verification is 
required please request a hard-copy version.
 Although we routinely screen for viruses, addressees should check this e-mail and 
any attachments for viruses. We make no representation or warranty as to the absence 
of viruses in this e-mail or any attachments. Please note that to ensure regulatory 
compliance and for the protection of our customers and business, we may monitor and 
read e-mails sent to and from our server(s). 

For further important information, please read the  Important Legal Information and 
Legal Statement at http://www.cantor.com/legal_information.html

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



[PHP-DB] Re: MySQL query from multiple tables

2002-07-04 Thread Matthew Crouch

it sounds like you may be serializing your SQL, in which case the following link might
help.
http://www.ashleyit.com/rs/jsrs/select/php/select.php


Matthew Nock wrote:

> Hi All,
>
> I have a strange query which I need to build - I have looked at the JOIN and
> aliasing functions of mySQL but not sure if I can achieve want I want to do.
>
> I have two tables (product_head, and product_features) (in addition to a
> number of other tables) which form the list of products I have available,
> and the features available with each product.
>
> I want to be able to retrieve from product_head the rows which are for a
> specific product category (ie: 1)..  this bit is easy.
>
> SELECT * from product_head where prod_cat_ID = 1;
>
> This query could return 1 or more rows - works great.
>
> but I also want to retrieve records from the product_features table.
> information stored in this table is:
>
> prod_ID feat_ID feat_value
>
> so for each product ID, there could be any number of features.  I need to
> retrieve only certain feat_value records, for specific products, where the
> feat_ID equals certain values .
>
> can I build a single query that will return all these results similar to
> below?
>
> Prod_ID Prod_name   Feat_1_valueFeat_2_valuefeat_3_value
> 1   prod1   34  25  15
> 2   prod2   10  15  15
> ...
>
> does this all make sense?


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




[PHP-DB] Re: MySQL query from multiple tables

2002-06-29 Thread andy

hello Matthew:

if I understood your problem right, you have to join the two tables.

E.g:

SELECT
ph.*,
pf.prod_ID,
pf.feat_ID,
pf.feat_value
FROM
product_head ph,
product_features pf

WHERE
ph.prod_cat_ID = 1
AND ph.prod_cat_ID = pf.prod_cat_ID /*join the two tables with the same
id*/
AND pf.yourcriteria = whatever /* put your criteria for table 2 here*/

Hope this helps a bit,

Andy

--
--
http://www.globosapiens.net
Global Travellers Network


"Matthew Nock" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]...
> Hi All,
>
> I have a strange query which I need to build - I have looked at the JOIN
and
> aliasing functions of mySQL but not sure if I can achieve want I want to
do.
>
> I have two tables (product_head, and product_features) (in addition to a
> number of other tables) which form the list of products I have available,
> and the features available with each product.
>
> I want to be able to retrieve from product_head the rows which are for a
> specific product category (ie: 1)..  this bit is easy.
>
> SELECT * from product_head where prod_cat_ID = 1;
>
> This query could return 1 or more rows - works great.
>
> but I also want to retrieve records from the product_features table.
> information stored in this table is:
>
> prod_ID feat_ID feat_value
>
> so for each product ID, there could be any number of features.  I need to
> retrieve only certain feat_value records, for specific products, where the
> feat_ID equals certain values .
>
> can I build a single query that will return all these results similar to
> below?
>
>
> Prod_ID Prod_name Feat_1_value Feat_2_value feat_3_value
> 1 prod1 34 25 15
> 2 prod2 10 15 15
> ...
>
> does this all make sense?
>



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




[PHP-DB] Re: MySQL Query Acting Up

2002-06-20 Thread Martin Clifford

Thanks everyone!  Between all the replies I was able to locate the problem and fix it! 
 It wasn't the missing backslash (that was a typo, which sucks).  I wasn't properly 
passing the article_id field to the query, so MySQL had a problem with WHERE id="".

Thanks again! :o)

Martin


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




[PHP-DB] Re: MySQL Query Acting Up

2002-06-20 Thread Seth Yount

in your   SET title=\"$title\",   statement you forgot the second 
backslash before the double quote.  I would start there.


Martin Clifford wrote:

> Howdy all,
> 
> If someone call tell me why this MySQL query is not working, I'd be VERY thankful.  
>I don't see a damn thing wrong with it, but I could have been looking at it too long.
> 
> Here is the query:
> 
> $query = "UPDATE articles2 SET title=\"$title", brief=\"$brief\", 
>doclink=\"$doclink\" WHERE article_id=\"$id\"";
> $result = mysql_query($query, $connect)
>  or die(mysql_error());
> 
> No errors are produced, yet the query doesn't do anything.  Nothing in the row 
>changes.  Any help would be appreciated!
> 
> Martin
> 
> 


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




[PHP-DB] Re: MySQL Query Acting Up

2002-06-20 Thread user

in your   SET title=\"$title\",   statement you forgot the second 
backslash before the double quote.  I would start there.

Martin Clifford wrote:

> Howdy all,
> 
> If someone call tell me why this MySQL query is not working, I'd be VERY thankful.  
>I don't see a damn thing wrong with it, but I could have been looking at it too long.
> 
> Here is the query:
> 
> $query = "UPDATE articles2 SET title=\"$title", brief=\"$brief\", 
>doclink=\"$doclink\" WHERE article_id=\"$id\"";
> $result = mysql_query($query, $connect)
>  or die(mysql_error());
> 
> No errors are produced, yet the query doesn't do anything.  Nothing in the row 
>changes.  Any help would be appreciated!
> 
> Martin
> 
> 


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




[PHP-DB] Re: MYSQL query help

2001-12-14 Thread Fred

There are several ways to get around the lack of subselect support in mysql.
For your situation you can simply use:

SELECT * FROM lib_asset_tbl, lib_copy_tbl WHERE lib_asset_tbl.material_id <>
'' AND lib_asset_tbl.asset_id = lib_copy_tbl.asset_id

of course, this will return a row for every instance of a many to many
relationship, so you may want to use a GROUP BY clause to reduce the number
of rows in the result.

Fred

Harpreet <[EMAIL PROTECTED]> wrote in message
01c184ac$6ed6b250$38c8a8c0@harpreet">news:01c184ac$6ed6b250$38c8a8c0@harpreet...
> I dont think we can use 'IN' and 'NOT IN' in mysql. Is there an
alternative
> that would work?
>
> select * from lib_asset_tbl where material_id <>'' and asset_id in (select
> asset_id from lib_copy_tbl)
>
> Help is appreciated.
>
> Regards,
> Harpreet Kaur
> Software Developer
> Crispin Corporations Inc.
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]