[PHP-DB] php problem

2005-01-06 Thread Serenity Schindler
I am new to php and have no idea what I'm doing wrong. I have a file named 
test.php containing:
 
html
head
title PHP Test /title
/head
body
pThis is an HTML line
p
?php
   echo This is a PHP line;
   phpinfo();
?
/body
/html
 
The html lines show up just fine but none of the php info is displayed. Any 
ideas?
 
~Serenity~
 


-
Do you Yahoo!?
 Yahoo! Mail - You care about security. So do we.

Re: [PHP-DB] php problem

2005-01-06 Thread Jochem Maas
Serenity Schindler wrote:
I am new to php and have no idea what I'm doing wrong. I have a file named test.php containing:
 
html
head
title PHP Test /title
/head
body
pThis is an HTML line
p
?php
   echo This is a PHP line;
   phpinfo();
?
/body
/html
 
The html lines show up just fine but none of the php info is displayed. Any ideas?
does your page show you the text This is a PHP line?
if you view the source of the page in your browser do you see the following:
?php
echo This is a PHP line;
phpinfo();
?
if so then PHP is not either:
1. your webserver is not configured to use php to handle files with a 
php extension.
2. your webserver does not have php installed.

if not then try a file containing just the following and see if that 
outputs anything:

?php phpinfo(); ?
 
~Serenity~
 


-
Do you Yahoo!?
 Yahoo! Mail - You care about security. So do we.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] PHP query to mysql database returns emtpy data, but Query Browser shows records

2005-01-06 Thread Jochem Maas
graeme wrote:
Hi,
You have:
$query example = SELECT description from cpProducts where category='39 
47 48 172'

don't you want to add a logical operator such as OR, possibly AND
$query example = SELECT description from cpProducts where category='39 
OR 47 OR 48 OR 172'

graeme.
whatever it is that he is trying to do - I doubt he wants to put 'OR's 
in the character string, besides which AFAIK you can't do something like:

