Re: [PHP-DB] breaking apart data

2004-01-20 Thread CPT John W. Holmes
From: "Larry R. Sieting" <[EMAIL PROTECTED]>

> what would be the most efficient way to rework this data in to what I am
> after
>
> stored text:
> asdf asdf sadl jf lsakdjf a \r\n asdfierw aweiufasd asiuwr \r\n
> asdhfauiweuhrahsd \r\n
>
> displays text as:
> asdf asdf sadl jf lsakdjf a
> asdfierw aweiufasd asiuwr
> asdhfauiweuhrahsd
>
> I would like to highlight parts of the above.

What do you mean by "highlight" it? And how do you know what parts need to
be highlighted??

---John Holmes...

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



Re: [PHP-DB] Different character sets

2004-01-20 Thread CPT John W. Holmes
From: "Christine Clerc" <[EMAIL PROTECTED]>
> My pages collect short texts from different languages through HTML
> forms. The texts are stored in a MySQL database. Then, they are used
> in HTML pages.
>
> Problem 1 : the carriage returns don't show back up.

Yes they do. Look at the HTML source of your page and the newlines are
there. HTML doesn't recognize newlines, though. Use the nd2br() function or
some homegrown method to convert the newlines into  elements that HTML
understands.

---John Holmes...

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



Re: [PHP-DB] Unsubscribe (mailign lsits in general) question...

2004-01-20 Thread CPT John W. Holmes
What's this got to do with databases (PHP-DB list)? It's barely related to
PHP to begin with. Think about where your sending your messages before you
click the button.

---John Holmes...

- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 20, 2004 9:11 AM
Subject: [PHP-DB] Unsubscribe (mailign lsits in general) question...


> I've been told by my boss, that the law has changed in relation to 'Opt
> out' options on mailing lists etc...
> she tells me that I have to now change all my forms to conform.
>
> She claims that now, each time the user must click the 'remain subscribed'
> link, or we have to remove them from our mailing lists.
> Thus changing opt out, to opt in, EACH TIME?
> Is this true?
>
> She seems quite sure.
>
> We deal with both European and US clients (world wide to be honest, but
> most other countries don'e care about this.. do they?)
>
> Anyone heard of this before?
> Tris...

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



Re: [PHP-DB] SQL query...

2004-01-15 Thread CPT John W. Holmes
From: "Muhammed Mamedov" <[EMAIL PROTECTED]>


> Try this
>
>  "SELECT DISTINCT(file_name), Count(file_name) AS cnt FROM $table_name
WHERE
> date
> > BETWEEN '2003-10-01' AND '2003-12-31' group by file_name order by cnt;
> > desc"

If you're GROUPing by "file_name" then you don't need DISTINCT(file_name)...
it's redundant.

---John Holmes...

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



Re: [PHP-DB] date problem in MySQL DB

2004-01-13 Thread CPT John W. Holmes
From: "Angelo Zanetti" <[EMAIL PROTECTED]>

> This might be slightly off topic but hopefully someone can help.
> I have a field that is a varchar and I stored dates in it. But now I want
to
> change the type of the column to date, but I have a problem that the
formats
> differ:
>
> my format: mm/dd/
> mySQL format: -mm-dd
>
> So can I either:
> a. change the format of the date format
>
> or
>
> b. do i have to write a function that changes my format to the mySQL
before
> changing the column type??

You need to do option (b). Since this is a PHP list, I'd recommend
strtotime() and date() to do the formatting.

---John Holmes...

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



Re: [PHP-DB] inserting dynamic drop down menu data into mysql

2004-01-07 Thread CPT John W. Holmes
From: "Duane Barnes" <[EMAIL PROTECTED]>

> $output .= "$category";

Put quotes around your values...

If you have

This and That

how do you expect HTML to know you mean "This and That" as you're entire
value? It's not. It's going to take "This" and ignore the rest as
unrecognized attributes of the  element.

---John Holmes...

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



Re: [PHP-DB] Re: BINARY not recognized ??

2004-01-05 Thread CPT John W. Holmes
From: "Monty" <[EMAIL PROTECTED]>

> Hi John. The while the error message mashes BINARY and user_name together,
> that's not how I am typing it in my SELECT statement if you check my
example
> in the previous post. MySQL is doing this on it's own for some strange
> reason, even though there is clearly a space between the work BINARY and
> user_name in my statement.

Hmmm... There's no reason MySQL would put them together in the error message
unless it was really sent that way to it. Do you print out the query in your
program just to _make sure_ it's getting sent correctly? If you copy and
paste from what you see printed out and try it from the command line, do you
get the same result?

---John Holmes...

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



Re: [PHP-DB] Re: BINARY not recognized ??

2004-01-05 Thread CPT John W. Holmes
From: "Monty" <[EMAIL PROTECTED]>

> > I now get an error from MySQL stating that "BINARYuser_name" is not a
valid
> > column. So, something seems to be broken. I looked through the MySQL
online
> > docs and BINARY is still there, but, it won't work for me.

Maybe try putting a space between BINARY and the column name

---John Holmes...

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



Re: [PHP-DB] Remove all instances of a character....

2003-12-24 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>

> I have a MySQL database, with around 500 entries in one table...
> I've noticed that many entries have an erroneous ';' in the one of the 
> fields.
> 
> What I need to do, is tell MySQL to go through the ENTIRE table and find 
> any instances of '  ;  ' and them delete them... leaving the rest of the 
> data intact.

UPDATE TABLE SET column = REPLACE(column,' ; ','')

Reminder: This is a PHP list...

---John Holmes...

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



Re: [PHP-DB] Get Names of columns of a table

2003-12-17 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>
> > is there a PHP function that wil return the names of the columns for a
> > given table?

> http://www.php.net/mysq_list_fields

Note: The function mysql_list_fields() is deprecated. It is preferable to
use mysql_query() to issue a SQL SHOW COLUMNS FROM table [LIKE 'name']
Statement instead.

Even if you're not using MySQL, the database should have a SHOW query or an
equivilent.

---John Holmes...

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



Re: [PHP-DB] Query Sum problem

2003-12-16 Thread CPT John W. Holmes
From: "Larry Sandwick" <[EMAIL PROTECTED]>

> I appreciate the quick response, but I should have been more clear.
>
> I understand the query below, but I would only have 2 total and it is
> not group by the companies.
>
> The query below gives me the main information without totals.
>
> How do I add the 2 totals to the query below?
>
> SELECT DISTINCT(Company), account, City, State FROM Table WHERE number =
> 100

SELECT Company, Account, City, State, SUM(IF(Status='Held',Cost,0)) AS Held,
SUM(IF(Status='Open',Cost,0)) AS Cost FROM Table WHERE Number = 100

---John Holmes...

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



Re: [PHP-DB] Query Sum problem

2003-12-16 Thread CPT John W. Holmes
From: "Larry Sandwick" <[EMAIL PROTECTED]>
> I need to sum the field *COST* in this query where data in *STATUS* is
> equal to "HELD" and "OPEN", so I will have 2 totals passed below and do
> not know where to begin .

SELECT status, SUM(cost) FROM Table WHERE status IN ('HELD','OPEN') GROUP BY
status

---John Holmes...

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



Re: [PHP-DB] CREATE TABLE LIKE, error

2003-12-15 Thread CPT John W. Holmes
From: "Gary Every" <[EMAIL PROTECTED]>


> Try:
> CREATE table new_table SELECT * from old_table limit 1;
> 
> delete from new_table;
> 
> This will give you the same structure in both tables, and the 
> deletion will make the new_table empty.

Not quite the same as it will not copy indexes/keys...

---John Holmes...

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



Re: [PHP-DB] CREATE TABLE LIKE, error

2003-12-15 Thread CPT John W. Holmes
From: "Adam i Agnieszka Gasiorowski FNORD" <[EMAIL PROTECTED]>

> I cannot use this query
>
> CREATE TABLE table LIKE other_table;
>
> , which is supposed to create an
>  empty "clone" of the other_table named
>  table.
> Was it added in some later MySQL version?
>  It's in the manual on mysql.com, bo no version info
>  available.

Sure there is, you just had to keep reading.

Quote:
In MySQL 4.1, you can also use LIKE to create a table based on the
definition of another table, including any column attributes and indexes the
original table has:

CREATE TABLE new_tbl LIKE orig_tbl;
CREATE TABLE ... LIKE does not copy any DATA DIRECTORY or INDEX DIRECTORY
table options that were specified for the original table.



Since this is a PHP list, an alternative, two-step method is to issue a SHOW
CREATE TABLE Table_Name query, retrieve the results, and use them to create
your second table (replacing the table name, of course).

---John Holmes...

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



Re: [PHP-DB] ordering output

2003-12-10 Thread CPT John W. Holmes
From: "redhat" <[EMAIL PROTECTED]>

> I have a page that I put together that pulls in data for the time in
> individual fields - hour, minute, am/pm, month, day.  I am going to
> alter the db to add year as well.  I want to order this list by multiple
> criteria - first by year, then by hour, am/pm, minute.  It is a page
> that lists shows that are running on a local cable channel.  Is there a
> way to do what I am asking?  I know that I can 'select * from table
> order by year asc' but don't know how to sub order the items.
> thanks,

Answer you're looking for:
SELECT * FROM Table ORDER BY year ASC, month ASC, day ASC

Correct answer:

Use a DATETIME or TIMESTAMP field for your dates instead of separate columns
for each part. When you start looking for things that span certain lengths
of time, you'll thank yourself. You can still pull each part out if need be.
You'll also only need to sort based upon the single column.

---John Holmes...

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



Re: [PHP-DB] User defined function in a mysql query

2003-12-10 Thread CPT John W. Holmes
From: "antonio bernabei" <[EMAIL PROTECTED]>

> I need to make a join between two tables. And I can use the mysql_query
> function: this is ok.
> The problem arises because I need to apply a user defined function to a
> field of one of the two tables and the rule for the join is WHERE
> table1.filed1=function(table2.field2).
> But I receive a lot of errors: it seems like is not allowed to put such a
> function in the text of the query. Or there is a possibility?

You should be able to do this.. you're just doing a comparison. Although
it'll negate any indexes you have and make for a very slow join. We are
talking about a MySQL function, right... and not a PHP one??

---John Holmes...

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



Re: [PHP-DB] mysql + php

2003-12-08 Thread CPT John W. Holmes
From: "Will Contact" <[EMAIL PROTECTED]>
(B
(B> Now I am  programming php+mysql.  I put word, excel, mpeg and
(B> any binaries into
(B> the mySQL database using php on linux server,But I can take out these
(Bbinay
(B> from mySQL database. I would like to see the files and save my pc from
(B> server. So how can I take out from
(B> these binaries?
(B[snip]
(B> $sql_insert = "INSERT INTO objects(b_col, file_name, file_size,
(B> file_type,file_date) VALUES
(B>
(B('$UploadedFile','$UploadedFile_name','$UploadedFile_size','$UploadedFile_ty
(Bpe',now())";
(B>
(B>mysql_query($sql_insert);
(B
(BAre you sure anything is even being put in the database here? There's no
(Berror checking. Is the blob empty?
(B
(B> // But it does not work at. I can not see anything in my browser
(B> $sql_select = "select b_col, file_name, file_size, file_type,
(Bfile_date
(B> from objects where  file_name like 'gball.gif'";
(B> if(!($result=mysql_query($sql_select,$db))){
(B>   die;
(B>   }
(B>
(B>$file_name = mysql_result ($result,0,"file_name");
(B>echo $file_name;
(B
(BYou need to check what's actually in your database. If you don't get a
(Bresult here, then there's nothing matching "gball.gif" in your database
(B(even if you think there is).
(B
(BAs for displaying these files again (obligatory mention that storing binary
(Bfiles in the database is a BAD idea, IMHO) it's a simple matter of using
(Bheader() to send an appropriate CONTENT header matching whatever kind of
(Bfile you're sending "text/plain", "image/jpg", etc and then echoing the data
(Bfrom the blob.
(B
(B---John Holmes...
(B
(B-- 
(BPHP Database Mailing List (http://www.php.net/)
(BTo unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DB] convert date in german format

2003-11-26 Thread CPT John W. Holmes
From: "Hans Lellelid" <[EMAIL PROTECTED]>

> Using MySQL DATE_FORMAT() would work, but it's a hack solution; if you
> ever wanted to create an English version of your site you would have to
> make changes to your data-layer queries -- and that's just not where
> that logic belongs.

So use UNIX_TIMESTAMP and date() or just use strtotime(). Or go all out and
just store the dates in a unix format in an integer column to begin with!
The choice is yours...

---John Holems...

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



Re: [PHP-DB] convert date in german format

2003-11-26 Thread CPT John W. Holmes
From: "Ruprecht Helms" <[EMAIL PROTECTED]>
> how can I convert a date stored in a mysql-database for output
> in the german format (dd.mm.yy).
>
> I tried date ("d.m.y",$row->from);
>
> but I still get the english-format stored in the database.
> The databasefield is type  date.

That's because date() wants a Unix timestamp. MySQL has it's own format.

You have two options. Option 1 is to use DATE_FORMAT() in your query to
retrieve the date already formated. DATE_FORMAT() works similar to the PHP
date() function. Look it up in Chapter 6 of the MySQL Manual.

Option 2 is to use UNIX_TIMESTAMP() in your query to retrieve the MySQL date
formatted as a Unix timestamp. You can then pass this value to the PHP
date() function and format it like you have above.

---John Holmes...

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



Re: [PHP-DB] Array question

2003-11-25 Thread CPT John W. Holmes
From: "ShortStay" <[EMAIL PROTECTED]>

> How do you delete a value and key from an array?  I know the value.

You need to know the key.

unset($Array[$key]);

There are various array functions that'll find the key for you if you know
the value.

> Is it OK to post array questions to the db list?

Not really... use php-general

---John Holmes...

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



Re: [PHP-DB] Unsure of how to perform query and results..

2003-11-20 Thread CPT John W. Holmes
From: "Aaron Wolski" <[EMAIL PROTECTED]>

> I have data in a Db that looks something like:
>
> 14,[EMAIL PROTECTED],Andrew,Smith
> 1,[EMAIL PROTECTED],Andrew,Smith
> 14,[EMAIL PROTECTED],Barbara,Richardson
> 1,[EMAIL PROTECTED],Barbara,Richardson
>
> The number represents a product_id that was purchased by the customer in
> question. As you can see from this example.. I have a two customers who
> purchased two different products.
>
> What I NEED to do is have one entry for each customer but with both
> their product_id in the same result. For example:
>
> 14,1,[EMAIL PROTECTED],Andrew,Smith
>
> ANY clue how I could go about getting this to work? I'm very desperate
> and running out of time :-(

Sorry, it's not going to happen and besides, there isn't any reason you
should need to return a row like that. How about you tell us what you're
actually trying to do and someone can help you clean up your method...

---John Holmes...

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



Re: [PHP-DB] mysql table join

2003-11-20 Thread CPT John W. Holmes
From: "Roger Miranda (Sumac)" <[EMAIL PROTECTED]>

> Is there a way to permanently join/link two mysql tables?

Not without creating another table. 

CREATE TABLE MyTable SELECT ... FROM Table1 JOIN Table2 ON ... WHERE ...

Although I have to wonder about your schema if you need to do this. 

---John Holmes...

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



Re: [PHP-DB] works on production server but not on localhost :: fix

2003-11-19 Thread CPT John W. Holmes
From: "Paul Ihrig" <[EMAIL PROTECTED]>

> how weird is this
> just had to uncheck "allow anonymous access".
> and keep checked "Integrated Windows authentication"
>
> just seems a bit silly...
> every thing works fine now.

Of course it works because you're now running the PHP scripts as yourself,
and you have permission to read/write to the directory in question.

If you use anonymous access, like it was said before, PHP runs as the IUSR_*
account. So, in order for it to work, that user must have read/write
permissions for the directory.

---John Holmes...

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



Re: [PHP-DB] Query Case In-sensitive

2003-11-17 Thread CPT John W. Holmes
From: "Larry Sandwick" <[EMAIL PROTECTED]>

> Is there a way to run a query so that it ignores the case, and the query
> is not case sensitive?

What's this have to do with PHP and what database are you using?

---John Holmes...   

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



Re: [PHP-DB] - ereg_replace -SOLVED

2003-11-14 Thread CPT John W. Holmes
From: "ΝΙΚΟΣ ΓΑΤΣΗΣ" <[EMAIL PROTECTED]>

> eregi_replace("", " class=\"down_txt\">", $body);

How is that any different than just doing a str_replace() on "http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] using code for multiple sites

2003-11-13 Thread CPT John W. Holmes
From: "Chris Boget" <[EMAIL PROTECTED]>

> > > create a directory called "inc" in /usr/local/apache
> > > and then add the following line to php.ini
> > > include_path = ".:/usr/local/apache/inc "
> > I'd use a method like this, although I'd probably just use an absolute
path
> > instead of adjusting the include_path.
>
> What's the benefit of using an absolute path?  If you did need to change
the
> include path, you'd only have to do it in one file.  Or am I
misunderstanding
> what you are saying (likely)?

I don't think there's much of a benefit, really. I really don't like being
dependent upon php.ini changes (although you can change the include_path
with ini_set()).

Generally, the way I program is to have a variable in an include file that
determines the "include path", anyhow. So, if the program or these include
files move, I still only have to change it in one place (well, one place in
each program using the absolute path, I guess).

This all comes down to a matter of preference. Since all of the scripts are
on the same computer and you can change php.ini, the above method (yours) is
probably the easiest to use.

---John Holmes...

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



Re: [PHP-DB] using code for multiple sites

2003-11-13 Thread CPT John W. Holmes
- Original Message - 
From: "mike" <[EMAIL PROTECTED]>
> I currently manage several websites that share the same code.
>
> create a directory called "inc" in /usr/local/apache
> and then add the following line to php.ini
> include_path = ".:/usr/local/apache/inc "

I'd use a method like this, although I'd probably just use an absolute path
instead of adjusting the include_path.

---John Holmes...

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



Re: [PHP-DB] keyword searching

2003-11-12 Thread CPT John W. Holmes
From: "Adam Williams" <[EMAIL PROTECTED]>

> This is my SQL query:
>
> "SELECT seriesno, governor, descr, boxno, year, eyear, docno
> from rg2 WHERE seriesno = '$_POST[seriesno]' and governor matches
> '*$searchterm*' or descr matches '*$searchterm*'";

Looks like you're doing the equivilent to a MySQL "LIKE" search, i.e.
looking for a pattern in a string instead of doing a FULLTEXT search.

Consult you're documentation, as I don't think the PHP list can be much more
help.

---John Holmes...

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



[PHP-DB] Re: [PHP] keyword searching

2003-11-12 Thread CPT John W. Holmes
From: "Adam Williams" <[EMAIL PROTECTED]>

> I'm using Informix SQL.

Could have saved some bandwidth by mentioning that in the first place and
only posting to either php-general or php-db (which is more appropriate),
not both. :)

Ignore what my other posts said, as I don't know how Informix works.

---John Holmes...

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



Re: [PHP-DB] keyword searching

2003-11-12 Thread CPT John W. Holmes
From: "Adam Williams" <[EMAIL PROTECTED]>
> CPT John W. Holmes wrote:
> > From: "Adam Williams" <[EMAIL PROTECTED]>
> >
> >>I am selecting a field in a database called description for keyword
> >>searching.  The field contains names of people, states, years, etc.
When
> >>someone searches for say "holmes north carolina" the query searches for
> >>exactly that, fields which have "holmes north carolina", and not fields
> >>that contaim holmes, north, and carolina.  So I run a str_replace to
> >>replace all spaces with *, which turns it into "holmes*north*carolina",
> >>but say that north carolina is before holmes in the field, it won't
return
> >>those fields (it only returns fields in which holmes is infront of north
> >>carolina).  So how can I have it return all fields which contain all
> >>the words holmes, north, and carolina in any order, in that field?
> >
> > Are you doing a fulltext search or just matching a word in a lookup
column?
>
> I'm doing a fulltext search.

What is your query? Assuming MySQL, I get a result like this:

mysql> select * from test where match(t) against ('holmes north carolina');
++
| t  |
++
| my name is john holmes from north carolina |
| i'm from the north |
| in carolina is my home |
| did I mention my last name is holmes?  |
++
4 rows in set (0.01 sec)

Isn't that what you want?

---John Holmes...

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



Re: [PHP-DB] keyword searching

2003-11-12 Thread CPT John W. Holmes
From: "Adam Williams" <[EMAIL PROTECTED]>
> I am selecting a field in a database called description for keyword
> searching.  The field contains names of people, states, years, etc.  When
> someone searches for say "holmes north carolina" the query searches for
> exactly that, fields which have "holmes north carolina", and not fields
> that contaim holmes, north, and carolina.  So I run a str_replace to
> replace all spaces with *, which turns it into "holmes*north*carolina",
> but say that north carolina is before holmes in the field, it won't return
> those fields (it only returns fields in which holmes is infront of north
> carolina).  So how can I have it return all fields which contain all
> the words holmes, north, and carolina in any order, in that field?

Are you doing a fulltext search or just matching a word in a lookup column?

In the case of the latter, you'll have to split up the sentence into
individual words and look for each of them

WHERE column = 'holmes' || column = 'north' || column = 'carolina' ...

---John Holmes...
(not in North Carolina, btw!)

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



Re: [PHP-DB] newbie question on data accumulation

2003-11-12 Thread CPT John W. Holmes
From: "Joffrey Leevy" <[EMAIL PROTECTED]>

> Curious as to what happens after data is repeatedly
> selected from a mysql table overtime.  Does it
> accumulate as junk data, stored at some location and
> eventually slow down the database/program/server?
> Does any purging have to take place?

I would imagine it would be thrown away when ever the connection was closed
or the result set was retrieved entirely. Why not ask this on a MySQL list?
You'd probably get much better answers.

---John Holmes...

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



[PHP-DB] Re: [PHP] Changing case

2003-11-12 Thread CPT John W. Holmes
From: "Robert Sossomon" <[EMAIL PROTECTED]>

> I have a form that allows for an item to be entered, the other pieces
> have been fixed so far that were bogging me down, but now I am looking
> for a way to convert any entry in the form to be UPPER case so that when
> the quote is listed, they are alphabetical.  

http://us2.php.net/strtoupper

---John Holmes...

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



Re: [PHP-DB] Query or code?

2003-11-06 Thread CPT John W. Holmes
From: "Peter Beckman" <[EMAIL PROTECTED]>


> I have this data:
>
> Table Log: appid   userid points  datetype
> Table Score: appid userid score
>
> I want to verify that the last entry in table log of type "x" is equal to
> the sum of the scores in table score for the same appid and userid.
>
> Can I do this in SQL easily?  My problem is selecting the correct (most
> recent) row in log in which to match the score.
>
> Basically I want a report of AppID, TeamMemberID, log.points, score.score
> that shows where points != score;

Why do you have a score table at all? That's just repeating data when you
can always do a SUM query on the "log" table to get the score...

Athough...

SQL example:

mysql> select * from log;
++--+
| id | log  |
++--+
|  1 |1 |
|  1 |2 |
|  1 |3 |
|  1 |4 |
|  2 |3 |
|  2 |5 |
++--+
6 rows in set (0.00 sec)

mysql> select * from score;
++---+
| id | score |
++---+
|  1 |10 |
|  2 | 1 |
++---+
2 rows in set (0.00 sec)

mysql> select s.id, s.score, sum(l.log) as log_sum from score s, log l where
l.id = s.id group by l.id;
++---+-+
| id | score | log_sum |
++---+-+
|  1 |10 |  10 |
|  2 | 1 |   8 |
++---+-+
2 rows in set (0.00 sec)

mysql> select s.id, s.score, sum(l.log) as log_sum from score s, log l where
l.id = s.id group by l.id having s.score != log_sum;
++---+-+
| id | score | log_sum |
++---+-+
|  2 | 1 |   8 |
++---+-+
1 row in set (0.00 sec)

---John Holmes...

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



Re: [PHP-DB] RE: Problem

2003-11-06 Thread CPT John W. Holmes
From: "Jeremy Shovan" <[EMAIL PROTECTED]>

> All I did was rewrite it exactly the same as it was and the
> parse error disappeared. I have never seen anything quite
> like this before.

Seen this before. It's either the editor or a copy and paste operation
adding weird "invisible" characters. Major pain in the ass.

---John Holmes...

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



Re: [PHP-DB] Apostrophe problem on Firebird

2003-11-06 Thread CPT John W. Holmes
From: "Evan Morris" <[EMAIL PROTECTED]>

> I have data in a database that may contain apostrophes.

Some databases use the backslash character as an escape character for single
quotes, while others use another single quote. Try your query such as:

SELECT * FROM Table WHERE name = 'o''mallery'

Instead of using addslashes(), you'll need to do a simple str_replace to
escape the characters.

---John Holmes...

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



Re: [PHP-DB] SELECT COUNT - result from two tables

2003-11-06 Thread CPT John W. Holmes
From: "Boyan Nedkov" <[EMAIL PROTECTED]>
> Putting more than one table in the FROM clause means tables are joined,
> then at least following problems could arise:
>
> - using WHERE clause you can have empty recordset returned and then
> COUNT conflicts with it because there is actually no any data to be
> returned;

There won't be a conflict, COUNT(*) will just return zero. When you use
COUNT(*) there will _always_ be a row returned, either zero or the count.

> - joining two (or more) tables without using aliases to the equally
> named columns in the SELECT/WHERE/COUNT clauses will produce error
> message instead of expecting data;

You don't need an alias and the columns don't have to be equally named, but
yes, you have to "join" them somehow against some column. The original query
had this.

> - COUNT(*) wont work if u have equal table names in the tables;

I have no idea what you mean by that.

---John Holmes...

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



Re: [PHP-DB] Select Value with 's

2003-11-06 Thread CPT John W. Holmes
From: "pete M" <[EMAIL PROTECTED]>
> > do not quite understand your problem.. pls post some code?
> > heres a small snippet that should work well...
> >
> > $qry = 'SELECT `customer` FROM `customerList` ORDER BY `customer`';
> > $res = mysql_query($qry);
> > while($customer = mysql_fetch_object($res)) {
> > echo stripslashes($res->customer).''."\n";
> > }
>
> why the backticks and not quotes ?

Because quotes would make it a string. Backticks are used to deliminate
column and table names.

If you said: SELECT 'column' FROM Table

You'd get a result set with the literal string "column" as the value. Works
the same in the WHERE, ORDER BY, GROUP BY, etc clauses, also.

---John Holmes...

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



Re: [PHP-DB] Select Value with 's

2003-11-05 Thread CPT John W. Holmes
From: "Aleks @ USA.net" <[EMAIL PROTECTED]>
> First I build my select list:
>
> 
> All Customers
>
>   While ($Site = mysql_fetch_array($S))
>  {
>   $Sid = $Site["CID"];
>   $SName = htmlspecialchars($Site["Customer"]);
>   echo("$SName\n");

Easy fix: echo("$SName\n");

Long version:

htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES
as the second parameter. What you're ending up with is a value such as:

value='St. Mary's'

which, HTML will interpret as a value of "St. Mary" and an unknown s'
attribute. So,

$SName = htmlspecialchars($Site["Customer"], ENT_QUOTES);
echo("$SName\n");

will convert single quotes to HTML entities and not affect the value.

The "easy fix" above works because it uses double quotes around the value
and htmlspecialchars() already changes double quotes by default.

---John Holmes...

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



Re: [PHP-DB] Help: do ... while, reverse data query

2003-11-05 Thread CPT John W. Holmes
From: "Douglas Freake" <[EMAIL PROTECTED]>
> I need to do a loop where the mysql query starts
> at the bottom and goes up, as if the data was in
> reverse order. This is for building a category/
> sub_category menu.
> 
> Data structure: (cat_id, cat_sub, cat_name)
> 
> sample routine:
> 
> do {
> $sql = "SELECT * FROM categories WHERE cat_id = '$cat'";
> $go = mysql_num_rows($sql_result);
> $cat = $row["cat_sub"];
> $cat_id = $row["cat_id"];
> } while ( $go == 1);
> 
> Any ideas how to to start a the end of the database?

Yes, it's called an ORDER BY clause. 

SELECT * FROM categories WHERE cat_id = '$cat' ORDER BY cat_id DESC

---John Holmes...

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



[PHP-DB] Re: [PHP] php|cruise - do unto others...

2003-11-05 Thread CPT John W. Holmes
From: "Becoming Digital" <[EMAIL PROTECTED]>

> php|cruise is coming this March.

Final word on this, I promise! :)

I'll be on the cruise, so I'm looking forward to meeting anyone else that'll
be there. Contact me offline if you want.

I wanted to say think you to all of those that contributed to the "cause". I
ended up getting $71.03US that helped towards the price. (more donations are
still welcome, of course, to offset my empty bank account, now).

Thanks to Edward for bringing this up in the first place!

---John Holmes...

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



Re: [PHP-DB] number_format problem

2003-11-05 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>
> sweet.  thanks for hte correction.  i try, sometimes i fail. :)

But trying is half the battle. GI JOE!

---John Holmes...

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



Re: [PHP-DB] Unsuscribe

2003-11-05 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>

> Unsubscribe

No thanks. I like it here. 

---John Holmes...

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



Re: [PHP-DB] number_format problem

2003-11-05 Thread CPT John W. Holmes
From: "Peter Beckman" <[EMAIL PROTECTED]>
> On Wed, 5 Nov 2003, Dillon, John wrote:
>
>  I use this:
>
>   $x['funds'] = (int)preg_replace("/[\$,]/","",$x['funds']);
>
>  where $x['funds'] contains something like $3,249,555.32, and the end
>  result is an int of 3249555.  I drop the cents... you want to keep 'em,
>  change "int" to "float".

I'd be careful of casting it to float. Not sure how this would work, as it
may depend upon your database, but say you casted 100 to a float, it'd be
acceptable for PHP to store it as 99.9. Now when you throw that into
a DECIMAL field in MySQL for example, it may only store 99.99 instead of
rounding up.

Floating point errors are a pain. Make sure you test before implementing a
solution like this.

---John Holmes...

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



Re: [PHP-DB] number_format problem

2003-11-05 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>
> could you cast as a float/double before inserting?  $number = (double)
> $string;
>
> don't know what would happen to the comma, but i assume it would just get
> removed??

Everything after and including the first non-number character would be
dropped.

So "$12,000.34" would end up as zero. "12,445" would end up as 12, etc...

---John Holmes...

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



Re: [PHP-DB] number_format problem

2003-11-05 Thread CPT John W. Holmes
From: "Dillon, John" <[EMAIL PROTECTED]>

> I want to show a number from a database in the format x,xxx.00 in a
> textfield, then if it is changed by the user I want to post the value of
the
> number to a decimal field.  However, once you number_format the number it
> becomes a string, and numbers like 3,379.90 give a value of 3 when posted
to
> the database, which is hinted at in the notes on number_format.  I suppose
I
> need a string to number function - can someone tell me what this might be
> called please?

If you know it's going to be in a $x,xxx.xx format, then

$new_number = preg_replace('/[^0-9.]/','',$old_number);

will remove anything that's not a number or decimal point.

BUT, since we know that we can't trust it'll come in that format, you may
also want to run

$rs = preg_match('/[0-9]+\.?([0-9]{1,2})?/',$new_number); //untested :)

which _should_ make sure you're not getting a number like "xxx.xx.xxx" or
"xx.xx" from some tricky user. If $rs is TRUE or 1, then the number is
in the correct format.

---John Holmes...

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



Re: [PHP-DB] Query Error

2003-11-04 Thread CPT John W. Holmes
From: "Robert Sossomon" <[EMAIL PROTECTED]>


> The errors as it prints are:
>
> The query I just ran was: select * from GCN_items where `item_num` =
> '%fm-a294%'
> The query I just ran was: Resource id #2
> 0

Those aren't errors; it's just what you asked the script to display. Your
query simply isn't returning any rows.

You should be using LIKE instead of the equal sign, since I assume you're
looking for a pattern.

select * from GCN_items where `item_num` LIKE '%fm-a294%'

otherwise you're looking for the literal string "%fm-a294%"

---John Holmes...

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



Re: [PHP-DB] Query Error

2003-11-04 Thread CPT John W. Holmes
From: "Robert Sossomon" <[EMAIL PROTECTED]>

> And here is the additem.php file where it check for the info in the
> field and it is erroring out.

It would be rather useful to know the error...

>   $get_iteminfo = "select * from GCN_items where 'item_num' LIKE
> '%$_POST[sel_item_id]%'";

Take away the single quotes around your column name. You're asking for a
'string' LIKE 'another string' and not comparing anything in your column at
all.

You can use backticks around table and column names, though. Maybe that's
what you're trying to achieve.

$get_iteminfo = "select * from GCN_items where `item_num` LIKE
'%$_POST[sel_item_id]%'";

---John Holmes...

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



Re: [PHP-DB] removing space ?

2003-10-28 Thread CPT John W. Holmes
From: "Larry Sandwick" <[EMAIL PROTECTED]>


> When I select data from my data base I have spaces on the lead side for
> example the data that is stored is "  33.jpg".  Spaces included,
> exclude the quotes, quotes are example only to show the spaces.
>
> I would like to remove these spaces. Is there a way to do this?

trim(), either in your query or in PHP. Maybe you want to use the function
BEFORE you store the data??

---John Holmes...

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



Re: [PHP-DB] Unique Format

2003-10-22 Thread CPT John W. Holmes
Use htmlentities() or htmlspecialchars()...

---John Holmes...

- Original Message - 
From: "Tonya" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 22, 2003 1:07 PM
Subject: [PHP-DB] Unique Format


PHP 4.3.3 and MYSQL

I am constructing a site for gamers that has a member registration form with
field 'Game Handle'.

Gamers are funny in that their game alias can include just about any
character you can imagine.  Setting up an ereg for this would be quite
difficult.  However, I *do* want to protect my site from any malicious data
entry.

I have tried to strip_tags this field, but many gamers put their team tags
in their handle or use < and > characters within the name, so an input like
"Jester" results in the team being taken out and only Jester being
left.  While that is not so bad, if the user inputs a name like GD, it
changes the name signficantly.

Anyone have any suggestions on how I can format the game handle variable so
that it allows these characters while not leaving my site subject to
malicious input?

Thanks!

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



Re: [PHP-DB] Multiple adds?

2003-10-21 Thread CPT John W. Holmes
From: "Robert Sossomon" <[EMAIL PROTECTED]>


> An example is:
> http://www.garlandcnorris.com/quotes/seestore.php
>
> I have a session tracker installed on it already, but the modifying the
> information (instead of remove and readding it) and adding an entire
> group are pieces I am stumbling on.

So you want to be able to add multiple items into your cart at one time? Or
be able to edit multiple items at a time?

---John Holmes...

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



Re: [PHP-DB] Error settings

2003-10-21 Thread CPT John W. Holmes
From: "Dillon, John" <[EMAIL PROTECTED]>
> Hm. Adjusted error_reporting to none.  Why would I still get:
>
> "Forbidden
> You don't have permission to access /method="post" on this server.
> --
--
> 
> Apache/1.3.28 Server at www.somenet.com Port 80"

Nothing to do with PHP. Seems like your server will not allow you to use the
POST method...

> And if I use the address: http://localhost/apics3.php?ID=349 it complains
> about undefined variable, ID.
>
> "Notice:  Undefined variable:  ID in c:\program files\apache
> group\apache\htdocs\apics3.php on line 11"

Because of your error_reporting level. You say you changed it, but do the
changes reflect in a phpinfo() page?

> My php.ini contains:
> 
> ; This directive tells PHP whether to declare the argv&argc variables
(that
> ; would contain the GET information).  If you don't use these variables,
you
> ; should turn it off for increased performance.
> register_argc_argv = On
> 

Nothing to do with error reporting. This is mainly used for the command
line.

> Sounds like I've adjusted the wrong file.  I have only one php.ini file in
> c:\winnt (apart from the one in c:\php\backup), the one in
> c:/PHP/php-4.3.2-Win32 is called php.ini-dist and php.ini-recommended.  I
> haven't touched these.  Should I?

You should have copied one of those files to create your initial php.ini.
Take a look at the output of phpinfo() and it'll tell you where PHP is
reading it's php.ini file in the first block. If a path is shown, but no
php.ini file at the end, that's where PHP is expecting to find the php.ini
file, but it's not there. If a full path to php.ini is shown, then that's
the file you should be editing.

Finally, and the key to all of this, I think: restart your web server after
you make a change to php.ini.

---John Holmes...

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



Re: [PHP-DB] Multiple adds?

2003-10-21 Thread CPT John W. Holmes
From: "Robert Sossomon" <[EMAIL PROTECTED]>

> I am working on a quote system and have been trying to figure out how to
> make them system automatically add an entire vendor or category at one
> time.  I can make the system display all of them and give the sales
> folks in my office a chance to change the price, however if I have just
> one "Add" button it will ONLY add the first item in the group, not the
> entire group.

Can you give an example page to help with your explanation? I kind of
understand what you want, but without seeing what you're doing and what
point your at, it's hard to help.

---John Holmes...

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



Re: [PHP-DB] Error settings

2003-10-21 Thread CPT John W. Holmes
From: "Dillon, John" <[EMAIL PROTECTED]>

> How do I get rid of the undefined variable errors I get on a new (default)
> set up of Apache 1.3.28/PHP4.3.2 (without re-writing the code).  It works
on
> the internet on my host providers server but I am running this on
localhost.
> I also get undefined offset error.

Adjust your error_reporting level in php.ini or use the error_reporting()
function.

---John Holmes...






























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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Load MySQL from a variable

2003-10-21 Thread CPT John W. Holmes
From: "Rory McKinley" <[EMAIL PROTECTED]>

> AFAIK, LOAD DATA INFILE will only work off a file. So you would have to
> create a temp file. Another option is to create a multiple value insert
> query e.g.
>
> INSERT INTO arb_table (arb_column_1...arb_column_n)
> VALUES (arb_value_1..arb_value_n), (arb_value_1..arb_value_n), .

Making the above query should be as simple as:

$query = 'INSERT INTO arb_table (arb_column_1, arb_column_n) VALUES (' .
str_replace("\n","),\n(",$file_data) . ')';

where $file_data is your adjusted CSV file in a variable.

> Although LOAD DATA INFILE is, i think, the fastest way to get data into
> MySQL, if you first have to create a temp file, the additional nuisance
and
> time factors might make the above query a valid alternative.

Agree that LOAD DATA INFILE will probably still be faster overall, even with
the file write. Try each and see, though.

---John Holmes...

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



Re: [PHP-DB] Load MySQL from a variable

2003-10-21 Thread CPT John W. Holmes
From: "Kim Kohen" <[EMAIL PROTECTED]>

> I have some data from Filemaker Pro which needs to have a lot of
> search/replacing done before importing into MySQL. I have used
ereg_replace
> in PHP and end up with a variable holding the correct data. (there are
> several hundred rows of data in the variable)
>
> Is it possible to use Load data infile with a variable or will I need to
> write out a temp file and then load that?

The temp file would probably be the best/fastest way to do it.

---John Holmes...

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



Re: [PHP-DB] Re: looping over $row (was "Re: [PHP-DB] Using two colomns ...")

2003-10-20 Thread CPT John W. Holmes
From: "David T-G" <[EMAIL PROTECTED]>

> Hmmm...  I suppose so, but I can't picture it.  Shouldn't you always know
> the DB schema and format of what you're going to get back?  I can see not
> knowing how many RECORDS you'll get back but I should think you would
> know how many FIELDS will be in each.

Depends upon your application, I guess. I have a dynamic report builder for
this application that creates the header, footer, rows, etc, all in the same
format and it's just passed a query, any query. So, you never know how many
columns there are unless you count the row returned and loop through it (or
use mysql_num_fields()).

---John Holmes...

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



Re: [PHP-DB] Using two colomns of mysql data as key/value pairs in arrays

2003-10-20 Thread CPT John W. Holmes
From: "Chris Boget" <[EMAIL PROTECTED]>

> > From: "Chris Boget" <[EMAIL PROTECTED]>
> > > My bad.
> > > If MySQL had crosstab functionality, that *might* be able to help.
> > A "crosstab" is just a specifically formatted query, of which MySQL is
> > certainly capable of handling. I've done them in the past, but maybe
you're
> > thinking of something more complex. Either way, not sure it would help
or be
> > worth it for this (dead) issue. :)
>
> Then I'm not calling it the right thing... just the name of the type of
query that
> was told.  The kind of query I'm talking about is the one that rotates the
result
> set from tall to wide.  Basically doing exactly what the OP had asked for.
If
> that kind of query isn't called a 'crosstab' query, I'm not sure what the
name is.
> I know that mysql doesn't support it but PG does (I'm just starting to
learn PG).

I see. I've always heard it referred to as a "pivot table", or something
along those lines.

Great crosstab article/story:
http://www.devshed.com/Server_Side/MySQL/MySQLWiz/page1.html

---John Holmes...

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



Re: [PHP-DB] Using two colomns of mysql data as key/value pairs in arrays

2003-10-20 Thread CPT John W. Holmes
From: "David T-G" <[EMAIL PROTECTED]>

> [Actually, maybe I'm just too new at this, but I
> can't think of a practical example for which I would loop over $row...
> Care to help me out?]

How about a dynamic query where you do not know the number of columns
that'll be returned? You would not want to use _array() as you'll have the
duplicates to worry about / skip over. using _row() or _assoc() and just
looping through that will suffice.

---John Holmes...

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



Re: [PHP-DB] Using two colomns of mysql data as key/value pairs in arrays

2003-10-20 Thread CPT John W. Holmes
From: "Chris Boget" <[EMAIL PROTECTED]>
> My bad.
> If MySQL had crosstab functionality, that *might* be able to help.

A "crosstab" is just a specifically formatted query, of which MySQL is
certainly capable of handling. I've done them in the past, but maybe you're
thinking of something more complex. Either way, not sure it would help or be
worth it for this (dead) issue. :)

---John Holmes...

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



Re: [PHP-DB] Using two colomns of mysql data as key/value pairs in arrays

2003-10-20 Thread CPT John W. Holmes
From: "Devon" <[EMAIL PROTECTED]>


> I have been scouring the online documentation and experimenting for 
> hours trying to find a solution. I just can't do it.
> 
> I have two colomns of data that I am retrieving from MySQL:
> 
>SELECT id, name FROM a_table;
> 
> I just cannot figure out how to get that data from the resource handle 
> into an associative array with the 'id' colomn making up the keys and 
> the 'name' colomn making up the values.

while($r = mysql_fetch_assoc($result))
{ $array[$r['id']] = $r['name']; }

---John Holmes...

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



Re: [PHP-DB] problem - query inside a function

2003-10-16 Thread CPT John W. Holmes
From: "Luis M Morales C" <[EMAIL PROTECTED]>

> My Comment bellow:
>
> On Wednesday 15 October 2003 14:38, Kirk Babb wrote:
> > Hi,
> > I'm having trouble with a query inside a function.  I thought I'd
written
> > this so that the function would fail if email and zipcode supplied were
not
> > in the same row (trying to use those two things to identify the user),
but
> > I don't think that is what is happening because I can enter the wrong
> > zipcode and it will return data based on the email.  Any suggestions or
> > corrections? Thanks!
> > -Kirk
> >
> > [code snippet]
> > function getEditData($email,$zipcode) {
> > $sql = "SELECT * FROM contact_info WHERE zipcode='$zipcode' AND
> > email=\"{$email}\"";
>
> Change by
> $sql = "SELECT * FROM contact_info WHERE zipcode='{$zipcode}' AND
> email='{$email}'";

That's not causing the problem. Both methods are valid.

> > $query = mysql_query($sql);
> > if (mysql_affected_rows()=="0") {

mysql_affected_rows() does not apply to SELECT queries. Perhaps you're
meaning mysql_num_rows()?

> >   $this->sendResult("Fail","We do not have the given email and
zipcode
> > on file.  Please go to the menu and start again.");
> > }

---John Holmes...

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



Re: [PHP-DB] Sessions and MySQL?

2003-10-16 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>

> And I'm trying to add a session variable to a MySQL database.
> I've done this page that takes the results from a previous form...
> But I get this error:
> Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or 
> `T_NUM_STRING' 
> On line 83
> Which is the line that relates to the line:
> \"$_SESSION['salutation'];\", 
> 
> I've tried removing the ';' but it change nothing...?
> Can anyone see my error?
> 
> =
>  session_start();
> header("Cache-control: private");
> 
>$_SESSION['salutation'] = $_POST['salutation'];
> 
> //MySQL connection stuff
> mysql_query("INSERT INTO $table (
> salutation,
> name,
> city
> } VALUES {
> \"$_SESSION['salutation'];\", 
\"{$_SESSION['salutation']}\",
> \"$_SESSION['name'];\", 
\"{$_SESSION['name']}\",
> \"$_SESSION['city'];\"
\"{$_SESSION['city']\",
> }

---John Holmes...

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



Re: [PHP-DB] inserting date from text file

2003-10-15 Thread CPT John W. Holmes
From: "Aleks @ USA.net" <[EMAIL PROTECTED]>

> I have a large text file that I am inserting into a mysql db and seem to
> have a problem with
> the date format. The data is currently in the mm/dd/ format.

MySQL expects a MMDD or -MM-DD format (the delimiter for the string
version can be any character, actually)

> I am using phpMyAdmin with the above command. I have over 1000 lines of
data
> to add and
> changing all the dates would be a royal pain. Is the note a way to set the
> format in the
> column description to allow for the current data format to remain as is
and
> have the
> db insert the date in the correct mySQL format??

There's no way to set a format. You could insert them into a VARCHAR column,
then use an UPDATE query to pull the string apart and format it into
MMDD and update another DATE column, though.

Or have PHP run pre-process your text file and change the dates for you
(since this is a PHP list. :))

---John Holmes...

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



Re: [PHP-DB] mySQL field structure question

2003-10-01 Thread CPT John W. Holmes
From: "Susan Ator" <[EMAIL PROTECTED]>

> If I have a field in mySQL consisting of a number with 8 digits a decimal
> point and 4 more digits what is the field type it needs to be to sort it
> numerically?
>
> I've tried decimal(8,4) but it converts everything to .. I've
> also tried float but it doesn't sort numerically. All of the other integer
> types cut off the decimal bit.
>
> Any help would be appreciated.

What's this got to do with PHP?

Read here: http://www.mysql.com/doc/en/Numeric_types.html

---John Holmes...

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



Re: [PHP-DB] Replacing "+" with " " question

2003-09-30 Thread CPT John W. Holmes
From: "Graeme McLaren" <[EMAIL PROTECTED]>

> Jason, thank you for reply.  I tried switching the 1st 2 parameters in the
> str_replace function so that it now looks like this:
>
> $AddressLine1 = urlencode($AddressLine1);
>
> $AddressLine1 = str_replace("+", " ", $AddressLine1);
>
>
>
> Unfortunately as I am now replacing the + symbols with a space " " only
the
> part up to the first space is displayed back to the user.
>
> Any ideas?

I think this whole problem can be solved by putting quotes around your HTML
values.

echo "First Line Of Address:  ";

Now, the ONLY thing you need to do to $AddressLine1 to make it safe to
insert into this HTML form element is run htmlentities() on it.

$safe_AddressLine1 = htmlentities($AddressLine1);
echo "First Line Of Address:  ";

I think the whole bit with + and spaces will go away if you do this.
Remember that you may see "this+that" in the URL, but it's decoded
automatically when it gets to your PHP script back to "this that"...

---John Holmes...


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



Re: [PHP-DB] ereg_replace

2003-09-30 Thread CPT John W. Holmes
From: "Dillon, John" <[EMAIL PROTECTED]>

> strip_tags() is used to remove HTML tags, eg for showing text on the
browser
> and then sending it by plain text email or storing in the db.  As a matter
> of interest, how is this done using ereg_replace.  I thought this would
work
> ^<.*>$, that is being with < and any number of single characters ending
with
> >.  Didn't seem to work - why?

Because you have ^ and $ (beginning of string and end of string), you're
saying the entire string must be between < and > in order for a match to
occur.

Take them out and make sure you're not being "greedy", i.e. "this  and
that  are left" being reduced to "this  are left".

ereg_replace('<[^>]*>','',$string);

or

preg_replace('/<[^>]*>/','',$string);

should work.

---John Holmes...

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



Re: [PHP-DB] Re: Email Application

2003-09-25 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>

> I am not so new in PHP but I have a problem.
> I am trying to create a webmail program for my penpal
> site. I cant retrieve and desplay e-mails from my mail
> server. Any one with ideas?

I have an idea.

---John Holmes...

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



Re: [PHP-DB] Curious code behavior inside/outside function

2003-09-24 Thread CPT John W. Holmes
From: "Karen Resplendo" <[EMAIL PROTECTED]>


> I can't get odbc call to work inside of a function. It works on the
outside, then I pass the recordset and fieldname to the function to use the
data. I would like to just have the whole odbc stuff inside the function. Am
I missing something obvious? This is the error I get for the odbc_do line:
> "Supplied argument is not a valid ODBC-Link resource"
[snip]
> 
> This doesn't work:
>
> function isValidPWS($pws)
>  {
> $data=odbc_do($connectionSDWIS,"EXEC sp_PWSExists '$pws'");

Scope issue. $connectionSDWIS is not defined within your function. Either
pass it to the function or make it global.

---John Holmes...

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



Re: [PHP-DB] Problem with sessions on FreeBSD 4.4

2003-09-24 Thread CPT John W. Holmes
From: "Lars Rasmussen" <[EMAIL PROTECTED]>
> I have some problems with sessions, it seems that when i have this in my
> httpd.conf
> 
> AllowOverride All
> Options All
> 
>
> Sessions don't work.
>
> But as soon as i comment it out, it works just fine again.
>
> I don't really know what to do here, and i hope that you can help me.
> Thanks a lot.

You can start by showing us how it "don't work". What's your code, how do
you know it's not working, etc?

Have you tried a simple example from the manual to see if that works?

---John Holmes...

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



Re: [PHP-DB] Storing Session Variables

2003-09-24 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>
> "CPT John W. Holmes" <[EMAIL PROTECTED]>
> > From: <[EMAIL PROTECTED]>
> >
> > > Is there a limit to the number of session variables one can
create/store
> > ?
> > > Or is the limit imposed by the size of the file ?
> >
> > Size of file is only limit, although you should impose a practical limit
> > yourself. If you need to ask this question, you're probably relying on
> > sessions to much.
>
> Define 'too much' please...

"more than you should be"

Get serious for a second here... Why not explain why you're asking this
question? If you're going to store a huge amount of data in a session,
explain why.

---John Holmes...

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



Re: [PHP-DB] update db with variables

2003-09-24 Thread CPT John W. Holmes
From: "Robbie Staufer" <[EMAIL PROTECTED]>

> I'm writing an application that will display the contents of a db in the
> browser, including the db-assigned id number.  The user can then enter
> the id number in a form and the browser will display the record
> corresponding to that id number, with the data in editable text fields.
>
> The user edits the text fields and submits to an 'update' script using
> POST, and the update script puts the new values back into the database.
>  In the update script, I'm trying to access the field names and values
> in the $_POST array, and update the db using a loop:
>
> while ($data = each($_POST)) {
> $name = $data[ 'key' ];
> $value = $data[ 'value' ];
> echo $name, $value;
> $result =
> mysql_query("UPDATE tablename SET $name = $value WHERE ID=$id") or die
> ("unable to update record");
>}
>
> The echo statement shows me that the script dies on the first time
> through the loop.

Put quotes around your strings in your SQL:

mysql_query("UPDATE tablename SET $name = '$value' WHERE ID=$id")

Also, instead of "dieing" with your own error message, use mysql_error(),
which would have given you a better error to act upon...

or die("Error in update: " . mysql_error());

---John Holmes...

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



Re: [PHP-DB] Storing Session Variables

2003-09-24 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>

> Is there a limit to the number of session variables one can create/store ?
> Or is the limit imposed by the size of the file ?

Size of file is only limit, although you should impose a practical limit
yourself. If you need to ask this question, you're probably relying on
sessions to much.

> I'm on a Windows 2000 machine, and the variables are being saved in
> notepad.

Huh?

---John Holmes...

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



Re: [PHP-DB] Query Filter in GUI

2003-09-22 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>

> I have a PHP GUI in which a select box gets populated by a query of a
> MySQL DB for all CD's by all artists when the page is first opened. I am
> now trying to implement
> the same query but with a WHERE clause that filters the returned CD's to
> be displayed in the same select box according to the artist selected via a
> group of checkboxes (one per artist).  The problem so far is that if I try
> to implement some flow control (if checbox one is selected, append "where
> artist='hendrix' to the select all CDs query, mysql_query() etc...), I get
> an error message saying that the query string is empty. So I am looking
> for some advice about how to implement the logic of having the same select
> box display the results of different but related queries.
>
> For example,
>
> $query_1 = "SELECT CD_title FROM CDs order by CD_title";
> $result_1 = mysql_query($query_1) or die("Can't select CD_title from CDs"
> . mysql_error());
> while($row=mysql_fetch_array($result_1, MYSQL_BOTH)) ..etc...
>
> works just fine.
>
> But if I try to use some flow control to alter which query statement is
> assigned to $query_1...
>
> if(checkbox one is selected)
> {
> $query_1 = "SELECT CD_title FROM CDs WHERE artist_name = 'Hendrix'
> order by CD_title";
> }
>
> elseif(no checkboxes are checked)
> {
> $query_1 = "SELECT CD_title FROM CDs order by CD_title";
> }
>
> $result_1 = mysql_query($query_1) or die("Can't select CD_title from CDs"
> . mysql_error());
> while($row=mysql_fetch_array($result_1, MYSQL_BOTH)) ..etc...
>
> produces the error message stated above ... that the query string is
> empty. I've also tried to duplicate the "mysql_query($query_1) or
> die()..." within each section of the IF group, but then the select box
> does not get populated at all.

In order for you to get that error, neither of your two conditions are TRUE.
Since you have pseudo-code, it's hard to tell where the problem is,
though.Something in (checkbox one is selected) and (no checkboxes are
checked) is not right.

Here's an easy way to do this, though, so pay attention. :)

Create your checkboxes like this:



etc...

Notice how they are all named the same and have different value.

Now, when processing this form, you'll have a variable $_GET['artist']
that's an array. If a checkbox was checked, then the array will have some
elements, otherwise it'll be empty and not set... so use something like
this:

if(isset($_GET['artist']) && is_array($_GET['artist']) &&
!empty($_GET['artist']))
{
  $artist_list = "'" . implode("','",$_GET['artist']) . "'";
  $query = "SELECT CD_title FROM CDs WHERE artist_name IN ($artist_list)
order by CD_title";
}
else
{
  $query = "SELECT CD_title FROM CDs order by CD_title";
}

Then run your query and retrieve the results like you are doing now. What
this will to is take multiple checkboxes selected by the user (or just one
if you want) and make it into a comma separated list to send to the query.
So if two checkboxes are selected, you end up with a query such as:

WHERE artist_name IN ('Hendrix','Violent Femmes')

Hope that helps.

---John Holmes...

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



Re: [PHP-DB] sql optimizing assistance

2003-09-19 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>


> I have two tables and am running a simple join between them to get
> questions and their repsective response averages from a survey.  The
> question table has 49 rows and the Response table has 126,732.  I'd like
to
> cut down on the time its taking to run this specific query...as i'll be
> running many like it to generate reports. The query below is the selecting
> the most data, normally this will be limited to specific groups by joining
> more tables.
>
> I am executing the following query
> SELECT Question.Text_Long, AVG( Response ) FROM `Response` INNER JOIN
> Question ON Question.Question_Key = Response.Question_Key WHERE
> Question.Question_Key LIKE '2003%' GROUP BY Response.Question_Key ORDER BY
> Question.Question_Key ASC

What does EXPLAIN tell you for this query? Is it using your indexes?

---John Holmes...

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



Re: [PHP-DB] Working query not able to run with PHP script.

2003-09-19 Thread CPT John W. Holmes
From: "Jonathan Villa" <[EMAIL PROTECTED]>


> I have several tables I want to delete as well as their reference in
> another database
>
> The query produced is this:
>
===
> DROP TABLE xxx.zorder_47629403705b7e7f0c97387559d8c811; DELETE FROM
> orders WHERE table_name = "zorder_47629403705b7e7f0c97387559d8c811";
[snip]
> //$sql .= ' DROP TABLE xxx.'.$rows['table_name'].';DELETE FROM orders
> WHERE table_name = "'.$rows['table_name'].'";';
> }
> $dbConn = mysql_connect("localhost", "root", "new-password");
> mysql_select_db("xxx", $dbConn);
> mysql_query($sql, $dbConn);

You can only do one query per mysql_query() call. You'll need to loop and
call each query individually.

---John Holmes...

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



Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread CPT John W. Holmes
- Original Message - 
From: "Pat Lashley" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, September 15, 2003 5:12 PM
Subject: Re: [PHP-DB] Need to Run a PHP script using CRON or ?


> --On Monday, September 15, 2003 15:27:45 -0500 Jonathan Villa
> <[EMAIL PROTECTED]> wrote:
>
> >
> > Interesting... how does this fair concerning security?  So I'll have to
> > have this file located in my document root, is this a good thing?  My
> > current directory structure consists of several files located outside
> > the doc root.  I guess I could always include it onto a page
>
> Unfortunately command-line fetch programs seldom provide a clean
> method for providing authentication info; so you probably can't
> just restrict access to that script based on a userid/password.
> (You might be able to do something with SSL and client certificates;
> but then you need to either buy a client cert or figure out how to
> set up a private certificate authority...)

Getting off topic here, but you can specify user and password for wget. So
you could protect the file with .htaccess and provide the user/login to
wget.

The only problem is the user/password will be available when you run "ps".
For a way to get around that, see the man page of wget.

---John Holmes...

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



Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread CPT John W. Holmes
From: "Ryan Marks" <[EMAIL PROTECTED]>


> Not necessarily.  You can wget /path/to/file.php or my personal preference
> is not to use wget, but php directly
> /path/to/php/executable /path/to/file.php

Are you sure about that? I thought wget had to go through HTTP?

This didn't work for me, am I doing it wrong?

$ ls
cpanel3-skelmailpublic_html tmp
cpanelbranding  public_ftp  test.phpwww

$ wget test.php
--16:42:22--  http://test.php/
   => `index.html'
Resolving test.php... failed: No address associated with hostname.

---John Holmes...

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



Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread CPT John W. Holmes
From: "Jonathan Villa" <[EMAIL PROTECTED]>

> > wget -q -O - www.domain.com/cron.php > /dev/null

>
> Interesting... how does this fair concerning security?  So I'll have to
> have this file located in my document root, is this a good thing?  My
> current directory structure consists of several files located outside
> the doc root.  I guess I could always include it onto a page

Well, I guess it would depend upon what your "cron.php" does. You must be
aware that anyone can just type in the URL and run the script at any time,
not just when the cron process runs it. For example, my "cron.php" script
creates a mysql backup file and erases any backup files older than 30 days.
When it runs, it first checks if the backup for today was already made or
not. If it's already there, it does nothing. So, you can call this script
all you want and it's not going to mess up anything. Again, it depends on
what your script is doing, though.

Yes, it's safer to keep it outside of the webroot and call it via the
command line. This way you know it's only being called by cron and only when
you want it. It just depends on whether you can do that on your system or
not.

---John Holmes...

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



Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread CPT John W. Holmes
From: "Jonathan Villa" <[EMAIL PROTECTED]>


> I have an application which creates temporary tables.  My plan is to
> remove them after a 24 hour period and only those which are have a
> created time greater than 24 hours.  That part I can do, my question is
> how will I be able to run this script which is a 2 part script.
>
> First thing I do is pull the names of the temporary tables which are
> going to be deleted from another table.  From this result set, I need to
> DROP tables as well as remove the reference to them from the first
> table.
>
> I understand that I can run PHP from the command line but this would
> require PHP to installed as a CGI which I prefer not to do.
>
> I was hoping I that I could use CRON to run this script once a day...

You can. Create a php script that does what you want. It should not create
any output, either log status/error messages or send an email.

If you save it as cron.php, you can use a command such as the following in
your crontab:

wget -q -O - www.domain.com/cron.php > /dev/null

I'm assuming you know the specifics of cron or can google for it. :)

---John Holmes...

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



Re: [PHP-DB] how to recognize user login name?

2003-09-04 Thread CPT John W. Holmes
From: "David Smith" <[EMAIL PROTECTED]>


> Spychała Wojciech wrote:
>
> >I have to do user recognizing in m php project. Simplest method i know is
to
> >recognize for example login name (when user is logging into his local PC)
> >
> >I've tried to use $USERNAME variable but it isnt what i want because it
> >recognize login name on server not remote user
> >
>
> If you are referring to the Windows login name, this is not possible
> with PHP via the web browser.

Sure it is. It's usually in $_SERVER['LOGON_USER'] or something similar.
I've only seen this work with IIS when anonymous access is turned off,
though. This means you'll only get names for people that are on your
network, it won't work for people coming to your site from outside.

---John Holmes...

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



Re: [PHP-DB] To many connections problem with LAMP

2003-09-03 Thread CPT John W. Holmes
From: "Merlin" <[EMAIL PROTECTED]>
> I am getting more and more "to many connections" errors on my web
> application buid with LAMP.
>
> After doing some research it looks like this is a problem because I am
> using pmysql_connect instead of mysql_connect.
>
> Istn't it better to use persistant connections? There are about 14000 PI
> the system has to serve each day. It looks like this is close to the
> limit? The server itself is running on about 10%cpu. Is there a way to
> increase the amount of connections possible?
>
> Can anybody give me a suggestion on how to solve this problem and where
> to go from here?

You can set a higher max connection level with a my.cnf file. It's all
explained on the MySQL site.

Also, make sure you read the ENTIRE PAGE (with all notes) on the
mysql_connect() and mysql_pconnect() manual pages. There are really specific
configurations where using pconnect() is useful, otherwise it doesn't help
at all(and may hinder).

---John Holmes...

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



Re: [PHP-DB] Heop someone can help with this.. involves sessions.

2003-09-02 Thread CPT John W. Holmes
From: "Aaron Wolski" <[EMAIL PROTECTED]>

> I really hope you don't mind the OT post but I've looked everywhere and
> can't seem to find a solution to my problem.
>
> I am passing a var in a session (not in the URL) to my secure checkout
> area and it's not capturing the variable.
>
> I know there is a problem with using sessions across non-SSL and SSL but
> I was hoping someone would have an idea as to how to accomplish this?
>
> Both domains are setup on the same box.. the secure SSL area is
> secure.mydomain.com

The session id is maintained in a cookie (by default), so when you switch
from "non-secure" to "secure" you are probably losing the cookie because of
the difference in domains.

You need to pass the session id in the URL when switching to "secure" mode.

---John Holmes...

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



Re: [PHP-DB] SESSION SID Question

2003-08-28 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>
> Can someone explain to me the mechanism by which SID acquires a value?
>
> For example,
>
> $FOO = SID;
> echo $FOO;
>
> produces something like "PHPSESSID=ade4055eef947f1a00cdb280470e859b" when
> IE is first opened and the page is loaded,
> whereas reloading of the page produces an empty string when $FOO is
> echo'd. Seems to have something to do with creating a
> browser instance.

SID is used to pass the session ID around in URLs. It gives you the text
formatted so that you can just stick it into a URL.

Normally cookies are used to hold the session id and pass it from page to
page. If for some reason PHP cannot set the session cookie (or it's not
present), then PHP creates SID.

This means you can include SID in all of your URLs and when the cookie is
there, it'll be empty and nothing will appear in your URL (rightly so), but
if the cookie is not there, SID will place the session ID in your URL so
that your sessions persist.

---John Holmes...

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



Re: [PHP-DB] Populating an array from mysql db

2003-08-28 Thread CPT John W. Holmes
From: "mike karthauser" <[EMAIL PROTECTED]>

> Thanks for this - I ended up rehashing my query to this:
>
>  $result = mysql_query("SELECT * FROM dates WHERE bookcode = '$bookcode'
> ORDER BY date1",$db);
>
>
> // loop to populate array
>
> $myrow = mysql_fetch_array($result);
>
> $i = 1;
> while ($i <= '30') {
>
> if ($myrow['date'.$i] > '-00-00')

You're making PHP do some extra work here. You're testing to see if one
string is greater than another... how can strings be greater than or less
than? Why don't you just check for $myrow['date'.$i] != '-00-00' ??

---John Holmes...

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



Re: [PHP-DB] Populating an array from mysql db

2003-08-28 Thread CPT John W. Holmes
From: "mike karthauser" <[EMAIL PROTECTED]>


> I have a course booking system that allows the client to add courses and
> then specify how long they run for. The admin system I have built allows
the
> client to add up to 30 dates for each instance of the course and these are
> adding to a database row in the form date1, date2, date3, daten etc.
>
> What I am trying to achieve now is to extract this data into an array so I
> can count how many dates have been added and to display the dates.
>
> If the course runs for eg. 2 days - values of date1 and date2 would be
> populated as date1=2003-09-01, date2=2003-09-02 - all other dates would be
> default to -00-00 and I wish to ignore these.
>
> I'm trying to work out how to set up a loop to extract positive dates from
> my db so I end up with
>
> $bookdate[0] = '2003-09-01';
> $bookdate[1] = '2003-09-02'; etc
>
> Can anyone provide me with some help in this extraction?

With just a short comment on what a horrible, horrible database schema this
is, you should be able to use

if($date_from_db != '-00-00')
{ $bookdate[] = $date_from_db; }

---John Holmes...

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



Re: [PHP-DB] looking for a .exe file

2003-08-28 Thread CPT John W. Holmes
From: "blond al" <[EMAIL PROTECTED]>

> I need a php editor file
> thanks for help!

file:///WINNT/system32/notepad.exe

You're welcome.

---John Holmes...

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



Re: [PHP-DB] Logic Help...

2003-08-27 Thread CPT John W. Holmes
From: "NIPP, SCOTT V (SBCSI)" <[EMAIL PROTECTED]>


> Thanks for the feedback.  This seems to have helped, but something
> is still not working with the logic.  Here is the updated code:
>
>while($cntr != 0) {
> $cntr--;
> if (($shell[$cntr] == "") || ($grp[$cntr] == "")) {
>   echo " size=\"4\">Sorry, but your request was not filled out completely.  Please
> resubmit this request ensuring that you have selected a Primary Group and
> Default Shell.";
>   echo "Please
> follow this  href=\"http://ldsa.sbcld.sbc.com/DW/NewUser/newuser.php\";>link to
return
> to the beginning of the request process.";
>   exit;
> }
>   }
> ?>
>
> Now, the test conditions never seem to enter into this portion of
> code.  I am unable to figure out why at this point.  Thanks again for the
> help.

Okay... let's do some basic debugging now. What does print_r($shell) and
print_r($grp) display? Are there any entries that are equal to an empty
string?

---John Holmes...

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



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

2003-08-27 Thread CPT John W. Holmes
From: "Dillon, John" <[EMAIL PROTECTED]>

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

Escape the single quote with a backslash:

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

addslashes() works rather well for this.

---John Holmes...









































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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Problem in executing linux command from PHP

2003-08-27 Thread CPT John W. Holmes
From: "Gnanavel" <[EMAIL PROTECTED]>


> I have problem in executing  linux command
>
> $output=exec("ls -a");
> echo "$output";
>
> the above coding works, but
>
> $output=exec("cp file1 file2");
> echo "$output";
>
> does not works. can any one help me out of this problem

Riddle me this... exec() returns the last line of output from the result of
the command. What is the last line of output when you run "cp file1 file2"
from the command line?

---John Holmes...

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



Re: [PHP-DB] timestamp formatting on display?

2003-08-27 Thread CPT John W. Holmes
From: "Aaron Wolski" <[EMAIL PROTECTED]>
> Having a brain laps and not sure where in the manual to look and sadly I
> need a QUICK solution.
>
> I have a date formatted in a table like: 20030826132457
>
> Now.. I went to MySQL timestamp from UNIX timestamps because I like the
> readability of them when just looking at the Tables. How would I format
> the date something like: August 26, 2003??
>
> I could easily do this with a UNIX timestamp.. not sure if the same is
> possible with this type of timestamp. Also.. I can't use the MYSQL
> functions to format the data into a UNIX TimeStamp. not int his query.

How about using DATE_FORMAT() in your query to format the date? It works
almost the same way as date() in PHP.

If not, run the date through strtotime() and then use date() to format it.

---John Holmes...

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



Re: [PHP-DB] changing datatypes in the query

2003-08-27 Thread CPT John W. Holmes
From: "Matt Babineau" <[EMAIL PROTECTED]>
> On Tue, 2003-08-26 at 11:21, Matt Babineau wrote:
> > Tough question (I think). I am pulling some numbers out of a data base,
> > currently they are stored in a blob. When I try to "order by user_hits
> > desc" it does a text ordering, not a numerical ordering. Is there a way
> > to get it to do a numeric ordering?
>
> I think I answered my own question, I used CAST() to set the type in the
> ORDER BY statement.
>
> cast(s11.data as unsigned)

Here's a crazy idea. How about storing numerical data in a numerical column?

---John Holmes...

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



Re: [PHP-DB] Logic Help...

2003-08-26 Thread CPT John W. Holmes
From: "NIPP, SCOTT V (SBCSI)" <[EMAIL PROTECTED]>


> This isn't specifically a DB related question, but...  The following
> code snippet is not functioning for me.  I keep receiving a parse error on
> the "if" line.  Basically I want to stop execution of this page if either
of
> the conditions in the "if" statement exist.  Thanks in advance.
>
>
> #  while($cntr != 0) {
> #if (($shell[$cntr] eq "") || ($grp[$cntr] eq "Primary Gr")) {

Umm... you don't use 'eq' in PHP, you use == (that's two equal signs).

---John Holmes...

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



Re: [PHP-DB] It\'s wierd when I\'ve used forms...

2003-08-22 Thread CPT John W. Holmes
From: "Jacob A. van Zanen" <[EMAIL PROTECTED]>
> You'll have to look into stripslashes function (of the top of my head)
>
> PHP automatically puts slashes around variables

PHP automatically escapes quotes in incoming form data when magic_quotes_gpc
is enabled. If you do not want then, then either disable the setting or use
stripslashes() to remove the escape characters.

---John Holmes...


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



Re: [PHP-DB] WHERE mydatestamp > '2003-08-22 13:13:13'

2003-08-22 Thread CPT John W. Holmes
From: "Matt Babineau" <[EMAIL PROTECTED]>

> I'm trying to find things in my database that are greater then Now(),
> but the date is stored in a blob (don't ask, I know :-0). Is there a way
> I can do that comparison to find things that are in the future?

Option 1: Make a second column of DATETIME and "UPDATE Table SET
datetime_column = blob_column" and then drive on...

Option 2: Use the CAST() function... "SELECT * FROM Table WHERE
CAST(blob_column AS DATETIME) < NOW()"

Option 3: "SELECT * FROM Table WHERE UNIX_TIMESTAMP(blob_column) <
UNIX_TIMESTAMP(NOW())"

I'm sure there are more...

---John Holmes...


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



Re: [PHP-DB] join across databases - how to select databases?

2003-08-22 Thread CPT John W. Holmes
From: <[EMAIL PROTECTED]>
> to my knowledge this is not possible in MySQL.  There are only joins at
the
> table level.  I've been curious about this in the past myself, so if i'm
> incorrect, i'm hoping to hear it via this post.

You can stop hoping now. It is indeed possible. :)

mysql> select * from test1.table1;
++--+
| id | name |
++--+
|  1 | John |
|  2 | Bill |
|  3 | Mark |
++--+
3 rows in set (0.00 sec)

mysql> select * from test2.table2;
++-+
| id | name|
++-+
|  1 | Holmes  |
|  2 | Foreman |
|  3 | Smith   |
++-+
3 rows in set (0.00 sec)

mysql> select t1.name, t2.name from test1.table1 t1 join test2.table2 t2 on
t1.id = t2.id;
+--+-+
| name | name|
+--+-+
| John | Holmes  |
| Bill | Foreman |
| Mark | Smith   |
+--+-+
3 rows in set (0.00 sec)

---John Holmes...


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



Re: [PHP-DB] join across databases - how to select databases?

2003-08-22 Thread CPT John W. Holmes
From: "Moshe Weitzman" <[EMAIL PROTECTED]>


> I have looked all over the web but can't find an example *in php* for
> connecting to a mysql server, selecting database(s), and issueing a query
> which joins across databases. I already know the SQL required to achieve a
> multiple database query. My question is about how many calls to
> mysql_select_db() are required, does order matter, etc.

What have you tried? What does mysql_error() say after each attempt?

I assume something like the following would work, regardless of whether/how
you've called mysql_select_db()

SELECT t1.column FROM database1.table1 t1 JOIN database2.table2 t2 ON t1.id
= t2.id

If you have something working from the MySQL command line, then it's going
to work from mysql_query() with the same exact syntax.

---John Holmes...


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



Re: [PHP-DB] MYSQL 4.1 derived tables and PHP

2003-08-22 Thread CPT John W. Holmes
From: "Jack van Zanen" <[EMAIL PROTECTED]>
> I have installed MYSQL 4.1 with support for derived tables. If I query
Mysql
> with a query that has a subquery in the from clause it works fine. If I
now
> load this query in PHP I get invalid resource error. If I change the
select
> for another select w/o the subquery it works fine (So my php script must
be
> correct).
>
> Does PHP do syntax checking before sending the query to mysql?
> Any other solution?
> I have tried PHP 4.3.2/4.3.3 & 5.0

What does mysql_error() say?

---John Holmes...


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



Re: [PHP-DB] RE: Pivot tables

2003-08-14 Thread CPT John W. Holmes
All of the work is in the queries, so it doesn't matter that the example at
the end is in Perl.

The whole concept is that you're using SUM(IF(column=value,1,0)) to sum up
your values. To get each of the "values" you can run a query and use the
results of that query to build your second query with all of the SUMs.

---John Holmes...

- Original Message - 
From: "Dillon, John" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 11, 2003 2:09 PM
Subject: [PHP-DB] RE: Pivot tables


Darn, here's the link:

http://www.mysql.com/articles/wizard/print_version.html

-Original Message-
From: Dillon, John
Sent: 11 August 2003 19:09
To: [EMAIL PROTECTED]
Subject: Pivot tables



Here is the worth-reading mysql answer to my question below.  Pity it's
implemented on perl not PHP though...anyone know a PHP implementation?



I will need to generate a pivot table similar to that in Excel, in this
version I want to list a unique list of fields across the top and down the
side with totals - called cross-tabulations.

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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Pulling an ID list from a DB, then filtering that list againstanother list of ID's

2003-08-14 Thread CPT John W. Holmes
From: "Matt Babineau" <[EMAIL PROTECTED]>
> Got an interesting problem! I have a list of ID's, basically  things
> people have viewed on my website. When I pull the viewable items from my
> database, I need to be able to filter out all the ID's people have
> already viewed, so that they only get a list of things they have not
> viewed.
>
> I can think of a way to do this, but it is a nasty loop situation, that
> would probably not be good and tie up significant CPU time. Anyone have
> any suggestions on ways to filter view items from a fresh list that I am
> pulling from my Database?

So you have a "thing_id" and a "user_id". How do you mark the user as having
viewed the "thing"?

I'm thinking a LEFT JOIN is in order here, but need some more info on your
table structure.

---John Holmes...


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



  1   2   >