SELECT description from cpProducts where category=39 OR 47 OR 48 OR 172;
(possibly the SQL above will actually return all rows because any number 
greater than zero will evaluate to true - e.g. ($x = true || 1) is 
always true regardless of the value of $x, I am assuming the same 
general logic goes for SQL or'ing)
it should be:

SELECT description from cpProducts where category=39 OR 47 OR 48 OR 172;
Jason, read on for more (possible) help (well I gave it a shot but I 
don't think it will be any help, sorry):


Jason Walker wrote:
 

Here is the query:
 function ReturnPackageDescriptions($pack, $cat, $hotcat, $hotid){
 $comIB = $cat .   . $pack .   . $hotcat .   . $hotid;
  $catLength = strlen($comIB);
  echo $catLength;
  $query = SELECT description from cpProducts where 
category=' . $cat .   . $pack .   . $hotcat .   . $hotid . ';
  echo bR . $query . br;
 echo combined package number =  . $comIB . br;
   $retval = ;
  $link = 
mysql_connect($config['host'],$config['user'],$config['pass']) or 
die(Could not connect);
  mysql_select_db('stc_store') or die(Unable to connect 
to the default database);
  $result = mysql_query($query) or die(Unable to pull 
the menu objects for main event details);
  echo mysql_affected_rows() . br;
while ($results = mysql_fetch_array($result, 
MYSQL_ASSOC)){
 extract($results);
   echo $description;
   $retval = $description;
  }
   mysql_free_result($result);
 mysql_close($link);
  return $retval;
  }

I have some extra 'echo' statements to see the progress on the web 
page. If I remove the 'where' clause within the SQL statement, I get 
rows. But when I add the 'where' portion, no records are returned.

Here is an example of what the query looks like:
$query example = SELECT description from cpProducts where category='39 
47 48 172'
I'll assume that your table has a field named 'category' - otherwise the 
statement should throw you a big error :-) BUT is it a character data 
field (i.e. does it contain text)? AND do you actually have rows where 
the value of the category field is '39 47 48 172' - in order to get rows 
returned when running your example query the value needs to match this 
string EXACTLY.

Given the fact that using mysql control center give you the desired 
result the above probably was a waste of time typing. Given that fact 
the only thing I can think of is that you have a extra space floating 
about (but I can't see it in the code your provided)

does the output of mysql_error() provide any feedback?
(what an odd problem!)

When I run the same query in MYSQL Control center or Query Browser, no 
problem. I use this function template for my SELECT statements.

Please let me know if there is something missing from the code.
Thanks.
 

 

Jason Walker
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
http://www.desktophero.com
 


No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.8 - Release Date: 1/3/2005
 


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


Re: [PHP-DB] PHP query to mysql database returns emtpy data, butQuery Browser shows records

2005-01-06 Thread Bastien Koert
Perhaps an IN query clause it what he needs...
$query example = SELECT description from cpProducts where
category IN (39, 47, 48, 172)
bastien
From: Jochem Maas [EMAIL PROTECTED]
To: graeme [EMAIL PROTECTED]
CC: Jason Walker [EMAIL PROTECTED], php-db@lists.php.net
Subject: Re: [PHP-DB] PHP query to mysql database returns emtpy data, 
butQuery Browser shows records
Date: Thu, 06 Jan 2005 14:24:29 +0100

graeme wrote:
Hi,
You have:
$query example = SELECT description from cpProducts where category='39 47 
48 172'

don't you want to add a logical operator such as OR, possibly AND
$query example = SELECT description from cpProducts where category='39 OR 
47 OR 48 OR 172'

graeme.
whatever it is that he is trying to do - I doubt he wants to put 'OR's in 
the character string, besides which AFAIK you can't do something like:

SELECT description from cpProducts where category=39 OR 47 OR 48 OR 172;
(possibly the SQL above will actually return all rows because any number 
greater than zero will evaluate to true - e.g. ($x = true || 1) is always 
true regardless of the value of $x, I am assuming the same general logic 
goes for SQL or'ing)
it should be:

SELECT description from cpProducts where category=39 OR 47 OR 48 OR 172;
Jason, read on for more (possible) help (well I gave it a shot but I don't 
think it will be any help, sorry):


Jason Walker wrote:

Here is the query:
 function ReturnPackageDescriptions($pack, $cat, $hotcat, $hotid){
 $comIB = $cat .   . $pack .   . $hotcat .   . $hotid;
  $catLength = strlen($comIB);
  echo $catLength;
  $query = SELECT description from cpProducts where category=' 
. $cat .   . $pack .   . $hotcat .   . $hotid . ';
  echo bR . $query . br;
 echo combined package number =  . $comIB . br;
   $retval = ;
  $link = 
mysql_connect($config['host'],$config['user'],$config['pass']) or 
die(Could not connect);
  mysql_select_db('stc_store') or die(Unable to connect to 
the default database);
  $result = mysql_query($query) or die(Unable to pull 
the menu objects for main event details);
  echo mysql_affected_rows() . br;
while ($results = mysql_fetch_array($result, 
MYSQL_ASSOC)){
 extract($results);
   echo $description;
   $retval = $description;
  }
   mysql_free_result($result);
 mysql_close($link);
  return $retval;
  }

I have some extra 'echo' statements to see the progress on the web page. 
If I remove the 'where' clause within the SQL statement, I get rows. But 
when I add the 'where' portion, no records are returned.

Here is an example of what the query looks like:
$query example = SELECT description from cpProducts where category='39 47 
48 172'
I'll assume that your table has a field named 'category' - otherwise the 
statement should throw you a big error :-) BUT is it a character data field 
(i.e. does it contain text)? AND do you actually have rows where the value 
of the category field is '39 47 48 172' - in order to get rows returned 
when running your example query the value needs to match this string 
EXACTLY.

Given the fact that using mysql control center give you the desired result 
the above probably was a waste of time typing. Given that fact the only 
thing I can think of is that you have a extra space floating about (but I 
can't see it in the code your provided)

does the output of mysql_error() provide any feedback?
(what an odd problem!)

When I run the same query in MYSQL Control center or Query Browser, no 
problem. I use this function template for my SELECT statements.

Please let me know if there is something missing from the code.
Thanks.


Jason Walker
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
http://www.desktophero.com


No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.8 - Release Date: 1/3/2005


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


Re: [PHP-DB] str_replace question

2005-01-06 Thread Brent Baisley
I can't think of an instance where a query would have the phrase WHERE 
AND. Perhaps if you post the contents of the $additionalsql variable, 
we can tell you why it's not working.
You may actually be looking to use an array for your search words in 
str_replace(), or perhaps grep.

On Jan 5, 2005, at 8:05 PM, Chris Payne wrote:
Hi there everyone,

Im having a weird problem and Im not sure why, if I try to replace 
WHERE
AND with just WHERE it wont do it, but if I try to replace WHERE or 
AND by
themselves it WILL do it, but I cannot replace BOTH of them from a 
single
string, is something wrong below?


$additionalsql = str_replace(WHERE AND, WHERE, $additionalsql);

Basically Im trying to replace WHERE AND with just WHERE as Im 
building a
very complex SQL query and its a difficult one, and I have a solution 
that
works perfectly but I need this to work in order to do it.


I would appreciate any help on this, as its very important.

Chris
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.296 / Virus Database: 265.6.7 - Release Date: 12/30/2004

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Re: MySQL version issue

2005-01-06 Thread Norland, Martin
 -Original Message-
 From: Doug Thompson [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, January 05, 2005 8:44 AM
 
 I isn't my intention to start a peeing contest, but if *you* get rid
of the chip and actually read the manual excerpt, the equivalent SQL
statements it cites are very definitely available in mysql 3.xx.xx.

This will be brief, because this is rolling towards non-productiveness -
but, while you are technically right - it's still not an answer for him.

The new feature us do this OR (IF CONDITION) that and the equivalent
statement is do that with the precondition of (IF CONDITION).  Of
course the relevant SQL statements are available to independently insert
or update, it'd be pretty useless without.

So, yeah - solution is to bring the logic into the app, or get a new
host.  'nuff said.

Cheers,

- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


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



RE: [PHP-DB] php problem

2005-01-06 Thread Norland, Martin
 -Original Message-
 From: Jochem Maas [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, January 06, 2005 7:13 AM
 Subject: Re: [PHP-DB] php problem
 
 if so then PHP is not either:
 
 1. your webserver is not configured to use php to handle files with a
php extension.
 2. your webserver does not have php installed.

3. The file extension isn't recognized by apache as something to parse
for php (e.g. it's .html not .php)

Cheers,
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


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



Re: [PHP-DB] str_replace question

2005-01-06 Thread Bastien Koert
whats likely happening is the sql is being built on the fly. and he's 
malformed it somewhere...

A neat little trick would be to create the initial part of the statement 
with a predefined where clause based on some record state. For instance, we 
use a record_deleted field, since we don't delete data. He could start his 
statement by automatically looking for it

select * from tablename where record_deleted = 'No'
then any additional clauses that get added all require the AND keyword. No 
more problem

bastien
From: Brent Baisley [EMAIL PROTECTED]
To: Chris Payne [EMAIL PROTECTED]
CC: php-db@lists.php.net
Subject: Re: [PHP-DB] str_replace question
Date: Thu, 6 Jan 2005 09:20:47 -0500
I can't think of an instance where a query would have the phrase WHERE 
AND. Perhaps if you post the contents of the $additionalsql variable, we 
can tell you why it's not working.
You may actually be looking to use an array for your search words in 
str_replace(), or perhaps grep.

On Jan 5, 2005, at 8:05 PM, Chris Payne wrote:
Hi there everyone,

I’m having a weird problem and I’m not sure why, if I try to replace WHERE
AND with just WHERE it won’t do it, but if I try to replace WHERE or AND 
by
themselves it WILL do it, but I cannot replace BOTH of them from a single
string, is something wrong below?


$additionalsql = str_replace(WHERE AND, WHERE, $additionalsql);

Basically I’m trying to replace WHERE AND with just WHERE as I’m building 
a
very complex SQL query and it’s a difficult one, and I have a solution 
that
works perfectly but I need this to work in order to do it.


I would appreciate any help on this, as it’s very important.

Chris
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.296 / Virus Database: 265.6.7 - Release Date: 12/30/2004

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] str_replace question

2005-01-06 Thread Norland, Martin
 -Original Message-
 From: Bastien Koert [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, January 06, 2005 8:34 AM
 Subject: Re: [PHP-DB] str_replace question
 
 [snip]
 
 A neat little trick would be to create the initial part of the
statement with a predefined where clause based on some record state. For
instance, we use a record_deleted field, since we don't delete data. He
could start his statement by automatically looking for it
 
 select * from tablename where record_deleted = 'No'
 
 then any additional clauses that get added all require the AND
keyword. No more problem
 
 bastien

Alternatively, as mentioned before - something that evaluates to true.

The Answer**:
select * from tablename where 42

** to Life, the Universe, and Everything.

- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


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



[PHP-DB] Update / Delete / Insert quandry

2005-01-06 Thread Stuart Felenstein
I am working on update areas for my end users.  This
is where they can go in and update and / or edit
information in their profile. 

The problem I'm having a hard time getting my hands
around are those areas where they can have multiple
entries. 

One of the tables allows for a user to enter up to 5
choices. The table would look like this:

RecordID   TypeID
101  3
101  5
101  9
.etc.

So I can do a straight update - where if they wanted
to update the example above and change the 3 to a 12
that works fine.  What if they wanted to leave TypeID:
3 but delete 5 and 9.  Or another scenario, if they
wanted to leave the existing ones but add a fourth
record.  

Is there a way I can handle all this in one fell
swoop? I thought of deleting all current records
first and letting user make all new choices.  Not sure
if this would work well if many users though.

Any suggestions ?

Thank you,
Stuart

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



[PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Jason Davis
Hi all I am new to PHP and am trying to connect to mysql for the first time.
I get activity on the mysql monitor when I run it, but get the following
error.

DB Error: connect failed

The lines of code are:
require_once( DB.php );
$dsn = mysql://.DB_USER.:.DB_PASS.@.DB_SERVER./.DB_NAME;
echo $dsn;
$isPersistant = TRUE;
$db = DB::connect($dsn, $isPersistant);

if ( DB::isError( $db ) ) {
die ($db-getMessage());
}

The constants are properly defined and passing through to this page (checked
with echo), the database is created, the user has an account, and the
account has rights to do all funcitons on the db. Any thoughts on what might
be wrong?


Thanks
Jason

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



Re: [PHP-DB] PHP query to mysql database returns emtpy data, butQuery Browser shows records

2005-01-06 Thread jwalker


No the category field is varchar(250) and uses spaces to parse each element 
within the field. 

The database is an osCommerce hybrid - not my own. The values within the 
category field go from one number to an X set of numbers, separated by spaces. 
This is making development rather difficult and painful.

---Original Message---
 From: Bastien Koert [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] PHP query to mysql database returns emtpy data, 
 butQuery Browser shows records
 Sent: 06 Jan 2005 14:14:02

  Perhaps an IN query clause it what he needs...
  
  $query example = SELECT description from cpProducts where
  category IN (39, 47, 48, 172)
  
  bastien
  
  From: Jochem Maas [EMAIL PROTECTED]
  To: graeme [EMAIL PROTECTED]
  CC: Jason Walker [EMAIL PROTECTED], php-db@lists.php.net
  Subject: Re: [PHP-DB] PHP query to mysql database returns emtpy data,
  butQuery Browser shows records
  Date: Thu, 06 Jan 2005 14:24:29 +0100
  
  graeme wrote:
  Hi,
  
  You have:
  
  $query example = SELECT description from cpProducts where category='39 47
  48 172'
  
  don't you want to add a logical operator such as OR, possibly AND
  
  $query example = SELECT description from cpProducts where category='39 OR
  47 OR 48 OR 172'
  
  graeme.
  
  whatever it is that he is trying to do - I doubt he wants to put 'OR's in
  the character string, besides which AFAIK you can't do something like:
  
  SELECT description from cpProducts where category=39 OR 47 OR 48 OR 172;
  
  (possibly the SQL above will actually return all rows because any number
  greater than zero will evaluate to true - e.g. ($x = true || 1) is always
  true regardless of the value of $x, I am assuming the same general logic
  goes for SQL or'ing)
  it should be:
  
  SELECT description from cpProducts where category=39 OR 47 OR 48 OR 172;
  
  Jason, read on for more (possible) help (well I gave it a shot but I don't
  think it will be any help, sorry):
  
  
  Jason Walker wrote:
  
  
  
  Here is the query:
  
function ReturnPackageDescriptions($pack, $cat, $hotcat, $hotid){
$comIB = $cat .   . $pack .   . $hotcat .   . $hotid;
 $catLength = strlen($comIB);
 echo $catLength;
 $query = SELECT description from cpProducts where category='
  . $cat .   . $pack .   . $hotcat .   . $hotid . ';
 echo bR . $query . br;
echo combined package number =  . $comIB . br;
  $retval = ;
 $link =
  mysql_connect($config['host'],$config['user'],$config['pass']) or
  die(Could not connect);
 mysql_select_db('stc_store') or die(Unable to connect to
  the default database);
 $result = mysql_query($query) or die(Unable to pull
  the menu objects for main event details);
 echo mysql_affected_rows() . br;
   while ($results = mysql_fetch_array($result,
  MYSQL_ASSOC)){
extract($results);
  echo $description;
  $retval = $description;
 }
  mysql_free_result($result);
mysql_close($link);
 return $retval;
 }
  
  I have some extra 'echo' statements to see the progress on the web page.
  If I remove the 'where' clause within the SQL statement, I get rows. But
  when I add the 'where' portion, no records are returned.
  
  Here is an example of what the query looks like:
  
  $query example = SELECT description from cpProducts where category='39 47
  48 172'
  
  I'll assume that your table has a field named 'category' - otherwise the
  statement should throw you a big error :-) BUT is it a character data field
  (i.e. does it contain text)? AND do you actually have rows where the value
  of the category field is '39 47 48 172' - in order to get rows returned
  when running your example query the value needs to match this string
  EXACTLY.
  
  Given the fact that using mysql control center give you the desired result
  the above probably was a waste of time typing. Given that fact the only
  thing I can think of is that you have a extra space floating about (but I
  can't see it in the code your provided)
  
  does the output of mysql_error() provide any feedback?
  
  (what an odd problem!)
  
  
  
  When I run the same query in MYSQL Control center or Query Browser, no
  problem. I use this function template for my SELECT statements.
  
  Please let me know if there is something missing from the code.
  
  Thanks.
  
  
  
  
  
  Jason Walker
  
  [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
  
  http://www.desktophero.com
  
  
  
  
  
  No virus found in this outgoing message.
  Checked by AVG Anti-Virus.
  Version: 7.0.298 / Virus Database: 265.6.8 - Release Date: 1/3/2005
  
  
  
  
  
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: 

RE: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Hutchins, Richard
What version of PHP?
What version of MySQL?

-Original Message-
From: Jason Davis [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 06, 2005 10:42 AM
To: php-db@lists.php.net
Subject: [PHP-DB] Trying to connext to MySQL with PEAR


Hi all I am new to PHP and am trying to connect to mysql for the first time.
I get activity on the mysql monitor when I run it, but get the following
error.

DB Error: connect failed

The lines of code are:
require_once( DB.php );
$dsn = mysql://.DB_USER.:.DB_PASS.@.DB_SERVER./.DB_NAME;
echo $dsn;
$isPersistant = TRUE;
$db = DB::connect($dsn, $isPersistant);

if ( DB::isError( $db ) ) {
die ($db-getMessage());
}

The constants are properly defined and passing through to this page (checked
with echo), the database is created, the user has an account, and the
account has rights to do all funcitons on the db. Any thoughts on what might
be wrong?


Thanks
Jason

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

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



Re: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Jason Wong
On Thursday 06 January 2005 23:41, Jason Davis wrote:
 Hi all I am new to PHP and am trying to connect to mysql for the first
 time. 

In that case I strongly suggest that you at least vaguely familiarise yourself 
with using the basic PHP-native mysql_*() functions first. Go through the 
examples in the manual, learn how to:

- connect to the server
- select a database
- perform some simple queries
- retrieve the results of the queries
- handle errors

Whilst doing that you will have also confirmed whether your connection 
parameters (username/password/hostname/dbname) are correct.

 I get activity on the mysql monitor when I run it,  

What is this monitor? Doesn't it give any clearer indication of what is 
failing? Because this ...

 but get the following error.
 DB Error: connect failed

... seems to be an error produced by your Pear DB class and isn't very 
informative at all. If you do the above and use mysql_error() you'll get a 
more precise error message.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
New Year Resolution: Ignore top posted posts

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



RE: [PHP-DB] php problem

2005-01-06 Thread Tyler Replogle
whats the php info?
From: Serenity Schindler [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] php problem
Date: Thu, 6 Jan 2005 05:00:32 -0800 (PST)
MIME-Version: 1.0
Received: from lists.php.net ([216.92.131.4]) by mc10-f30.hotmail.com with 
Microsoft SMTPSVC(6.0.3790.211); Thu, 6 Jan 2005 05:01:36 -0800
Received: from ([216.92.131.4:19798] helo=pb1.pair.com)by pb1.pair.com 
(ecelerity HEAD (r3992M)) with SMTPid 40/9E-00694-0B63DD14 for 
[EMAIL PROTECTED]; Thu, 06 Jan 2005 08:01:36 -0500
Received: (qmail 33804 invoked by uid 1010); 6 Jan 2005 13:00:37 -
Received: (qmail 33790 invoked by uid 1010); 6 Jan 2005 13:00:37 -
X-Message-Info: 6sSXyD95QpW4Qlznwr+PaUISO5zVUEDYHmufcGYXiPw=
Return-Path: [EMAIL PROTECTED]
X-Host-Fingerprint: 216.92.131.4 lists.php.net  Mailing-List: contact 
[EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
list-help: mailto:[EMAIL PROTECTED]
list-unsubscribe: mailto:[EMAIL PROTECTED]
list-post: mailto:php-db@lists.php.net
Delivered-To: mailing list php-db@lists.php.net
Delivered-To: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
X-Host-Fingerprint: 206.190.38.234 web51803.mail.yahoo.com FreeBSD 4.7-5.2 
(or MacOS X 10.2-10.3) (2)
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;s=s1024; 
d=yahoo.com;b=U1nGI9pvlKE2Iv1QBvWXTvGWPvNX3mvrROr31XWwk/kszJ6mkDXfgQNuYpY9Z2iDEk/pI/c34RBx7hlEbjIgy5Bal0ecKHZjGXw3YeV7PJYmAoy6z2tHWWulSxFT8BfoAI4mEU7/gYX3wiev2DD9jG3V37cmjE/9VtYjvJq81K8= 
 ;
X-OriginalArrivalTime: 06 Jan 2005 13:01:36.0783 (UTC) 
FILETIME=[DADC71F0:01C4F3EF]

I am new to php and have no idea what I'm doing wrong. I have a file named 
test.php containing:

html
head
title PHP Test /title
/head
body
pThis is an HTML line
p
?php
   echo This is a PHP line;
   phpinfo();
?
/body
/html
The html lines show up just fine but none of the php info is displayed. Any 
ideas?

~Serenity~

-
Do you Yahoo!?
 Yahoo! Mail - You care about security. So do we.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Jason Davis
Pear DB version is 1.6.8


Jason Davis [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 MySQL 4.1
 PHP 4.3.10
 PEAR 0.5.0 (I think, not sure how to test that)

 On two different boxes
 one is an XP Pro box
 one is an Win2K Pro Box

 both running IIS

 Richard Hutchins [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  What version of PHP?
  What version of MySQL?
 
  -Original Message-
  From: Jason Davis [mailto:[EMAIL PROTECTED]
  Sent: Thursday, January 06, 2005 10:42 AM
  To: php-db@lists.php.net
  Subject: [PHP-DB] Trying to connext to MySQL with PEAR
 
 
  Hi all I am new to PHP and am trying to connect to mysql for the first
 time.
  I get activity on the mysql monitor when I run it, but get the following
  error.
 
  DB Error: connect failed
 
  The lines of code are:
  require_once( DB.php );
  $dsn = mysql://.DB_USER.:.DB_PASS.@.DB_SERVER./.DB_NAME;
  echo $dsn;
  $isPersistant = TRUE;
  $db = DB::connect($dsn, $isPersistant);
 
  if ( DB::isError( $db ) ) {
  die ($db-getMessage());
  }
 
  The constants are properly defined and passing through to this page
 (checked
  with echo), the database is created, the user has an account, and the
  account has rights to do all funcitons on the db. Any thoughts on what
 might
  be wrong?
 
 
  Thanks
  Jason
 
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php

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



Re: [PHP-DB] PHP query to mysql database returns emtpy data, butQuery Browser shows records

2005-01-06 Thread Jochem Maas
jwalker wrote:
No the category field is varchar(250) and uses spaces to parse each element within the field. 

The database is an osCommerce hybrid - not my own. The values within the category field go from one number to an X set of numbers, separated by spaces. This is making development rather difficult and painful.
Jason,
I thought it was something like that - sounds nasty, you poor man!
anyway can you confirm that the value in your where clause (as given in 
your example query) actually exists in the DB.

also things to try maybe:
1. test the problem on another machine
2. update php to latest release of you version (probably php4)
3. cut and paste a known value from the category field out of the DB and 
perform the query again with this value pasted into the query literally 
(rather than building the value from the various vars) to confirm the 
problem.

good luck

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


Re: [PHP-DB] str_replace question

2005-01-06 Thread Jochem Maas
Norland, Martin wrote:
-Original Message-
From: Bastien Koert [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 06, 2005 8:34 AM
Subject: Re: [PHP-DB] str_replace question

[snip]
A neat little trick would be to create the initial part of the
statement with a predefined where clause based on some record state. For
instance, we use a record_deleted field, since we don't delete data. He
could start his statement by automatically looking for it
select * from tablename where record_deleted = 'No'
then any additional clauses that get added all require the AND
keyword. No more problem
bastien

Alternatively, as mentioned before - something that evaluates to true.
The Answer**:
select * from tablename where 42
** to Life, the Universe, and Everything.
your killing me, Martin! :-)
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Jason Davis
MySQL 4.1
PHP 4.3.10
PEAR 0.5.0 (I think, not sure how to test that)

On two different boxes
one is an XP Pro box
one is an Win2K Pro Box

both running IIS

Richard Hutchins [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 What version of PHP?
 What version of MySQL?

 -Original Message-
 From: Jason Davis [mailto:[EMAIL PROTECTED]
 Sent: Thursday, January 06, 2005 10:42 AM
 To: php-db@lists.php.net
 Subject: [PHP-DB] Trying to connext to MySQL with PEAR


 Hi all I am new to PHP and am trying to connect to mysql for the first
time.
 I get activity on the mysql monitor when I run it, but get the following
 error.

 DB Error: connect failed

 The lines of code are:
 require_once( DB.php );
 $dsn = mysql://.DB_USER.:.DB_PASS.@.DB_SERVER./.DB_NAME;
 echo $dsn;
 $isPersistant = TRUE;
 $db = DB::connect($dsn, $isPersistant);

 if ( DB::isError( $db ) ) {
 die ($db-getMessage());
 }

 The constants are properly defined and passing through to this page
(checked
 with echo), the database is created, the user has an account, and the
 account has rights to do all funcitons on the db. Any thoughts on what
might
 be wrong?


 Thanks
 Jason

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

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



Re: [PHP-DB] str_replace question

2005-01-06 Thread Jochem Maas
Brent Baisley wrote:
I can't think of an instance where a query would have the phrase WHERE 
AND. Perhaps if you post the contents of the $additionalsql variable, 
we can tell you why it's not working.
You may actually be looking to use an array 
tried to explain that to him already, either he ignored it or its too 
complex - can't say because he never responded.

for your search words in 
str_replace(), or perhaps grep.

On Jan 5, 2005, at 8:05 PM, Chris Payne wrote:
Hi there everyone,

Im having a weird problem and Im not sure why, if I try to replace 
WHERE
AND with just WHERE it wont do it, but if I try to replace WHERE or 
AND by
themselves it WILL do it, but I cannot replace BOTH of them from a single
string, is something wrong below?


$additionalsql = str_replace(WHERE AND, WHERE, $additionalsql);

Basically Im trying to replace WHERE AND with just WHERE as Im 
building a
very complex SQL query and its a difficult one, and I have a solution 
that
works perfectly but I need this to work in order to do it.


I would appreciate any help on this, as its very important.

Chris
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.296 / Virus Database: 265.6.7 - Release Date: 12/30/2004

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


Re: [PHP-DB] PHP connect to mysql problem

2005-01-06 Thread Andrew Kreps
On Wed, 5 Jan 2005 15:25:21 +0300, Tsegaye Woldegebriel
[EMAIL PROTECTED] wrote:
 Anybody help!
 I can't connect from my PHP to mysql using the following code:
 $link = mysql_connect(localhost, root, merkato)
or die(Could not connect :  . mysql_error());
 it replies with error:
 Could not connect : Client does not support authentication protocol
 requested by server; consider upgrading MySQL client
 

It sounds like you're using the MySQL 3.x or 4.0 client to try to
connect to a 4.1 MySQL server.  MySQL 4.1 uses a different password
encryption (as you found), and you should update the PHP MySQL client
library to make it work.  You can also change the password encryption
on the MySQL server to make this work, although you'd be defeating a
security measure in doing so.  Have a look here:

http://dev.mysql.com/doc/mysql/en/Old_client.html

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



Re: [PHP-DB] MySQL Auto PK

2005-01-06 Thread Andrew Kreps
On Wed, 05 Jan 2005 18:11:23 -0500, John Holmes
[EMAIL PROTECTED] wrote:
 OOzy Pal wrote:
  Is it possible to have mysql at an ID as 20050105-1 as
  (MMDD-1), -2, etc.
 
 automatically? No. But you can always just use
 
 SELECT CONCAT(date_column,'-',pk_column) AS fixed_id ...
 
 if you _really_ need something like this. Or just join them together in
 PHP.

I think the only downside to that solution is that the primary key
will continue to increment regardless of the day, and I think the
original poster wanted:

20050105-1
20050105-2
20050106-1
...etc.

This would be a great place for a stored procedure, but I don't know
if I can recommend running MySQL 5 to you.  The most platform-safe way
I can think of is to get a count(*) of the number of rows with today's
date, add 1 to it, and stick that number on the end of the string
you've created to insert into a varchar field.  It's an extra query
per insert, but it'd do the job.

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



Re: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread James Pancoast
In my (very) limited experience with PEAR::DB, I've found that
getMessage() doesn't give very verbose error messages :).

So if I'm really having a problem, I do all 4 of these:

echo 'Standard Message: ' . $db-getMessage() . br\n;
echo 'Standard Code: ' . $db-getCode() . br\n;
echo 'DBMS/User Message: ' . $db-getUserInfo() . br\n;
echo 'DBMS/Debug Message: ' . $db-getDebugInfo() . br\n;


At least for me, this gives me a lot more useful information (DB
1.6.8, but PHP 5.0.3).  Hope this helps.

On Thu, 6 Jan 2005 11:42:03 -0500, Jason Davis [EMAIL PROTECTED] wrote:
 Pear DB version is 1.6.8
 
 
 Jason Davis [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  MySQL 4.1
  PHP 4.3.10
  PEAR 0.5.0 (I think, not sure how to test that)
 
  On two different boxes
  one is an XP Pro box
  one is an Win2K Pro Box
 
  both running IIS
 
  Richard Hutchins [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   What version of PHP?
   What version of MySQL?
  
   -Original Message-
   From: Jason Davis [mailto:[EMAIL PROTECTED]
   Sent: Thursday, January 06, 2005 10:42 AM
   To: php-db@lists.php.net
   Subject: [PHP-DB] Trying to connext to MySQL with PEAR
  
  
   Hi all I am new to PHP and am trying to connect to mysql for the first
  time.
   I get activity on the mysql monitor when I run it, but get the following
   error.
  
   DB Error: connect failed
  
   The lines of code are:
   require_once( DB.php );
   $dsn = mysql://.DB_USER.:.DB_PASS.@.DB_SERVER./.DB_NAME;
   echo $dsn;
   $isPersistant = TRUE;
   $db = DB::connect($dsn, $isPersistant);
  
   if ( DB::isError( $db ) ) {
   die ($db-getMessage());
   }
  
   The constants are properly defined and passing through to this page
  (checked
   with echo), the database is created, the user has an account, and the
   account has rights to do all funcitons on the db. Any thoughts on what
  might
   be wrong?
  
  

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



Re: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Jason Davis
Ok tried that and go this error message instead.

Client does not support authentication protocol requested by server;
consider upgrading MySQL client

Going to MySQL site to try to figure out what this means/which other clients
are available.

Jason Davis

Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Thursday 06 January 2005 23:41, Jason Davis wrote:
  Hi all I am new to PHP and am trying to connect to mysql for the first
  time.

 In that case I strongly suggest that you at least vaguely familiarise
yourself
 with using the basic PHP-native mysql_*() functions first. Go through the
 examples in the manual, learn how to:

 - connect to the server
 - select a database
 - perform some simple queries
 - retrieve the results of the queries
 - handle errors

 Whilst doing that you will have also confirmed whether your connection
 parameters (username/password/hostname/dbname) are correct.

  I get activity on the mysql monitor when I run it,

 What is this monitor? Doesn't it give any clearer indication of what is
 failing? Because this ...

  but get the following error.
  DB Error: connect failed

 ... seems to be an error produced by your Pear DB class and isn't very
 informative at all. If you do the above and use mysql_error() you'll get a
 more precise error message.

 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-db
 --
 New Year Resolution: Ignore top posted posts

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



Re: [PHP-DB] Update / Delete / Insert quandry

2005-01-06 Thread Andrew Kreps
On Thu, 6 Jan 2005 07:28:32 -0800 (PST), Stuart Felenstein
[EMAIL PROTECTED] wrote:
 
 The problem I'm having a hard time getting my hands
 around are those areas where they can have multiple
 entries.
 
 One of the tables allows for a user to enter up to 5
 choices. The table would look like this:
 

I think you need to have a primary key that's unique per record.  That
would allow you to make modifications per record without worrying
about the duplicated RecordID.

As far as updates and additions go, I usually keep the two separate
when designing applications.  Being able to update multiple rows at
once shouldn't be a problem, you just select all the data, display it
to your users with the appropriate form elements (select boxes, check
boxes and such), and index it in your form by the unique id field.

I don't think it's necessary to delete the records and reload them,
doing that adds database load and increases the chance that something
will go wrong.  I hope I've touched on the items that concern you,
feel free to write back if you need more information.

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



Re: [PHP-DB] select text from a text file

2005-01-06 Thread Andrew Kreps
On Wed, 5 Jan 2005 11:58:59 -, Ed [EMAIL PROTECTED] wrote:
 Happy new year folks!
 
 The titlemight make this seem like an easy to answer question
 
 However here's the complicated bit (well for me anyway).
 
 In my text file that is written to by the users in a chatroom it looks like 
 this:
 
 nickname||color||what the user is saying||user
 
 how can i make it so that if they have a private message when they press 
 update it pulls the message from the text file and displays it in the frame 
 but also deletes the text?
 

You should be using a database for this, it makes things so much
easier.  That being said, here's one way to go about the text file
version:

Open the file, read through it line by line.
As you read it, push the lines into an array.
If you find a private message for the user, store that in a variable,
and do not push it into the array.
Finish reading the file.
If there's a private message, you've got it in a variable, and you can
overwrite the private message file with the array you've stored, which
is all of the current private messages minus the one you're about to
display.

Please note, this does not scale at all, especially in the fast-paced
world of chat rooms.  You will likely end up with file locking
problems if you proceed with the flat-file method.


 Also, how can i make it so that if in a drop down menu they select the word 
 everybody it goes to a file called messages.txt and if they select user 
 or user2 or user3 from the list it writes to private.txt is this at all 
 possible? user and user2 etc arent hardcoded it's pulling the names from a 
 list of online users.
 

Are you talking about appending messages to a text file?  In that
case, you can have the dropdown submit with the message, and in the
PHP code have a case for 'everybody' where it writes to messages.txt,
and if it's not 'everybody', write it to private.txt with the username
that was selected from the dropdown as part of the row.

Does that answer your question?

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



Re: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Jason Davis
This helped a LOT! With that info I was able to figure out that I need to do
this. http://dev.mysql.com/doc/mysql/en/Old_client.html
Thanks everyone,

Jason Davis


Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Thursday 06 January 2005 23:41, Jason Davis wrote:
  Hi all I am new to PHP and am trying to connect to mysql for the first
  time.

 In that case I strongly suggest that you at least vaguely familiarise
yourself
 with using the basic PHP-native mysql_*() functions first. Go through the
 examples in the manual, learn how to:

 - connect to the server
 - select a database
 - perform some simple queries
 - retrieve the results of the queries
 - handle errors

 Whilst doing that you will have also confirmed whether your connection
 parameters (username/password/hostname/dbname) are correct.

  I get activity on the mysql monitor when I run it,

 What is this monitor? Doesn't it give any clearer indication of what is
 failing? Because this ...

  but get the following error.
  DB Error: connect failed

 ... seems to be an error produced by your Pear DB class and isn't very
 informative at all. If you do the above and use mysql_error() you'll get a
 more precise error message.

 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-db
 --
 New Year Resolution: Ignore top posted posts


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



[PHP-DB] Warnings and Notices

2005-01-06 Thread Jason Davis
I just got the software I was fighting with working. Only issue now is that
the top of the page is filled with notices and warnings, even though the
code is working. Is there any way to turn off or hide these notifications?

Jason

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



RE: [PHP-DB] Stopping display of DB errors

2005-01-06 Thread Norland, Martin
 -Original Message-
 From: Todd Cary [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, January 06, 2005 11:36 AM
 Subject: [PHP-DB] Stopping display of DB errors
 
 When I run a query using Interbase and if an error occurs, the error
displays in the browser window even though I am testing for errors.  Is
there a way to prevent this?

Suppress the error by prefixing the function with @:

$sthdl  = @ibase_query($stmnt,$dbh);  -- won't display error
regardless

Cheers,
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


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



RE: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 06 January 2005 16:39, Jochem Maas wrote:

 Hutchins, Richard wrote:
  echo $dsn; $isPersistant = TRUE;
 
 doesn't effect the code but 'Persistant' is spelled 'Persistent'

Oh dear, as a fully-paid-up pedant, I'm afriad I can't resist this one:

Doesn't affect the answer, but this occurrence of 'effect' should be
'affect'. ;)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP-DB] Re: Warnings and Notices

2005-01-06 Thread Jason Davis
Figured it out myself. Changed PHP.ini to read
error_reporting = E_ALL  ~E_NOTICE
instead of
error_reporting = E_ALL

Jason Davis [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I just got the software I was fighting with working. Only issue now is
that
 the top of the page is filled with notices and warnings, even though the
 code is working. Is there any way to turn off or hide these notifications?

 Jason

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



Re: [PHP-DB] Update / Delete / Insert quandry

2005-01-06 Thread Stuart Felenstein

--- Andrew Kreps [EMAIL PROTECTED] wrote:

 On Thu, 6 Jan 2005 07:28:32 -0800 (PST), Stuart
 Felenstein
 [EMAIL PROTECTED] wrote:
  
  The problem I'm having a hard time getting my
 hands
  around are those areas where they can have
 multiple
  entries.
  
  One of the tables allows for a user to enter up to
 5
  choices. The table would look like this:
  
 
 I think you need to have a primary key that's unique
 per record.  That
 would allow you to make modifications per record
 without worrying
 about the duplicated RecordID.

I don't think it would kill me to add an auto inc
primary id.  Currently both the recordID and the
TypeID are set up as primary id's.  Also have a unique
index using both fields.  The recordID though should
be duplicated though as it ties the records from the
various tables together to form the profile.

 As far as updates and additions go, I usually keep
 the two separate
 when designing applications.  Being able to update
 multiple rows at
 once shouldn't be a problem, you just select all the
 data, display it
 to your users with the appropriate form elements
 (select boxes, check
 boxes and such), and index it in your form by the
 unique id field.

Okay, makes sense to me.


 I don't think it's necessary to delete the records
 and reload them,
 doing that adds database load and increases the
 chance that something
 will go wrong.  I hope I've touched on the items
 that concern you,
 feel free to write back if you need more
 information.


Thank you, I think I'm straight for now!

Stuart

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



Re: [PHP-DB] MySQL Auto PK

2005-01-06 Thread Jason Wong
On Friday 07 January 2005 02:29, Andrew Kreps wrote:

 This would be a great place for a stored procedure, but I don't know
 if I can recommend running MySQL 5 to you.  The most platform-safe way
 I can think of is to get a count(*) of the number of rows with today's
 date, add 1 to it, and stick that number on the end of the string
 you've created to insert into a varchar field.  It's an extra query
 per insert, but it'd do the job.

Don't forget to WRITE lock the table before counting, and only unlock after 
inserting the new id.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
New Year Resolution: Ignore top posted posts

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



[PHP-DB] mssql_connect issues

2005-01-06 Thread Philip Thompson
Hi all.
I have worked with a MySQL database a whole lot, but never really an MS 
SQL database before. Here's the problem I'm having. I call this 
function and then nothing else happens. No other information shows up 
on the page.

$link = mssql_connect(myServer, me, pw);
Of course, I replace the values here with the real ones, but nothing 
happens. I know the database exists b/c I am looking at it right now.

If I echo something to the screen before this call, then it shows. If I 
echo something after, it does not show. If I add or die (...) after 
the function call, it does not show. I'm kinda lost on what it could be 
at this point. I have commented out everything else that it could 
potentially be so that I know it's this line. I get no error message... 
I just get nothing.

Any thoughts? Thanks in advance,
~Philip
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] mssql_connect

2005-01-06 Thread Philip Thompson
Hi again all!
Right after I sent the email... I think I figured out what it was! I do 
not have it `uncommented` in my php.ini file! Therefore, none of the 
mssql_* functions would work.

Sorry for that last email.
~Philip
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] terminates string?

2005-01-06 Thread Gabino Travassos
Hey Matthew
Example: index..php?id=4539page=dest.phpwig=top
From this url example I can use the following variables:
$id='4539';
$page='dest.php';
$wig='top';
for ampersands, use %26
the same way that spaces are %20 in URLs
So, if I wanted to pass a variable that had an ampersand in it, like Tony  
Tina's Wedding
page=Tony%20%26%20Tina%27s%20Wedding

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


RE: [PHP-DB] MySQL Auto PK

2005-01-06 Thread Norland, Martin
 -Original Message-
 From: Andrew Kreps [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, January 06, 2005 12:30 PM
 Subject: Re: [PHP-DB] MySQL Auto PK
 
 On Wed, 05 Jan 2005 18:11:23 -0500, John Holmes
[EMAIL PROTECTED] wrote:
  OOzy Pal wrote:
   Is it possible to have mysql at an ID as 20050105-1 as
(MMDD-1), 
   -2, etc.
  
  automatically? No. But you can always just use
  SELECT CONCAT(date_column,'-',pk_column) AS fixed_id ...
  if you _really_ need something like this. Or just join them together
in PHP.
 
 I think the only downside to that solution is that the primary key
will continue to increment regardless of the day, and I think the
original poster wanted:
 
 20050105-1
 20050105-2
 20050106-1
 ...etc.
 
 This would be a great place for a stored procedure, but I don't know
if I can recommend running MySQL 5 to you.  The most platform-safe way I
can think of is to get a count(*) of the number of rows with today's
date, add 1 to it, and stick that number on the end of the string you've
created to insert into a varchar field.  It's an extra query per insert,
but it'd do the  job.

Doing a count and tagging the number on the back could result in race
conditions with a much larger window than one would prefer (albeit still
small).  Wouldn't tagging the time on the end of the date accomplish the
overall goal?  You can pull them from the database as is (with their
full date/time - ordered by such) and then trim the date out (mysql
could even do this for you) and tag on -$rownum.  Still, no atomicity
for guarantee of uniqueness.

The primary key should be used solely for unique identification
purposes, how it looks visually should be of little concern/interest -
at least, given the data I've seen so far (e.g. it's just based on
date/time).  This really seems like a perfect candidate for an
autoincrement and a separate date / datetime field.

Cheers,
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


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



Re: [PHP-DB] terminates string?

2005-01-06 Thread Jochem Maas
Perry, Matthew (Fire Marshal's Office) wrote:
I am using PHP 4.3.1 and running Apache Server and MySQL.
The following question is probably only related to PHP.
 

Here is the problem:
 

I am passing the following string from one form to another:
../create.php?dest=Employee/menu_handleemployee.php?action=updateID=$ID
 

Here is the actual code:
form
action=../create.php?dest=Employee/menu_handleemployee.php?action=updateID
=?echo $ID;? method=post enctype=multipart/form-data
name=form1EMPLOYEE
 

When I view the source it comes out as expected:
form
action=../create.php?dest=Employee/menu_handleemployee.php?action=updateID
=82 

method=post enctype=multipart/form-data name=formEMPLOYEE
 

But after it goes to the next page it turns into this:
../create.php?dest=Employee/menu_handleemployee.php?action=update
Everything up to and after the '' disappears!!
that because PHP sees your URL as having two GET vars:
dest=Employee/menu_handleemployee.php?action=update
ID=82
the ampersand is the default name/value pair seperator.
try using urlencode() [and urldecode() when you actually want to 
redirect to that 'dest' url] on the redirect string when passing it 
along in the URL (or form field)

e.g.
$action = 
'../create.php?dest='.urlencode(Employee/menu_handleemployee.php?action=updateID=$ID);


and if that doesn't work try replacing the '' char with something else e.g.
$action = 
'../create.php?dest='.str_replace('','$$',Employee/menu_handleemployee.php?action=updateID=$ID);

and then before your redirect to that url reverse the replacement e.g.:
header('location: ' . 
str_replace('$$','',Employee/menu_handleemployee.php?action=updateID=$ID));
exit;


BTW: 2 dollar signs may not be the best choice of chars to use.

another way of tackling the issue is by looking at the contents of 
$_SERVER (a auto superglobal var, just like $_GET, $_POST etc) - try:

print_r($_SERVER);
you'll be surprised what kinds of useful items are contained in that array.
while you're at it try:
print_r($_GET);
looking at the output of that will probably help you understand where 
the 'ID' bit of the redirect url went.

RANT
print_r() is your friend USE IT!!! OFTEN!!!
sing this as a reminder When in doubt print it out
[ (tm) Wong Coding Industries ;-) ]
/RANT
 

The goal of this code is to send the redirect address to the form that
modifies my data. 

I want variable dest to be used to dynamically redirect the page.
 

I have tried the following to fix the problem without avail:
1) I tried saving the variable in other ways such as text fields in the form
itself.
2) I tried addslashes() (which works well with similar problems related to
',  etc.).
3) I tried adding \ before 
4) I danced around my computer and threatened to pull the plug.
you forgot to wave the dead chicken around your head!
None of these worked!
 

 

What is it about '' that throws everything off with PHP variables?  It
doesn't seem to be a problem with HTML.
its the default request name/value pair seperator.
This is exceedingly difficult to research online because '' is excluded
from most search engines automatically.
it's called an ampersand. which might help further searching.
 

-Matthew
 

 

 


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


Re: [PHP-DB] Stopping display of DB errors

2005-01-06 Thread Jochem Maas
Todd Cary wrote:
When I run a query using Interbase and if an error occurs, the error 
displays in the browser window even though I am testing for errors.  Is 
there a way to prevent this?

 function db_insert_logon_session($dbh, $sessionid, $offset) {
   $fulldate = date(m/d/Y H:i:s,time() + $offset);
   $stmnt = INSERT INTO SESSION (SES_ID, SES_EXPIRE)  .
VALUES( . $sessionid . , .
' . $fulldate . ');
//echo('Query: ' . $stmnt . 'br');
OK Todd, listen the fuck up :-)
you are missing one of the greatest things about the interbase 
extension, parameterized queries, try doing it like this:

$fulldate = date(m/d/Y H:i:s,time() + $offset);
$stmnt = 'INSERT INTO SESSION (SES_ID, SES_EXPIRE) VALUES(?,?)'
$sthdl  = @ibase_query($stmnt,$dbh, array($sessionid,$fulldate));
do it like that and you have just made SQL injection hacks an 
impossiblity :-), and stray quotes in text strings being entered into 
the DB will never again break your queries.

suck on that MySQL.
   $sthdl  = ibase_query($stmnt,$dbh);  -- displays error regardless
$sthdl  = @ibase_query($stmnt,$dbh);  -- shouldnt displays error
   if ($sthdl) ibase_commit();
   else print(Error:  . ibase_errmsg() . br);
   return $sthdl;
 };
BTW: the interbase extension was rewritten for PHP5, I don't know 
whether this was backported to PHP4 - the guy that did it is a friend of 
mine though so I'll ask about that - anyway the reason that I mention 
this is is that I don't have your problem and I use PHP5 for my 
firebird/php (the interbase extension is also used for firebird)

having said that I have a custom DB class for interbase/firebird which 
uses the following construction:

$res = call_user_func_array('ibase_query', array_values($args));
this is to do with parameterized queries (the number of args is 
obviously variable).


for anyone who reads this far know this:
Todd is a superior human being cos he uses a superior DB ;-)
MySQL is a single-celled organism next to the space-faring superbeing 
that is firebird (ok interbase too, but that aint open source)

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


Re: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Jason Wong
On Friday 07 January 2005 03:12, Ford, Mike wrote:
 Oh dear, as a fully-paid-up pedant, I'm afriad I can't resist this one:

I'm afraid it's afraid ... :-)

 Doesn't affect the answer, but this occurrence of 'effect' should be
 'affect'. ;)

Yeah and it annoys me too when people mix up you're and your, and just to 
annoy the Americans, it's ensure and not insure!

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
New Year Resolution: Ignore top posted posts

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



RE: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Norland, Martin
 -Original Message-
 From: Ford, Mike [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, January 06, 2005 1:13 PM
 Subject: RE: [PHP-DB] Trying to connext to MySQL with PEAR
[snip]
 Oh dear, as a fully-paid-up pedant, I'm afriad I can't resist this
one:
 
 Doesn't affect the answer, but this occurrence of 'effect' should be
'affect'. ;)
 
 Cheers!
 
 Mike

* Joining in on the fun *

I'm afraid you spelled afraid incorrectly.  I'll be sending you the bill
for my services related to this matter.

:)

- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


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



Re: [PHP-DB] MySQL Auto PK

2005-01-06 Thread Jochem Maas
Andrew Kreps wrote:
...
20050105-1
20050105-2
20050106-1
...etc.
This would be a great place for a stored procedure, but I don't know
if I can recommend running MySQL 5 to you.  The most platform-safe way
an open source alternative that does offer this enterprise level 
functionality (stored procedures) is firebird. and its based on proven 
tech. (interbase), not to mention its not bleeding edge (firebird stayed 
in beta so long that if it had been a microsoft product it would have 
gone gold, shipped, and been put to pasture ;-).

but firebird is a little more difficult to get into than MySQL and you 
may not have access to hosting that provides it.

I can think of is to get a count(*) of the number of rows with today's
date, add 1 to it, and stick that number on the end of the string
you've created to insert into a varchar field.  It's an extra query
per insert, but it'd do the job.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Warnings and Notices

2005-01-06 Thread Jochem Maas
Jason Davis wrote:
I just got the software I was fighting with working. Only issue now is that
the top of the page is filled with notices and warnings, even though the
code is working. Is there any way to turn off or hide these notifications?
read them and fix your code is one way.
another is to turn down error reporting:
http://nl2.php.net/error_reporting
Jason
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Jochem Maas
Ford, Mike wrote:
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

On 06 January 2005 16:39, Jochem Maas wrote:

Hutchins, Richard wrote:
echo $dsn; $isPersistant = TRUE;
doesn't effect the code but 'Persistant' is spelled 'Persistent'

Oh dear, as a fully-paid-up pedant, I'm afriad I can't resist this one:
Doesn't affect the answer, but this occurrence of 'effect' should be
'affect'. ;)
DOH! :-)
Cheers!
Mike
-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] I'm trying to out perform Martin Norland....

2005-01-06 Thread Jochem Maas
in terms of helpfulness and volume of replies to Q's on this list 
;-)  but it doesn't help that my mails seem to take hours to reach the 
list (Martin's keep beating mine to show up).

is the list-server against me? or do others also see loads of lag?
rgds,
Jochem
PS - as an even bigger kick in the face - I had the term 'o f f t o p i 
c' (without the spaces) and the list bounced my message:

php-db@lists.php.net: host pair1.php.net[216.92.131.4] said: 550 
Apparent off-topic email rejected. (in reply to end of DATA command)

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


Re: [PHP-DB] Warnings and Notices

2005-01-06 Thread Janet Valade
Jason Davis wrote:
I just got the software I was fighting with working. Only issue now is that
the top of the page is filled with notices and warnings, even though the
code is working. Is there any way to turn off or hide these notifications?
You can set the error level in php.ini, using the description there. You 
can also set the error level per script, as follows:

http://www.php.net/manual/en/function.error-reporting.php
You can stop errors being displayed altogether. See display_errors in 
your php.ini file.

You can send your errors to a log file.
http://www.php.net/manual/en/function.error-log.php
You can stop individual warnings and messages by putting a @ in front of 
them.

Janet

--
Janet Valade -- janet.valade.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] SQL statement syntaxis

2005-01-06 Thread PHPDiscuss - PHP Newsgroups and mailing lists
Hello everybody,
I'm building a small application and I have trouble passing a POST
variable form one page to another inside the SQL statement.

The query (displayed below) works great without the
.$_POST['CompanyName']. 

$query_company_listing = SELECT CompanyID, CompanyName,
CompanyOrDepartment, BillingAddress, City, PostalCode, PhoneNumber FROM
company WHERE company.CompanyName=.$_POST['CompanyName'].  ORDER BY
CompanyName ASC;

But it messes up if I include it because the first  is considered as the
end of the previous one and so on. So the code gets messed up.

Any help will be greatly appreciated!
Have everybody a wonderful 2005!
Jorge

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



[PHP-DB] SQL statement syntaxis

2005-01-06 Thread PHPDiscuss - PHP Newsgroups and mailing lists
Hello everybody,
I'm building a small application and I have trouble passing a POST
variable form one page to another inside the SQL statement.

The query (displayed below) works great without the
.$_POST['CompanyName']. 

$query_company_listing = SELECT CompanyID, CompanyName,
CompanyOrDepartment, BillingAddress, City, PostalCode, PhoneNumber FROM
company WHERE company.CompanyName=.$_POST['CompanyName'].  ORDER BY
CompanyName ASC;

But it messes up if I include it because the first  is considered as the
end of the previous one and so on. So the code gets messed up.

Any help will be greatly appreciated!
Have everybody a wonderful 2005!
Jorge

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



[PHP-DB] SQL statement

2005-01-06 Thread PHPDiscuss - PHP Newsgroups and mailing lists
Hello everybody,
I'm building a small application and I have trouble passing a POST
variable form one page to another inside the SQL statement.

The query displayed below works great without the
.$_POST['CompanyName']. 

$query_company_listing = SELECT CompanyID, CompanyName,
CompanyOrDepartment, BillingAddress, City, PostalCode, PhoneNumber FROM
company WHERE company.CompanyName=.$_POST['CompanyName'].  ORDER BY
CompanyName ASC;

But it messes up if I include it because the first  is considered as the
end of the previous one and so on, so the code gets messed up.

I'll really appreciate any/all help!
Have you all an excellent year!
Jorge

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



Re: [PHP-DB] PHP query to mysql database returns emtpy data, but Query Browser shows records

2005-01-06 Thread graeme
Sorry I was in a hurry for lunch.. I meant category='39 ' OR category 
'47' etc...  which of course the IN clause would address.

But if it is a character string '39 47 48 172' that is required then 
double check the number of spaces that are required against those that 
are produced. Maybe is is a double digit and two spaces trip[le digit 
and one? Without an example of the data and what is produced it's hard 
to help.

graeme
Jochem Maas wrote:
graeme wrote:
Hi,
You have:
$query example = SELECT description from cpProducts where 
category='39 47 48 172'

don't you want to add a logical operator such as OR, possibly AND
$query example = SELECT description from cpProducts where 
category='39 OR 47 OR 48 OR 172'

graeme.

whatever it is that he is trying to do - I doubt he wants to put 'OR's 
in the character string, besides which AFAIK you can't do something like:

SELECT description from cpProducts where category=39 OR 47 OR 48 OR 172;
(possibly the SQL above will actually return all rows because any 
number greater than zero will evaluate to true - e.g. ($x = true || 1) 
is always true regardless of the value of $x, I am assuming the same 
general logic goes for SQL or'ing)
it should be:

SELECT description from cpProducts where category=39 OR 47 OR 48 OR 172;
Jason, read on for more (possible) help (well I gave it a shot but I 
don't think it will be any help, sorry):


Jason Walker wrote:
 

Here is the query:
 function ReturnPackageDescriptions($pack, $cat, $hotcat, $hotid){
 $comIB = $cat .   . $pack .   . $hotcat .   . 
$hotid;
  $catLength = strlen($comIB);
  echo $catLength;
  $query = SELECT description from cpProducts where 
category=' . $cat .   . $pack .   . $hotcat .   . $hotid . ';
  echo bR . $query . br;
 echo combined package number =  . $comIB . br;
   $retval = ;
  $link = 
mysql_connect($config['host'],$config['user'],$config['pass']) or 
die(Could not connect);
  mysql_select_db('stc_store') or die(Unable to connect 
to the default database);
  $result = mysql_query($query) or die(Unable to 
pull the menu objects for main event details);
  echo mysql_affected_rows() . br;
while ($results = mysql_fetch_array($result, 
MYSQL_ASSOC)){
 extract($results);
   echo $description;
   $retval = $description;
  }
   mysql_free_result($result);
 mysql_close($link);
  return $retval;
  }

I have some extra 'echo' statements to see the progress on the web 
page. If I remove the 'where' clause within the SQL statement, I get 
rows. But when I add the 'where' portion, no records are returned.

Here is an example of what the query looks like:
$query example = SELECT description from cpProducts where 
category='39 47 48 172'

I'll assume that your table has a field named 'category' - otherwise 
the statement should throw you a big error :-) BUT is it a character 
data field (i.e. does it contain text)? AND do you actually have rows 
where the value of the category field is '39 47 48 172' - in order to 
get rows returned when running your example query the value needs to 
match this string EXACTLY.

Given the fact that using mysql control center give you the desired 
result the above probably was a waste of time typing. Given that fact 
the only thing I can think of is that you have a extra space floating 
about (but I can't see it in the code your provided)

does the output of mysql_error() provide any feedback?
(what an odd problem!)

When I run the same query in MYSQL Control center or Query Browser, 
no problem. I use this function template for my SELECT statements.

Please let me know if there is something missing from the code.
Thanks.
 

 

Jason Walker
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
http://www.desktophero.com
 

 

No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.8 - Release Date: 1/3/2005
 



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


RE: [PHP-DB] PHP query to mysql database returns emtpy data, but Query Browser shows records

2005-01-06 Thread Jason Walker


Graeme - you were moving in the right direction. Since the data in the field
is varchar(250), the only thing that changes is the fact that the last
number is 3 digits. Other page queries were also affected with 4 x 2 digit
numbers in the category field (eg. '37 48 49 52').

By adding '%' between each number and using 'LIKE' as opposed to '=', the
queries through PHP return the correct value.

I think is very strange as 3x numbers work fine when using spaces (' ')
between each criteria (as in '37 48 53').

The change would look something like:

SELECT description from cpProducts where category like '39%47%48%172'

There is something between each element, but PHP can not seem to handle the
third empty space.

Thanks to all for your help and ideas!


Jason Walker
[EMAIL PROTECTED]
http://www.desktophero.com
-Original Message-
From: graeme [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 06, 2005 7:55 PM
To: Jochem Maas
Cc: Jason Walker; php-db@lists.php.net
Subject: Re: [PHP-DB] PHP query to mysql database returns emtpy data, but
Query Browser shows records

Sorry I was in a hurry for lunch.. I meant category='39 ' OR category 
'47' etc...  which of course the IN clause would address.

But if it is a character string '39 47 48 172' that is required then 
double check the number of spaces that are required against those that 
are produced. Maybe is is a double digit and two spaces trip[le digit 
and one? Without an example of the data and what is produced it's hard 
to help.

graeme

Jochem Maas wrote:

 graeme wrote:

 Hi,

 You have:

 $query example = SELECT description from cpProducts where 
 category='39 47 48 172'

 don't you want to add a logical operator such as OR, possibly AND

 $query example = SELECT description from cpProducts where 
 category='39 OR 47 OR 48 OR 172'

 graeme.


 whatever it is that he is trying to do - I doubt he wants to put 'OR's 
 in the character string, besides which AFAIK you can't do something like:

 SELECT description from cpProducts where category=39 OR 47 OR 48 OR 172;

 (possibly the SQL above will actually return all rows because any 
 number greater than zero will evaluate to true - e.g. ($x = true || 1) 
 is always true regardless of the value of $x, I am assuming the same 
 general logic goes for SQL or'ing)
 it should be:

 SELECT description from cpProducts where category=39 OR 47 OR 48 OR 172;

 Jason, read on for more (possible) help (well I gave it a shot but I 
 don't think it will be any help, sorry):


 Jason Walker wrote:

  

 Here is the query:

  function ReturnPackageDescriptions($pack, $cat, $hotcat, $hotid){
  $comIB = $cat .   . $pack .   . $hotcat .   . 
 $hotid;
   $catLength = strlen($comIB);
   echo $catLength;
   $query = SELECT description from cpProducts where 
 category=' . $cat .   . $pack .   . $hotcat .   . $hotid . ';
   echo bR . $query . br;
  echo combined package number =  . $comIB . br;
$retval = ;
   $link = 
 mysql_connect($config['host'],$config['user'],$config['pass']) or 
 die(Could not connect);
   mysql_select_db('stc_store') or die(Unable to connect 
 to the default database);
   $result = mysql_query($query) or die(Unable to 
 pull the menu objects for main event details);
   echo mysql_affected_rows() . br;
 while ($results = mysql_fetch_array($result, 
 MYSQL_ASSOC)){
  extract($results);
echo $description;
$retval = $description;
   }
mysql_free_result($result);
  mysql_close($link);
   return $retval;
   }

 I have some extra 'echo' statements to see the progress on the web 
 page. If I remove the 'where' clause within the SQL statement, I get 
 rows. But when I add the 'where' portion, no records are returned.

 Here is an example of what the query looks like:

 $query example = SELECT description from cpProducts where 
 category='39 47 48 172'


 I'll assume that your table has a field named 'category' - otherwise 
 the statement should throw you a big error :-) BUT is it a character 
 data field (i.e. does it contain text)? AND do you actually have rows 
 where the value of the category field is '39 47 48 172' - in order to 
 get rows returned when running your example query the value needs to 
 match this string EXACTLY.

 Given the fact that using mysql control center give you the desired 
 result the above probably was a waste of time typing. Given that fact 
 the only thing I can think of is that you have a extra space floating 
 about (but I can't see it in the code your provided)

 does the output of mysql_error() provide any feedback?

 (what an odd problem!)



 When I run the same query in MYSQL Control center or Query Browser, 
 no problem. I use this function template for my SELECT statements.

 Please let me know if there is something missing from the 

RE: [PHP-DB] SQL statement

2005-01-06 Thread Jason Walker

First off - $_POST['CompanyName'] is valid, right?

Can you do something like this?:
if (isset($_POST['CompanyName'])){
$sqlCompanyName = $_POST['CompanyName'];
} else {
return them back to the form, or something?
}


$query_company_listing = SELECT CompanyID, CompanyName,
CompanyOrDepartment, BillingAddress, City, PostalCode, PhoneNumber FROM
company WHERE company.CompanyName='$sqlCompanyName' ORDER BY
CompanyName ASC;


Also, what datatype is CompanyName? If it is varchar - or really anything
else - I have had better look single quote encapsulation on the VALUE
portion of the query (company.CompanyName='VALUE' vs.
company.CompanyName=VALUE)

Not knowing the datatypes may make this an irrelevant point though.



-Original Message-
From: PHPDiscuss - PHP Newsgroups and mailing lists
[mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 06, 2005 12:09 PM
To: php-db@lists.php.net
Subject: [PHP-DB] SQL statement

Hello everybody,
I'm building a small application and I have trouble passing a POST
variable form one page to another inside the SQL statement.

The query displayed below works great without the
.$_POST['CompanyName']. 

$query_company_listing = SELECT CompanyID, CompanyName,
CompanyOrDepartment, BillingAddress, City, PostalCode, PhoneNumber FROM
company WHERE company.CompanyName=.$_POST['CompanyName'].  ORDER BY
CompanyName ASC;

But it messes up if I include it because the first  is considered as the
end of the previous one and so on, so the code gets messed up.

I'll really appreciate any/all help!
Have you all an excellent year!
Jorge

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



-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.8 - Release Date: 1/3/2005




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.8 - Release Date: 1/3/2005

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