Re: [PHP-DB] mysql not valid resource. .

2005-08-09 Thread Martin Norland
A thought - if he's getting the 'not a valid resource' from just the 
code he posted, then his problem is with the $connessione variable, and 
not the query itself.  Check to make sure the connection is up at 
all/etc. and *it* is a valid resource.  Generally (well, in the simple 
case - which is the general case) you only have the one database 
connection, and don't need to bother passing it around.


Also, make sure you're using resources in the right places later - many 
times people will use the result ($query) as if it contains the rows 
returned, instead of being a resource identifier to get the rows.


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


Hutchins, Richard wrote:

Marco,

Have you tried echoing out the sql statement to the browser before it gets
sent to the database? That would show you the exact query string and give
you a chance to see where the error might reside.

$sql=select distinct des_riga, count ( des_riga ) as freq from k_riga
where id_tabella= . $id_tabella .  and id_colonna= . $id_colonna .
 group by des_riga order by des_riga;

echo $sql //ADD THIS LINE

// COMMENT THIS OUT FOR NOW $query=mysql_query ($sql, $connessione);

Rich
-Original Message-
From: Marco Strullato [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 09, 2005 9:44 AM
To: php-db@lists.php.net
Subject: [PHP-DB] mysql not valid resource


Hi all, I have a problem with mysql:
this code produce a not valid mysq resource.

$sql=select distinct des_riga, count ( des_riga ) as freq from k_riga
where id_tabella= . $id_tabella .  and id_colonna= . $id_colonna .
 group by des_riga order by des_riga;
$query=mysql_query ($sql, $connessione);

$id_tabella, $id_colonna and $connessione has the correct value...

The same query runs perfectly if I exec it directly on the db.

Do you have any suggestions?

Marco


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



Re: [PHP-DB] Re: printing errors. .

2005-08-02 Thread Martin Norland

I would like to think that we could be a little nicer to this poor fellow.

He obviously typed all of these messages on a cellphone keypad without 
predictive text entry.  He's in dire straits, and needs our help.


At least, I really hope that's the case.

thrws i m gnna gt mdvl n hs ss

Incidentally - I *think* in some of these he's actually answering 
questions, but they must be fairly old, I archive every two months or so 
and I don't see any matches in my current.


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



Miles Thompson wrote:

David,

Amen to that! Vowels do help, don't they?

Started to read this thread, then thought Bah, if he doesn't care 
enough to help us understand his problem, why bother straining to 
understand this  crap?


Miles

At 09:27 AM 8/2/2005, David Robley wrote:


(umeed wrote:

 most of the time wen dealing with
 mysql,
 i get error

 bt i want to exactly know wt the error is
 due to.

 how can i print specific error tht wil make it easy to know

u cn us mysql_error() n prnt ur qry as well

And perhaps if you write properly your questions may be better understood


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



Re: [PHP-DB] Finding duplicate contacts..

2005-07-26 Thread Martin Norland
Well, if you want to be as certain as you can - you're going to need to 
stick to a fairly rigorous check.  What you could do is export the DB 
into something PHP can quickly load right in (something serialized, for 
e.g.) every X minutes, and then at the end of the day run your 'rigorous 
 test'.  One thing that (might) spare you, is once you've checked a set 
against itself, you shouldn't need to check it again [depends on how 
changes are handled].  If you track the records that are changed updated 
or added, and every few hours (or nightly) check back over that - you'll 
have a fairly fast performing system that has few likely dupes on the whole.


Now, in my opinion you might want to stick with the idea of hitting the 
DB directly (depends) - but toss in some 'real world sanity checking'. 
Without seeing the query, I can't say if you haven't already - but 
chances are you can do quicker passes frequently, and occasionally do 
the slower more thorough checks.  Most peoples last names don't change 
often - and when they do, they could easily also change phone number and 
address.  Toss in 'soundex' to handle typos if doing it at the DB level, 
or you can use levenshtein distance [levenshtein()] to catch the 
occasional typo if hitting the info in PHP.


Another thing to note - if you know you're going to have duplicates no 
matter what your efforts, you might just want to automatically accept 
new records and let the system mark anything that looks dupe for a human 
to check over, saving you all that checking on the entry end of things 
(which I guess are done in batches, PDA sync or some such?)


If you realize there will be no fast perfect solution, you can start 
getting creative with a couple different levels and find a pretty happy 
balance.


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


[EMAIL PROTECTED] wrote:

We have a table with contacts and we need to determine if someone's already in 
there but with possibly slightly different info or if the old data contains 
duplicates.  Current criteria (I'm sure there's better):

If home phone matches any existing home, work or alt phones.
If work phone matches any existing home, work or alt phones.
If alt phone matches any existing home, work or alt phones.
If a concat of last name, street address and zip match any existing.

Table currently contains about 60,000 entries (imported from old system) and we 
can expect it to grow.

Indexes are on home, work and alt phones, as well as last name, street address 
and zip.  Tried it without indexes, it was slow.. tried it with indexes.. still 
about the same speed.

Tried seeing if putting the dupe check into a prepared statement sped it up 
any.  It didn't.

Analyzed table.  Same speed.

Out of 60,000 entries, we have roughly 40,000+ unique phone numbers (that's 
doing a union on all three phone number columns).  So even pre-compiling just 
that list and querying another table is going to be similar in time issues it 
seems.

For new contacts being brought in, we might have 30-60 at a time (maybe more) 
so this query would end up being run on each of the 30-60.  At 1.5-2 sec for 
each query, that ends up being a full minute or two to do the whole scan.

If I pull the phone #'s and name/address/zip combies into an array in PHP first, it's 
only like 12 secs, but each user would end up pulling it (and maybe store in a session 
variable or something) and re-pull it periodically to make sure it's semi-fresh.  This 
sounds like the quicker, but not the best solution.



Any tricks, tips or philosophical and/or theoretical things I've just not 
seeing, please let me know.


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



Re: [PHP-DB] Help. I am losing the plot.. .

2005-07-05 Thread Martin Norland

Ross Honniball wrote:

script1.php:

echo 'script 1 before';
require_once('script2.php');
echo 'script 1 after';

script2.php:

echo 'hello from script 2';

which in IE visually produces:

script 1 beforehello from script 2script 1 after

However if I view the source in IE, I get:

script 1 before?hello from script 2script 1 after
^
^
^
NOTICE THE QUESTION MARK.


I can't say I've ever run into it, but I would guess it relates to ? 
?'s.  Perhaps your Apache server configuration changed and it no longer 
recognizes ? start tags and only ?php - but then it shouldn't be 
echo()ing, rather just emitting the whole of the file or some such.


I'd suggest using telnet and issuing your get statement right there

telnet yourserver 80
GET /

this should give you exactly what your server returns on such a request, 
minus any customizations it has for the useragent.  View source can lie 
sometimes, unfortunately.


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


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



Re: [PHP-DB] Re: list test subject. .

2005-06-26 Thread Martin Norland

[[[ O-F-F topic ]]]

prefer replies offlist if they have to be done, but I had to clear the 
waters some on this.


that said...

JeRRy wrote:
[A lot of mostly unintelligible and worthless to quote jumble]

delays like this are not frequent, and should not be.

delays like such.  Most recently IP's were a major issue than they 
upgraded how they operate to IP(something or rather) ... IP2 or 
something.  Effected Web Hosts.  I'm not quite clear exactly what all 
this was but my web host was down for a considerable time because of it 
and all my sites effected as people could not connect.  Some were 
upgraded on the fly some sites were down for weeks or more.  My web host 
was down for 11 days.Where do you live ?


No.  You were handed a pile of lies, it's possible that a major line 
recently was upgraded or repaired.  Are you in New Zealand?

http://slashdot.org/article.pl?sid=05/06/24/0249231tid=95tid=133
More likely your web host broke something badly and had to rebuild their 
system(s).  IPv6 is the next version of IP, and it's not full replacing 
IPv4 anytime soon because coordinating the whole mess is cumbersome. 
It's already in use in plenty of places, and they use it alongside IPv4 
just fine.


Australia!I know, that the USA are realy underdeveloped (Broadband,...) 
but broken DNS or such issues?


The USA is not really underdeveloped in this area, we are just too 
widespread to have *really* fast pipes.  Broadband has penetrated the US 
quite fine and it's extremely easy to get fast always on connections


Tests were ran with certain domains.  Most domains failed in Washington 
area.  But since these tests are not always accurate but I'd guess the 
problem lays within a hop or something there.  But how would I know in 
Australia?  Another is I tried to load 
http://www.getpaid2reademails.com/ and I can't access it but people 
elsewhere can.  When I ran anonymous browsing it works.  (another 
location)More bizzare!!!


Your DNS was broken, you still had a local cache of the sites you 
frequently visit.


Not really.  A person in Canada confirmed they were not able to view the 
above site for the passed 3 days.  I can view it now.  Another person in 
Americal could see it before but can't now despite the site being online 
and the server active.  It happens quite often this occourence. This 
list seems to be working fine now, I just got a swag of emails sworming 
in all at once.  But when I see the date/time emails were sent I see 
there is quite a delay in some hitting the inboxes.Maybe you should ask 
your ISP what happen...


Again, DNS servers/issues.  DNS changes can take a long while to 
propogate.  If your webhost was also your DNS host and their servers 
went poof, it is possible some people had the lookup cached while some 
didn't.


Email has no particular guaranteed delivery time, and backoff algorithms 
differ - in addition to mail servers queuing mail up before sending.  It 
happens, mail isn't always as instant as we would like.


Why should I?  Can't you see I am using Yahoo!? lol ... Nothing wrong 
with my ISP currently.  As they don't feed my emails, they just feed the 
pages to check them. ;)  But it's great to see people interested if the 
list is still ACTIVE... Rather than forgetting it exists if people 
don't get emails every so hours.  The list has lovers.. :):-)


amen.  hail to the list. :)

I think there has been 2 emails stating is the list active lately.  But 
none have confirmed www problems.   Michelle, go back to your little 
box.Little Box ?


That's what they call a linux (of some description) O/S machine, a box. 

it's just OS - it's an abbreviation, not O/S like O/S 2.

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


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



Re: [PHP-DB] RE: php-db Digest 20 Jun 2005 23:54:37 -0000 Issue 2992. .

2005-06-22 Thread Martin Norland

Cosman CUSCHIERI wrote:

I make part of a team where we have created a system which produces reports.
The reports are produced based on selection criteria which the user sets
from an oracle database. 


The problem we are facing is that when the users selects a big time frame
the report just freezes, the status bar displays 'done' the IE (our
preferred browser) window flag stops animating and report does not show
anything, only a blank page. I am suspecting a time out somewhere. I am
using the function set_time_limit and some of the reports did improve but
still facing the problem with others. 


[snip]

Make sure php is logging its errors somewhere, and check your apache 
error logs.  This seems very much like the behavior I've seen when a 
script hits the maximum memory allowed.  It's possible the first 
bottleneck was the processing, and the second is the memory needed.


Of course, it's possible it's something else entirely - but something 
should be logged when the pages bail out like that.


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


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



Re: [PHP-DB] Shrinking gifs.. .

2005-06-22 Thread Martin Norland

nikos wrote:

Thank you Martin
I install new gd, reconfigure php and now is running OK.

But, it was a mass to realize that shortening gifs results to loss
transparency(!).

[snip]

imagecolortransparent()

That function will set the transparent color in an image (only one per 
image).  If you read the description carefully it says that it will 
return the existing one if you don't specify a new color...


so:
$transparent_color = imagecolortransparent($uploaded_img);
imagecolortransparent($thumbnail, $transparent_color);

That should get you and Nadim what you're looking for, assuming things 
work as promised (I've never used it myself).


If you need to work with pngs and the likes, imagecolorexactalpha / 
imagecolorclosestalpha - requires GD 2.01 and PHP 4.0.6 
(imagecolorallocatealpha requires PHP 4.3.2 though, oddly enough)


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


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



Re: [PHP-DB] Shrinking gifs. .

2005-06-21 Thread Martin Norland

nikos wrote:

Hello list
I'd like to make a thumbnaile list using some gifs.
I use the following code but I got error (Call to undefined function:
imagecreatefromgif() ).
Does anybody knows what's wrong?

[snip]

RH-9 Linux
Apache httpd-2.0.40-21.11
PHP Version 4.3.11
gd-1.8.4-11


gif support was removed from gd in 1.6*.  It was re-added in 2.0.28. 
This is all due to the Unisys patent on the LZW compression that gifs use.


short answer - you just don't have support for making gifs, it was a 
licensing issue at the time the software you're using was 
released/packaged.  Upgrade gd.


* funny, since gd stood for 'gif draw' originally.

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


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



Re: [PHP-DB] Strange MySQL Problem. .

2005-06-14 Thread Martin Norland

Brian D. McGrew wrote:

I'm am having the hardest time getting PHP to connect to MySQL.  From a
command line I can say 'mysql -u root -p' and connect with no problems.

[snip]

Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (13)


what do you get with:
mysql -u root -p -S/var/lib/mysql/mysql.sock
chances are you need to tell php where your mysql socket is (through 
php.ini).


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


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



Re: [PHP-DB] mysqldump but exclude one table. .

2005-06-14 Thread Martin Norland

Hassan wrote:

Hello everyone,
   I've a reader for sometime now, the best db list ever got into.
 
Well, I'd like to mysqldump a certain database, but with skipping one table, is it possible?

[snip]

from mysqldump --help

--ignore-table=name
Do not dump the specified table. To specify more than one
table to ignore, use the directive multiple times, once
for each table.  Each table must be specified with both
database and table names, e.g. --ignore-table=database.table

forgotten, but found using mysqldump --help | grep table and some 
quick scanning - docs are your friend :)


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


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



Re: [PHP-DB] mysqldump but exclude one table. .. .

2005-06-14 Thread Martin Norland

[EMAIL PROTECTED] wrote:

C:\mysqldump --version
mysqldump  Ver 9.09 Distrib 4.0.16, for Win95/Win98 (i32)

[snip]

Ummm. What version are you using, Martin?

David


fairly fresh I'm afraid.

mysqldump  Ver 10.9 Distrib 4.1.9, for pc-linux-gnu (i686)

your grep generates... interesting... output :)  Useful, but I hope its 
not default.


A quick search on mysql's site isn't giving any indication when this was 
added - though there is mention of some replication flags with 
ignore-tables in 4.0.15 - since you're 4.0.16 I'm guessing that's not 
when it was added.  Your other options are to expressly state the tables 
you want dumped

mysqldump [OPTIONS] database [tables]
the old fashioned way.  You can get listings of the database through php 
and just have an `ignore` array that skips them when building the dump 
command.


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


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



Re: [PHP-DB] Page refresh question. .

2005-06-09 Thread Martin Norland

Chris Payne wrote:


I'm using PHP and MySQL in a shopping cart system but the client wants it so
that when you add an item to the cart the page doesn't refresh and we all
know with PHP the page MUST refresh in order to execute the MySQL query.  Is
it possible, maybe with javascript? That I can talk to MySQL without having
to have the page itself refresh when they add the items to the cart?  This
is really a pain as the system was basically finished and now I'm told they
don't want the page to refresh and they see other sites that don't refresh -
sigh.  If it can be done with Javascript, do you have a sample of how I can
use PHP, Javascript and MySQL together to achieve this please?


Ask them if they're willing to lose any business at all, because any 
solution (XMLHttpRequest, hidden frame, cookies to store it until page 
refresh, etc.) will or could run into compatibility problems, and it's 
possible users won't be able to check out if they're using older browsers.


Also, it's really too late now, but you should try to demo these things 
early and be firm about having things stated as early in the process as 
possible, so you can change to meet their final request (which always 
differs from their initial) earlier rather than later.  Bottom line is 
this is probably a new request, but you may have to eat it depending on 
your situation / relationship / contract.


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


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



Re: [PHP-DB] Missing mysql.so?. .

2005-05-31 Thread Martin Norland

KEVIN ZEMBOWER wrote:

I'm trying to fix PHP and MySQL on a Debian woody system that might be pretty 
messed up. The system has some parts, perhaps some libraries, in Debian testing 
with the bulk of the system in stable. I thought it's been running okay since I 
made these system changes, but today I had to reboot it and php and MySQL 
failed.

I've removed and reinstalled the Debian packages from stable:
cn2:/var/www/centernet/htdocs/phpmyadmin# apt-get install -t stable php4 
php4-cgi php4-common php4-mysql php4-mcal php4-cli

[snip]

Is it normal that the php4, php4-mysql, php4-mcal and php4-cgi versions are all 
4.1.2, but that php4-common and php4-cli are 4.3.10?

[snip]

I tried linking or copying the files in 20010901 to 20020429, but that gave an 
error about a mismatch.

Any suggestions on what I can try to get this system back in working order? If 
possible, I'd like to stay within the Debian system, using Debian package 
management commands rather than downloading source and recompiling.

Thanks for reading through all this and for your advice and suggestions.


php4-cli and php4-common don't exist in stable, it's pulling from 
testing - I expect you've got apt-pining setup:

http://packages.debian.org/cgi-bin/search_packages.pl?keywords=php4searchon=namessubword=1version=allrelease=all

so I would start there...
apt-get remove php4-common php4-cli php4-mysql;
apt-get update;
apt-get install php4-mysql;
see how that goes.  You might need to re-remove everything.  When all is 
said and done check your php.ini, in case it has remaining lines 
pointing at wrong libs/etc.


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


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



Re: [PHP-DB] Multiselect List. .

2005-05-18 Thread Martin Norland
Patel, Aman wrote:
Ryan Jameson (USA) wrote:
That's not the problem. The problem is referring to the listbox via
javascript. It doesn't like the format: formName.listBoxName[].value it
has no problem with formName.listBoxName.value but then PHP doesn't seem
to handle it correctly.
There is a function called MM_findObj which does exactly what you 
need. I believe it originated from the Macromedia company (hence the MM 
prefix) - possibly used by Dreamweaver for its scripting purposes, but I 
digress.

Below is the funtion, and whenever you want to refer to oddly named form 
elements, you call MM_findObj('oddlyNamedFormElement[]') (and it returns 
an object reference to the form element that you can use normally).
[snip]
An addendum to that, two points:
 (mixed js and html examples, patently obvious which is which though)
1) You can use this for more than just form elements, if you give an 
item an id.  e.g.
	div id=my_great_divhello world/div
	h8_ie_my_great_div = MM_findObj(my_great_div);

2) This is just a general warning, but I used to stumble into it a lot. 
 IE creates variables/objects in the document namespace, essentially 
polluting it - good for convenience, bad for cross-browser anything.  As 
an example:
	input name=nothing
can be used as just nothing e.g.:
	alert(nothing);
... and in fact, you get errors when you try to do things like:
	nothing = MM_findObj(nothing);
because IE doesn't like to overwrite its pretty little objects.  Which 
nobody asked for.  The only solution is to use different names for the 
javascript variables describing/referring to your form/other elements.
	h8_ie_nothing = MM_findObj(nothing);

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

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


Re: [PHP-DB] php line error. .

2005-05-17 Thread martin . norland
'Yemi Obembe wrote:
 
 just care to know how php does the line counting when it echoes error 
 messages like:
 
 parse error: unexpected '}' on line 129
 
 1. does the line counting includes empty lines
yes.
 2. are externally included files (using include(), require() etc) also line 
 counted(sic)?
no. (but the line with the include() call counts normally
 3. are d parts of the file that are not in php (i mean that are not contained 
 within the php delimeters) also counted?
yes.

in short, it's the line number of the script as if it were a plain text 
file.

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

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




**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


GWAVAsigAdmID:DD28CD8AE59761E4E0C23AE2EB03BE38



**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


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

Re: [PHP-DB] problems with a script. .

2005-05-17 Thread martin . norland
John R. Sims, Jr. wrote:
  Martin; I have taken your advice and read both of the articles, but
 unfortunately I have not been able to find what needs to be changed.  As I
 mentioned, I am very new at this.
 
 Could you possibly look at the script and point me in the right direction?
[snip]
 /head  ?php
 // Set the page title and include the HTML header.
 $page_title = 'Wireless Neighborhoods';
 include_once ('include/header.html');
 
 $db_connection = mysql_connect ('db.wireless-neighborhoods.org', 'scfn',
 'scfn75') or die (mysql_error());
 $db_select = mysql_select_db('scfn') or die (mysql_error());
 // If the form was submitted, process it.
 
 if (isset($submit)) {
 $query = insert into case_note values ('0', '$id',NOW(),
 NOW(),'$cmanager', '$location', '$purpose', '$present', '$subject',
 '$note');
 if (@mysql_query ($query)) {
 ààecho 'A Case Note has been added.';
 } else {
 ààecho 'The case note could not be added.' . mysql_error();
 }
 }
 
 ?
[snip]
It looks like you are using register_globals on your development 
machine.  You'll likely find it easier to write safer/cleaner PHP 
scripts if you don't rely on this.

http://us2.php.net/register_globals

though register globals itself isn't strictly a security issue, it is a 
convenience that can cause unwanted/undue variable namespace pollution. 
  I'd recommend you disable it on your development machine ( in your 
php.ini configuration file ) and then you'll have to set about changing 
any variables that are coming from get/post - e.g.
if (isset($submit)) {
becomes
if (isset($_POST['submit'])) {
and the likes.

It's odd that your PHP 5 installation has this enabled - the default 
changed to it being off in PHP 4.2.0, and certainly hasn't changed back.

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

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




**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


GWAVAsigAdmID:A00631876AE75ABACF5876E2D91276D2



**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


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

Re: [PHP-DB] problems with a script. .

2005-05-16 Thread Martin Norland
John R. Sims, Jr. wrote:
 Martin; I have taken your advice and read both of the articles, but
unfortunately I have not been able to find what needs to be changed.  As I
mentioned, I am very new at this.
Could you possibly look at the script and point me in the right direction?
[snip]
/head  ?php
// Set the page title and include the HTML header.
$page_title = 'Wireless Neighborhoods';
include_once ('include/header.html');
$db_connection = mysql_connect ('db.wireless-neighborhoods.org', 'scfn',
'scfn75') or die (mysql_error());
$db_select = mysql_select_db('scfn') or die (mysql_error());
// If the form was submitted, process it.
if (isset($submit)) {
$query = insert into case_note values ('0', '$id',NOW(),
NOW(),'$cmanager', '$location', '$purpose', '$present', '$subject',
'$note');
if (@mysql_query ($query)) {
echo 'A Case Note has been added.';
} else {
echo 'The case note could not be added.' . mysql_error();
}
}
?
[snip]
It looks like you are using register_globals on your development 
machine.  You'll likely find it easier to write safer/cleaner PHP 
scripts if you don't rely on this.

http://us2.php.net/register_globals
though register globals itself isn't strictly a security issue, it is a 
convenience that can cause unwanted/undue variable namespace pollution. 
 I'd recommend you disable it on your development machine ( in your 
php.ini configuration file ) and then you'll have to set about changing 
any variables that are coming from get/post - e.g.
	if (isset($submit)) {
becomes
	if (isset($_POST['submit'])) {
and the likes.

It's odd that your PHP 5 installation has this enabled - the default 
changed to it being off in PHP 4.2.0, and certainly hasn't changed back.

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

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


Re: [PHP-DB] php line error. .

2005-05-16 Thread Martin Norland
'Yemi Obembe wrote:
just care to know how php does the line counting when it echoes error 
messages like:
parse error: unexpected '}' on line 129
1. does the line counting includes empty lines
yes.
2. are externally included files (using include(), require() etc) also line counted(sic)?
no. (but the line with the include() call counts normally
3. are d parts of the file that are not in php (i mean that are not contained within the php delimeters) also counted?
yes.
in short, it's the line number of the script as if it were a plain text 
file.

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

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


Re: [PHP-DB] database synchronization. .

2005-05-12 Thread Martin Norland
M Saleh EG wrote:
Are you running your sites on the same server?
If yes use only one database for all of them.
Unless he's installed the latest of either SSvX* or QFCP**, I'm guessing 
his server isn't installed at multiple sites.
  * [SSvX] Schrodinger's Server vX
  ** [QFCP] Quantum Flux Computing Platform

He could just have all the 'sites' use the same database if they were 
websites, he meant sites as in on-site, e.g. physical locations.

I have to agree that you're basically stuck with either replication, or 
the frequent synchronization you're doing now - depending on whether or 
not the servers can always be on.  Is it possible to have a delay on the 
updating of information - to have a master server for the writes, and 
local slave servers at each site for just reads - or are writes too 
common a change?

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

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


Re: [PHP-DB] problems with a script. .

2005-05-12 Thread Martin Norland
Mychael Scribner wrote:
I think you do. When I first installed php5, the tried a few apps that were
written in php4, and they never worked with 5.
-Original Message-
From: John R. Sims, Jr. [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 12, 2005 10:04 AM
To: php-db@lists.php.net; php_mysql@yahoogroups.com
Subject: [PHP-DB] problems with a script

Hi everyone,
 
I have a question.  I have built a script on my desktop that works fine, but
when I upload it to the server, it does not post the data to the database.
I checked the my server and the isp server.  I am running php 5.+ but my isp
is only running php 4.3.9  does this mean I have to change my script?
 --- eep crosspost ---
You will likely need to change some parts of it, but it should by no 
means be a complete rewrite.  We'd need more info to track down whether 
it's a specific problem - but I suggest you read this:
	http://us4.php.net/manual/en/migration5.php
and more specifically this:
	http://us4.php.net/manual/en/migration5.incompatible.php
to see what might have changed that you're using that php4 doesn't 
handle the same.  Any instances of unknown functions and the likes will 
have to be tracked down and dealt with as you hit it.

Basically - your best bet is enabling error messages (note: @ before a 
function suppresses errors) and grunting through it.  Note - obviously - 
if you are using lots of the newer php5 features (mostly related to 
classes) you probably won't want to try migrating down, and might be 
better off looking for a new host or setting up php5 on your current 
host (either you or them installing it, more likely you'll have to if 
it's even allowed).

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

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


Re: [PHP-DB] Transfering post data to a series of pages. .

2005-05-04 Thread Martin Norland
Perry, Matthew (Fire Marshal's Office) wrote:
Is there a way to transfer post data to a series of PHP pages?
For example, lets say I have the following 4 pages:
Page1.php - this page has my original post form
Page2.php - this page does one thing with the post data
Page3.php - this page does another thing with the post data
Page4.php - this page shows the results of everything I have done
Right now I am using the header: ?header(Location: page3.php);?
The problem is, the following works:
Page1.php - this page has my original post form
Page2.php - this page does one thing with the post data
Page3.php - this page shows the results of everything I have done
But when I try to add the second transfer the data is lost:
Page1.php - this page has my original post form
Page2.php - this page does one thing with the post data
Page3.php - this page does another thing with the post data
Page4.php - Only the results from Page2.php are shown
ASP does this with %Server.Transfer (transferpage1.asp)%
Is there a counterpart with PHP?
- Matthew
include() :P
seriously though, Page1.php and Page4.php are the only two pages that 
should exist, if any.  Page2 and Page3 should pretty much guaranteed be 
turned into function calls or classes and called from Page4.php.  You 
don't need to separate logic and display in separate scripts that you 
push everything at, just separate your logic out into function calls.

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

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


Re: [PHP-DB] Transfering post data to a series of pages. .. .

2005-05-04 Thread Martin Norland
Martin Norland wrote:
include() :P
seriously though, Page1.php and Page4.php are the only two pages that 
should exist, if any.  Page2 and Page3 should pretty much guaranteed be 
turned into function calls or classes and called from Page4.php.  You 
don't need to separate logic and display in separate scripts that you 
push everything at, just separate your logic out into function calls.
haha - clarification on the if any... I meant if there should even be 
a separate page for receiving the POST data.  It will depend on how you 
have things setup, as to whether or not Page1 should POST to Page4 or 
just POST back onto itself.

	For e.g. 'detail' pages I tend to have POST to themselves, so you add 
an item in the page then it enters edit mode.  Similarly with list 
pages, when modifying properties of a listed entity - e.g. activate, 
delete, share.  It all depends on how you want things, but you will 
want at least 1 .php script, as opposed to if any :)

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

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


Re: [PHP-DB] URL question. .

2005-05-02 Thread Martin Norland
Mark Cain wrote:
 a 404 script is the way I would handle it.
[snip]
- Original Message -
From: Chris Payne [EMAIL PROTECTED]
To: php-db@lists.php.net
Sent: Friday, April 29, 2005 11:00 PM
Subject: [PHP-DB] URL question
Hi there everyone,
My client needs to be able to have their url www.blahblah.com
http://www.blahblah.com/  pickup the product number but I can't do it
the way I'd want (which would be www.blahblah.com/?mls=examplenumber, instead
they said it MUST be www.blahblah.com/examplenumber - how can I grab the
number AFTER the .com in PHP so that I can process it with MySQL without
it being assigned a variable name, just the number?
[snip]
You might also want to use apache mod_rewrite
http://httpd.apache.org/docs/mod/mod_rewrite.html
e.g. .htaccess
RewriteEngine On
RewriteRule ^/prod/(.*)$ product.php?pid=$1 [R]
I don't see that there's any easy way to trap a 404 error and rewrite 
based on that, you might be able to check if the requested object 
existed beforehand and set an ENV var to check against.

I don't know whether the straight 404 work would be easiest, or whether 
you might want to combine the two.  If you absolutely can't have any 
other pieces in the URL that you can uniquely tie to product lookups, 
you'll have a hard time doing this with just mod_rewrite, so the 404 may 
be the way to go.

Still, something to be aware of.  You could also do a rewrite map if the 
products are sufficiently static, though in that case you could also 
just alias it / etc.

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

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


Re: [PHP-DB] Problems with a script. .

2005-05-02 Thread Martin Norland
John R. Sims, Jr. wrote:
 ?php
[snip * - not even gunna bother]
 /HTML
Okay, quick/proper fixes 1 - 4:
1) you never open a FORM element, you only close it - you'll be 
wanting one, probably with a method=POST.

2) you should quote your array indices... just because php will evaluate 
them as themselves doesn't mean it's a good thing to rely on.
wrong: ($_POST[master_id] == )) {
right: ($_POST['master_id'] == )) {

3) you should similarly quote and curly group for the mysql queries.
wrong:
$add_master = insert into client values ($_POST[fname]', '$_POST[lname]');
right:
$add_master = insert into client values ('{$_POST['fname']}',
'{$_POST['lname']}');
4) also, all of your queries are doing inserts - they're not specifying 
the fields they are to insert into, and I'm sure many of them should in 
fact be UPDATE statements.  You'll want to fix that before your data 
gets *too* sparse.


Once that's all fixed, go to step 5.

5) rewrite all the database accesses to prevent people from doing sql 
injection attacks and ruining everything.

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

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


Re: [PHP-DB] Headers sent error msg on one server but not the other ...... .

2005-04-29 Thread Martin Norland
David Martínez wrote:
I suggest you to activate Output Buffering at beggining of your code. 
It's so easy and should not modify the output of your code.
This prevents your error Headers already sent.
At the first line of your PHP code, insert ob_start() and in the end 
of your code insert ob_clean_flush().

If you do not want to use Output Buffering you should remove any 
character sent, including Cr Lf (\n\r). I think it's so hard and I don't 
recommend it.

Depending of your server, PHP can evaluate \n\r as nothing or evaluate 
\n\r as an output.
Personally I disagree with this.  Yes it's easy, but you should never 
enable a feature to fix a bug or problem when it can be tracked down 
(although obviously in time critical situations, using it as a 'band 
aid' is - sometimes - necessary).  With a quick pointer he was able to 
find it, and not impact the performance of his web server (output 
buffering will take more memory - since it's obviously buffering all the 
output)

More importantly though, with output buffering - no content is sent to 
the client until you flush - in your suggestion at the end.  This isn't 
always an issue since many scripts do much of their processing at the 
top anyway, but if nothing is sent to the browser - the users will (the 
majority of the time) see the page they were on, and continue 
interacting with it thinking their request didn't go through.  This will 
only increase load on your server and, depending on what the users are 
doing (and how your backend is written) could throw someone or something 
into a state of confusion.

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

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


Re: [PHP-DB] php3 and oracle9i client libraries doesn't compile. .

2005-04-28 Thread Martin Norland
neil smith wrote:
I'm using this command to configure php3
./configure --with-apxs=/usr/local/apache/bin/apxs 
--with-config-file-path=/usr/local/lib --enable-versioning 
--enable-track-vars --with-oci8=/u01/app/oracle/product/9.2.0.4 
--with-oracle=/u01/app/oracle/product/9.2.0.4 --enable-sigchild

that works ok. But when I type make it eventually fails with this error:
gcc -shared -o libphp3.so mod_php3.o libmodphp3-so.a -L/usr/local/lib 
-L/u01/app/oracle/product/9.2.0.4/lib -lclntsh -lpsa -lcore4 -lnlsrtl3 
-lclntsh -ldl -lm -lpthread -lnsl -lirc -lgdbm -lpam -lm -ldl -lcrypt 
-lresolv -Wl,--version-script=/usr/php/php-3.0.18/php.map -Wl,-rpath 
/u01/app/oracle/product/9.2.0.4/lib
/usr/bin/ld: cannot find -lpsa
collect2: ld returned 1 exit status
apxs:Break: Command failed with rc=1
make: *** [libphp3.so] Error 1


I don't understand enough about this compilation process to know what 
lpsa is and why it can't find it. Does anybody know how I can get php3 
to work with oracle 9i client libraries?
thanks in advance to anyone who can help.
-lpsa means it's trying to link a library named 'psa' - off the top of 
my head I can't say what that is, and a brief googling is proving less 
than useful.

--- end section where I am 'useful', on to questioning rant ---
Can I ask why you're using such an old version of php?  If it's for a 
legacy application I can understand, but it seems like you're giving up 
a LOT to stay on php3.  In any case - looking at the release dates for 
the two:

http://www.oracle.com/technology/software/products/oracle9i/index.html
	Oracle9i Database Release 2 Enterprise/Standard Edition for Linux New 
(26-Mar-04)

http://www.php.net/releases.php
3.0.x (latest)
# Released: 20 Oct 2000
I'd say you'd be better off trying your legacy app under php4 and moving 
to that.  If it's simply a register globals issue, then you're no safer 
in php3 than you would be in php4 with it turned on, so that's not a 
reason to stay back.

good luck determining what psa is, I have to run to a meeting but I may 
try looking again later.

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

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


Re: [PHP-DB] php3 and oracle9i client libraries doesn't compile.... . .

2005-04-28 Thread Martin Norland
Patel, Aman wrote:
As far as I know, PSA is the internal product name for Plesk Server 
Administration software. Here's the product page if you need more 
information.

http://www.sw-soft.com/ru/products/psa/
Why would PHP need PSA? I have no idea (apart from the fact that psa 
seems to be just another web server(tm) probably based on apache).
psa is an Oracle module - though I can't see what it is, maybe someone 
with Oracle somewhere could find out (there should be a psa.h somewhere) 
- it should be included with your Oracle server/client files.  At the 
bare minimum, you can search for that and make sure php3 can find it, or 
just remove the -lpsa and see what happens - could be something 
unnecessary you aren't using anyway.

	My guess is that it's an older module that's since been replaced or 
phased out, but php3's interface to it expects it to be there still. 
Could be wrong, it's happened before.

Incidentally, why does PHP need:
Professional Services Automation
Personal Security Advisor
Public Safety Announcement
Python Software Activity
Port Scan Attack
 (  3 letter abbreviations are way too crowded :P  )
cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Headers sent error msg on one server but not the other.... .

2005-04-28 Thread Martin Norland
Craig Hoffman wrote:
Hey Folks,
I have a script that times out the session if there is no activity in a 
certain amount of time.  If there is no activity the HEADER()  redirects 
to the logout page and kills the session.  Everything works fine on our 
test server, but when I test the script on the production server, I get  
an error HEADERS ALREADY SENT... after no activity.  I know all this 
stuff needs to be on top, before any  XHTML.

The test server has reg globals = OFF and the production server has them 
set to ON.  I can't change the any PHP.INI settings on the production 
server. Both servers are running PHP 4.3.10.  Other than that PHP 
installation is close to identical.   Any ideas / thoughts on what's 
causing the production server to send this error out?  Something to 
steer me in the right direction... I'm attaching a code snippet to look at:
Something is generating output before you get there - it could be as 
simple as:
---
?php
$stuff = '';
?

?php
$otherstuff = '';
?
---
Did you spot it?  That's right - a carriage return was sent.  Since your 
application works locally, I'd have to assume something is sending 
output before your scripts even start.  Is there any kind of header, 
wrapper, server-side include, or anything around the script - or perhaps 
you're making use of output buffering and the server isn't allowing its use?

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

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


Re: FW: [PHP-DB] mime-type related to extension?. .

2005-04-27 Thread Martin Norland
meal list_php wrote:
Hi I sent this on 21st of april and got no answer...
there is no way to check the real mime type of a file?
even a file without extension?
thanks,
You can call out to an external program called file (which is pretty 
much guaranteed to be there, on a Linux system) which uses some magic to 
determine the file type.  It should be able to tell you if the file is 
jpeg regardless, without any messy work from you.  It will return a 
string like so:
	$ file false.doc
	false.doc: JPEG image data, JFIF standard 1.02
I'd run a few tests with some images from different sources, but it 
should be returning a very standard string - JPEG image data should at 
least be common.  IIRC Sony also has a 'motion jpeg' which might cause 
you problems, depending on what you're doing - if you can get a hold of 
one of those to test (if it's a concern) you might want to.

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

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


Re: [PHP-DB] Memory. .

2005-04-27 Thread Martin Norland
[FOTOList.com] Suporte wrote:
Hi,
When I get something from database, using this function: pg_query 
(postgresql) or mysql_query and after put this result in somes 
variables, Am I using double memory to same data or this new variable 
point to variable with db result?
The postgresql or mysql process is storing the resultset in memory, php 
is passed the address of the resultset.  When you actually pull the 
individual rows out of the resultset into PHP and assign them a 
variable, you are storing a second copy of that.  If you pull out all 
the rows and store them in an array in PHP, you then have two copies of 
your entire data.  If you need to pull your whole set of results out 
into an array, you can immediately use pg_free_result() or 
mysql_free_result() afterwards to free up the copy using memory in the 
database.

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

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


Re: [PHP-DB] Counting HTML Lines

2005-04-15 Thread Martin Norland
Ng Hwee Hwee wrote:
is there a way to count how many lines of screen output has HTML render?
below is a sample of what i'm trying to do.. i'm trying to generate a table
with the Remarks column containing data type TEXT which may have a few
lines. therefore, i cannot just count how many rows of records i have. can
someone please help me??
basically, i need to insert a page break at every 20 lines of screen output
for printing purposes. can someone enlighten me on how i can read HTML
rendered output?? thank you really really s much!!!
I'm going to go out on a limb and answer your problem instead of your 
question - because I don't personally see your proposed method as a good 
solution for the problem.  Put simply, it's impractical to try to 
approximate how the end users browser will render content, and no matter 
what you do, you'll constantly be tweaking for exceptions.  Instead, 
we'll attack with the best weapon we have, HTML and CSS.

There are a number of ways you can get what you want, but you'll likely 
have to play with all of them just to get a single working solution.

1) thead/tfoot
	http://www.w3.org/TR/html4/struct/tables.html#h-11.2.3
This is likely the best bet and simplest way to get what you want - I 
assume the reason you are wanting to break the content up is because

2) CSS pagebreak options
'page-break-before' and 'page-break-after' can be set to 'always', 
'auto', 'left', and 'right' - left and right are for printing on both 
sides - and afaik 'left' isn't supported by anyone, and 'right' has very 
limited support - still, as far as pagebreaks, you'll mostly be just 
forcing them with an always.  It's worth noting that this is CSS2 - but 
it is some of the rare CSS2 that is supported in browsers [though not 
necessarily all, since there are even CSS1 properties not (properly) 
supported by all major browsers]

3) PRE tags if all else fails
  If you can't get any of these solutions to work, you can force your 
output to behave as expected with PRE tags and approximations.  This 
basically brings you back to your original question - counting 
linebreaks and characters and the likes, counting the lines by stripping 
the html output to determine how many characters really would go out 
(with the ob_* functions, remember though - you're just analyzing, don't 
leave the html out unless you really want to!). - except it changes to 
have you cater your output more to be predictable.  Also, remember to 
account for htmlentities if that's an issue,  = amp;, etc.  Really 
not a fun solution to entertain, IMO.

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

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


Re: [PHP-DB] using POST data for a readfile

2005-04-13 Thread Martin Norland
mel list_php wrote:
Thank you very much!
[snip]
I didn't get the base tag though, what does that mean?
It was merely a cautionary warning about sites that force a base href 
for relative URIs (including, of course, URLs)

See: http://www.w3.org/TR/html4/struct/links.html#h-12.4
cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] find a value in entire table...

2005-04-06 Thread Martin Norland
[EMAIL PROTECTED] wrote:
I need to search an entire table for a value, and then report back what 
field it was found in... how on earth do I do that?
I've a list of departments, as field names.
whenever a user interacts with that Dpet, I wanna add thier id No to the 
appropriate field.
[snip]
So I wanna input an user ID no, and then get told what Dpets have been 
accessed...

I need to learn this, as I know it's simple, but I've never had to do it 
before!
You'll be better off storing a single row for each user/department 
interaction.  In fact, break them straight out into id's and just have 
it as a linking table

user_department_interactions
|  user_id  |  department_id  |
then have a table for the departments information
departments
|  department_id  |  department_name  |  more fields...  |
a simple join in your query will tell you the department name
select distinct department_name from user_department_interactions where 
user_id=3 AND user_department_interactions.department_id = 
departments.department_id;

the above will return a list of department names that user_id 3 
interacted with.  Whenever they interact with a department you just 
insert a single row into the user_department_interactions table, if you 
only ever want to store whether they interacted at all, you can set 
constraints and catch the error on insert, or search before inserting.

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

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


Re: [PHP-DB] Slow access Apache + PHP + MySQL

2005-03-30 Thread Martin Norland
Jennifer Goodie wrote:
 -- Original message --
From: Andre Matos [EMAIL PROTECTED]
[snip]
The system administrator told me that could be the PHP session, but again,
he also was not complete sure about this.
I have no idea what this even means. 
I take it to mean that to prolong the hard drives life, he set PHPs 
sessions to write to /dev/fd0 (floppy disk) - naturally.

Seriously, that's one of the strangest I don't know so I'll just give 
them any old answer answers I've seen.  I prefer hearing stuff about 
how the moon is in parallax with the sun and the resulting increased 
magnetism (yadda yadda yadda) is causing the syntax error that suddenly 
appeared.  Nah, I'm kidding - I run my own, no sense in lying to myself.

The 64bits machines won't perform any better, and in fact will perform 
worse, if you're still running everything 32bit.  They are still going 
to be pushing around 64 bits for all their operations, even if they're 
only using the lower 32 on it.  Unless you compiled it with 
optimizations, you aren't getting any benefit from the larger word size 
being pushed around.  This still shouldn't be a terribly perceptible 
increase - my money is on the altered .conf file or lack of indexes.

What versions of the software were you using previously?  Also - you 
mentioned only one of the machines changed, but you aren't clear on what 
that machines specific duties are - are all the machines load balanced? 
 The one machine that changed seems to have all the pieces (LAMP) so I 
don't understand why you mention a database server separately from a web 
server...

It's also possible something lower level and sillier is causing the 
problem - like a bum cable, a bad hub, or a conflicting IP address.  Try 
using the system locally, off a web browser running on it, and see if 
you still see the same issues (if possible).  Try this after ruling out 
the important stuff, as these issues are unlikely if you literally just 
swapped a machine out with the config the same.

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

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


Re: [PHP-DB] Re: Just can't get it to work.. variables

2005-03-30 Thread Martin Norland
David Robley wrote:
Gavin Amm wrote:
[snip]
That would indicate that you are actually saying:
 $monthVal = $monthName[04];
where the 04 is actually a string; you have no element '04' in your array.
Cast $monthInt to an integer before you use it as an array element.
Alternatively, if you are using MySQL, you can use DATE_FORMAT to achieve
the same result.
### ORIGINAL CODE ###
while ($row = mysql_fetch_array($result)){
$monthName = array (, Jan, Feb, Mar, Apr, May,
Jun, Jul, Aug, Sep, Oct, Nov, Dec);
echo pb.$monthName[substr($row['start'], 4, 2)].
.substr($row['start'], 6, 2)./bbr\n.$row['details'].\n/p\n\n;
}
Yep, also - no need to redeclare $monthName each iteration.  If you 
wanted you could also just declare it thusly:

$monthName = array (01 = Jan, 02 = Feb, 03 = Mar, 04 = 
Apr, 05 = May, 06 = Jun, 07 = Jul, 08 = Aug, 09 
= Sep, 10 = Oct, 11 = Nov, 12 = Dec);

... incidentally, Oct/Nov/Dec should have worked previously afaik, PHP 
is fairly forgiving.  You can probably also get away with just using 
round() to get your integers where you need them, instead of the 
declaration above.

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

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


Re: [PHP-DB] Sybase CALL statement problems

2005-03-29 Thread Martin Norland
Anthony Robins wrote:
When retrieving ODBC results from Sybase SQL Anywhere 6 and 9 from a
CALLed procedure, the output to the browser is being arbitrarily
truncated. 

?php 
$DataSourceUserID = user;
$DataSourcePassword = pass;
$DataSourceName = source;

$ODBCConnect =
odbc_connect($DataSourceName,$DataSourceUserID,$DataSourcePassword);
$CallSQL = CALL mladselmeans( '', 0, , 0, , 0, ,
'mladsite', 1 );
$CallTest = odbc_exec( $ODBCConnect, $CallSQL );
odbc_result_all($CallTest);
?
The resulting output does contain proper data, but as I said, it
simply gets chopped off at a seemingly random point (I have had it
chop anywhere from 1500-25000 characters off).  The amount of
truncation seems to vary depending on the results of the CALL, and
when the results are the same, the truncation is the same.  Perhaps
the strangest thing is that I know for a fact that all of the data is
being returned by Sybase... If I use output buffering and send the
contents of the buffer to a file before the end of the script, all of
the data makes it into the file, but still not to the browser. 
Trying to free the odbc resource or close the connection results in
no output at all.
A number of possibilities come to mind - some hackish unfortunately. 
You  say with output buffering the contents make it into the file, but 
not the web browser.  Have you checked your logfiles to see if there is 
anything - perhaps the script is terminating early, etc.  Print 
something after the table as well, see if that doesn't help.  It 
certainly sounds like something is being buffered.  There are reports 
that this function doesn't return the total number of rows correctly, 
but nothing more on that as to whether that indicates a problem or not.

http://www.php.net/manual/en/function.odbc-result-all.php
Also - you may want to view the source, or open that output buffering 
generated file in a web browser - and see if the same problem persists. 
 It could just be bad data inside the database that's causing for e.g. 
!-- or span display=none or who knows what - to make it *appear* 
that the content is truncated.

Obviously - you could try something hackish where you output buffer to a 
file, then emit the file to the browser - but if its all getting into 
the file I'd say the problem lies elsewhere, and that *shouldn't* work 
anyway, or if it does it's just a buffering problem in the first place.

definitely check all logs. twice.
Incidentally, what is with the parameters to mladselmeans - it looks 
very strange :)

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

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


Re: [PHP-DB] Sybase CALL statement problems

2005-03-29 Thread Martin Norland
Anthony Robins wrote:
I have checked my logfiles, and everything seems to be running
smoothly and error free.  The truncation occurs wether I use the
odbc_result_all function or something like:
WHILE( odbc_fetch_row( $CallTest ) ):
FOR( $ii = 1; $ii = odbc_num_fields( $CallTest ); ++$ii ):
PRINT (odbc_field_name( $CallTest, $ii ) . = . odbc_result(
$CallTest, odbc_field_name( $CallTest, $ii ) ) . br);
ENDFOR;
PRINT (brbr);
ENDWHILE;
So it is not a problem with odbc_result_all.  I have compared the
source of the resulting page with the output buffering generated file
and it is definitely truncating, no -- or span display=none or
anything similar... In one case, the browser page source was 12,196
characters in length compared to 37,127 characters in the output
buffer file. 

As you said, there are some 'hackish' things that I have tried such
as tacking on several thousand characters of whitespace to the end of
the output, which still truncates, but ends up truncating in the
middle of the whitespace...  I refuse to resort to something like
this.
[snip]
(silly question) a flush() does nothing?  You could also try turning on 
output buffering, and then just ob_flush()'ing when done (and turn it 
back off).  http://www.php.net/manual/en/function.flush.php mentions 
some caveats (specifically - some that may apply to you - w32 servers, 
and mod_gzip).  The fact that adding whitespace 'helps' really screams 
it's a buffering problem IMO.

http://www.php.net/odbc_longreadlen mentions truncation, but it's 
talking about TEXT/BLOB and the likes, since you *can* get the full 
results, I doubt this is meaningful.

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

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


Re: [PHP-DB] Command Line Error

2005-03-28 Thread Martin Norland
Ron Piggott wrote:
I wrote a really simple 11 or 12 line PHP script to remove old entries from
a web card application I made:
?
$todays_date=DATE(Y-m-d);
[snip]
Take a look at this line:
$todays_date=DATE(Y-m-d);
When it is ran from the command line this line causes the script to give
these error messages:
/home/actsmin/actsministries-www/webcards/administration/daily_maintenance.p
hp3: line 3: syntax error near unexpected token `DATE('
/home/actsmin/actsministries-www/webcards/administration/daily_maintenance.p
hp3: line 3: `$todays_date = DATE(Y-m-d);'
Any idea why the command line can't deal with but the http:// version works
just fine?
I'm guessing you're not running this through php, you've just made it 
executable?  You need to either give it some #! magic (e.g. #!/bin/php) 
- or - more clearly, call php from cron and pass it this script.  (In 
either case, ?php is better form than just ?.

00 8-19/2 * * mon-fri /usr/bin/php /foo/backup_script.php
[if you aren't suppressing output properly, you can also do this]
00 8-19/2 * * mon-fri /usr/bin/php /foo/backup_script.php  /dev/null
[though it's better to suppress output properly, so you can get any 
error messages/etc.]

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

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


Re: [PHP-DB] Command Line Error

2005-03-28 Thread Martin Norland
Martin Norland wrote:
00 8-19/2 * * mon-fri /usr/bin/php /foo/backup_script.php
I should have mentioned this - this runs twice an hour Monday through 
Friday, between the hours of 8am and 7pm.  You would more likely prefer

05 1* * *   your_command
which would run at 1:05am every day.  use 'crontab -e' to edit your own 
crontab.

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

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


Re: [PHP-DB] database connection timeout

2005-03-24 Thread Martin Norland
Juffermans, Jos wrote:
Hi,
[snip]
Hello, again.
I'm afraid phrasing a question multiple ways over a course of days tends 
not to have much success.  In an effort to avoid populating google with 
just the question, I will give to you what I would try.

( please note the irony of this  now. )
I'm trying to connect to an Oracle database (using ocilogon) which is in a
different country and connected to our serverfarm via a VPN (the database
has no public access). Unfortunately the VPN or the database is not always
available. In those cases I will present the visitor with a page explaining
that the service is unavailable.
[snip]
Is it that it's not always available, or that it needs time to 'come 
back up'.  You may want to try running some random low-traffic 
application over it to make sure it remains running.  Some simple SNMP 
protocol or even simpler just connect to a remote GKrellM.  Heck, a ssh 
connection with top running would do - just something that is constantly 
transmitting a trickle of data.

My problem is that ocilogon takes a long time to return control if the
connection cannot be established - often even more than 30 seconds. I've
learned that if a connection can be established it'll happen in only a few
seconds (usually within 1 second) and am convinced that if the connection is
not established in eg 5 seconds, there is no point in waiting another eg 30
seconds. How can I tell ocilogon to timeout after eg 5 seconds (like you can
with fsockopen)?
[snip]
I can't claim whether or not it will work since I don't have an Oracle 
server handy, so I will merely name functions and talk a bunch.

Essentially, you want ocilogon (complex network function to login to a 
networked Oracle [in this case] server) to timeout just like fsockopen 
(fairly simple function to open a socket, including network resources). 
 My suggestion is to try connecting using fsockopen, with the timeout. 
 If it successfully connects - chances are, the majority of the time, 
your ocilogon that follows will work as well.

Unfortunately, the stream_set_* functions rely on a valid stream 
resource, so they won't work with ocilogon (if there was any chance they 
would).  That would have been a nice route to go otherwise.

Another dirty little trick you might use is running the ocilogon in a 
separate script and making use of set_time_limit() to make sure it 
doesn't run too long.  Just be sure not to set_time_limit() for your 
whole set of scripts, unless you really want them to abort after the 5 
or 10 second limit you're setting ocilogon (unlikely).

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

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


Re: [PHP-DB] database connection timeout

2005-03-24 Thread Martin Norland
Juffermans, Jos wrote:
I understand your point but since I wasn't getting any response and never
received a confirmation email from the system telling me that my email
account had been verified, I wasn't sure that the original post was actually
sent to the community. Oddly enough I got an email from the system this
morning asking me to verify my email address - again :s
Fair enough, I've been on that boat before. :)
The VPN connection is not always available. I'm afraid I don't have much
control over the VPN myself and I believe only the Oracle port has been
opened in this VPN.
You might want to contact whoever manages the VPN - it sure sounds like 
it needs to always be up!

MN Essentially, you want ocilogon (complex network function to login to a 
MN networked Oracle [in this case] server) to timeout just like fsockopen 
MN (fairly simple function to open a socket, including network resources). 
MN   My suggestion is to try connecting using fsockopen, with the timeout. 
MN   If it successfully connects - chances are, the majority of the time, 
MN your ocilogon that follows will work as well.
That's a good idea, I'll try to connect to the Oracle port thru fsockopen.
Let us on the list know how/whether or not this works, It's definitely 
worth having some info on.

MN Another dirty little trick you might use is running the ocilogon in a 
MN separate script and making use of set_time_limit() to make sure it 
MN doesn't run too long.  Just be sure not to set_time_limit() for your 
MN whole set of scripts, unless you really want them to abort after the 5 
MN or 10 second limit you're setting ocilogon (unlikely).
I'm not sure if I can set the time limit (safemode...) but are you saying
that set_time_limit only affects the script that you include and not the
caller script?
No no no - include() should be the same as if you just placed the code 
right where the include is, so it would apply it to the whole script.
You'll have to call out separately and make it another process,  and 
exec or something - a small script whose sole intention is to determine 
if the VPN is up.  exec() or the likes - like I said - dirty trick/hack. 
 The idea is to just have it return 0 or 1 [actually, depending on how 
the time limit works, it may not return anything if it ends 
prematurely].  Definitely try the fsockopen bit first, and give it a few 
go's if it's not working.

I'll try the fsockopen connection test on the oracle port. Thanks for your
help.
Welcome to the list!
cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Why not ?

2005-03-24 Thread Martin Norland
JeRRy wrote:
Why does this NOT work?
UPDATE tipping SET score = 3 WHERE round1.game1 = H
AND tipping.username = jerry;
Please inform?
You're not linking table round1 to table tipping in any way, and you've 
got some quoting issues.

something like this:
UPDATE tipping SET score=3 WHERE round1.game1='H' AND 
round1.username=tipping.username AND tipping.username='jerry';

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

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


Re: [PHP-DB] Re: paginating : optimising queries

2005-03-22 Thread Martin Norland
Hatem wrote:
Fetching 10 rows is much faster than 1000 ! Fourat
your code is optimized just keep it as it :) just keep
your code away from adodb, pear db, and such
abstraction if you want speed ! you don't need to talk
about optimisation with 2 queries.
Regards,
Hatem
Depends on the DB, in many cases the times are so similar as to not be 
worthwhile - but yes, I agree - limits are definitely worthwhile.

Run the query without the limit, this gives you the count - don't 
actually fetch the rows.  Now run the same query, with the limit.  If 
your database is worth anything (most any is), it has this query cached 
and it takes negligible extra time, and you don't have to spend time 
'skipping' ahead X rows.  If your database interface functions support 
'skipping' ahead - use that instead.

Obviously, for page 1 of a paginated list, this performs worse than just 
running the single query.  But if you get to page 99, you'll likely find 
this is faster.  Feel free to do your own tests, many factors can change 
all of these findings, and it's best to match them to suit your own 
scenario.

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

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


Re: [PHP-DB] Re: paginating : optimising queries

2005-03-22 Thread Martin Norland
Lester Caine wrote:
[snip]
Don't know what you are using ;)
Transferring 1000 records is always going to take time, when you only 
need 10 to be displayed.
[snip]
I wasn't referring to transferring the record, only running the query.
[snip]
Run the query without the limit, this gives you the count - don't 
actually fetch the rows.  Now run the same query, with the limit.  If 
your database is worth anything (most any is), it has this query 
cached and it takes negligible extra time, and you don't have to spend 
time 'skipping' ahead X rows.  If your database interface functions 
support 'skipping' ahead - use that instead.

The trick with any transactional database is to maintain the most used 
counts in a second table, and manage those counts with triggers, so you 
only need a single record read to access them. The counts will always be 
valid for your view of the database then.
[snip]
This only works for known queries - anything that is filtered or 
otherwise limited won't benefit from this - but you still need to spend 
time maintaining the count.  I'm speaking in a general, global, 
automated statement creation sense - you can't just wrap a count(*) 
around any given sql query - and in many cases, even when you can - it 
still ends up computing just as much information, so either way it 
calculates all the rows that would be returned.
[snip]
Obviously, for page 1 of a paginated list, this performs worse than 
just running the single query.  But if you get to page 99, you'll 
likely find this is faster.  Feel free to do your own tests, many 
factors can change all of these findings, and it's best to match them 
to suit your own scenario.
The ADOdb pager only needs to know how many pages to indicate in the 
navigate bar, and how many records to download. In theory this can be 
very fast, and only slows down where a database engine does not support 
a simple limited read. pgsql driver in ADOdb supports LIMIT so it's only 
the calculation of COUNT(*) that needs replacing with a faster 
pre-calculated count.
[snip]
I've been talking about using LIMIT the whole time, I'm not sure where 
you're going with this - I was merely further explaining what was likely 
obvious anyway.  Naturally when you pull in * ordered by an indexed 
column you gain speed with limits, but when you start putting conditions 
on things, the queries have to run across (many|all) the rows.

I try to speak in general terms on this list, not everyone is using 
ADOdb or mysql (though I often slip into speaking about mysql since 
people either use it, are familiar with it, or at the very least - any 
standard sql engine will support the same features)

My statements were always related to using pagination in a general sense 
 - e.g. a class you create for pagination, that can paginate any manner 
of query cleanly.  If you're dealing solely with hard-coded / 
hand-crafted queries, you can obviously build your pagination to fit.

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

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


Re: [PHP-DB] Re: paginating : optimising queries

2005-03-22 Thread Martin Norland
On a side note, who's sick of seeing the word optimizing misspelled in 
the title? :)

Ah, the things we do to keep a thread clean.
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Re: paginating : optimising queries

2005-03-22 Thread Martin Norland
[EMAIL PROTECTED] wrote:
  On a side note, who's sick of seeing the word optimizing misspelled in
  the title? :)
  Ah, the things we do to keep a thread clean.
[snip]
Well, of course, _optimise_ is the British spelling of _optimize_ .
Afterall, this __is__ an international list ;-
David
My apologies to all, 'dict' tricked me - it has 'optimize', 'optimise', 
'optimizing', but not 'optimising' - and I foolishly only checked the 
-ing conjugated tense instead of the root! (I do try a cursory check 
before posting such nonesense, honest!)

Now back to your regularly scheduled international discussion...
cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Re: paginating : optimising queries

2005-03-22 Thread Martin Norland
Hutchins, Richard wrote:
nonesense??
Sorry, couldn't resist, Martin. ;)
This isn't a spelling bee anyway. I don't think it actually matters to
anybody. I'll take solid programming advice with a few spelling errors over
a shot in the dark with perfect spelling any day.
Elbonian spelling. (tribute/apologies to Scott Adams)
cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Re: paginating : optimising queries

2005-03-22 Thread Martin Norland
[EMAIL PROTECTED] wrote:
[snip]
My apologies to all, 'dict' tricked me - it has 'optimize', 'optimise', 
'optimizing', but not 'optimising' - and I foolishly only checked the 
-ing conjugated tense instead of the root! (I do try a cursory check 
before posting such nonesense, honest!)

Now back to your regularly scheduled international discussion...
Martin,
No apologies necessary from my perspective. You are a very active member 
of these php lists, and you have helped a great many php users the world 
over. I'm afraid some cross cultural sensitization kicked in on my end 
from many years working in human services.

David
Last post on this from me, honest!  Next one will be helpful and totally 
on-target.  Pose questions at will.
---
Okay, now I think I just got an apology in response to my apology.  We 
better stop this right here and now or we're all going to end up with 
cavities and false teeth, it's getting awfully sweet in here. :)

On a quick final note - you were right IMO.  There is entirely too 
little acknowledgement of anything international in the average mindset 
I see or come across.  Look at character sets / encodings support in 
applications - I8LN - it's all only barely starting to come together 
these days, after how many years of computer usage?  It took forever to 
break down the mindset that 'not everyone who uses a computer 
speaks/writes English'.

(defensive statement: yes I know it (the correct British spelling) is 
still English - but it does open the wider concern.)

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

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


Re: [PHP-DB] grabbing data from other peoples sites

2005-03-17 Thread Martin Norland
Perry, Matthew (Fire Marshal's Office) wrote:
I guess my real question is how to parse the output from someone else's
site.  Setting up the lookup procedure from data in my database and filling
their form with the address is the easy part.  How do I make their form
submit, parse the output, store it, and then reuse it in another function?
I have never tried something like this before.
- Matthew
[snip]
just fyi - you should test this on your own site until it's working as 
you expect, then start poking at them - it's only proper, and you can 
debug better that way.  You may want to see about setting a referrer as 
well, they may check for it.  Lastly - if they require a cookie of some 
sort, you'll have to figure that bit out :)  Should be doable, just need 
two requests/etc.

example modified from php manual user contrib notes for fsockopen ( joe 
at edwardsconsultants dot com (10-Aug-2003 08:56) original example )
//
oh - and it's untested by yours truly.
//
$proto = http;
$host = foobarfoobar.com;
$port = 80; // or 443 for https
$path = /where/on/their/site/lookup_backend.php;
$our_data = array ( address = 55 main street );
$poststring = ;
// build our post
foreach ($our_data as $key = $val) {
	$poststring .= urlencode($key) . = . urlencode($val) . ;
}
// strip off trailing ampersand
if ($poststring != ) { $poststring = substr($poststring, 0, -1); }

// done with setup - now let's move on to the action
$fp = fsockopen($proto.'://'.$host, $port, $errno, $errstr, $timeout = 30);
if (!fp) {
echo $errstr ($errno)\n;
} else {
// send request
fputs($fp, POST $path HTTP/1.1\r\n);
fputs($fp, Host: $host\r\n);
fputs($fp, Content-type: application/x-www-form-urlencoded\r\n);
fputs($fp, Content-length: .strlen($poststring).\r\n);
fputs($fp, Connection: close\r\n\r\n);
fputs($fp, $poststring . \r\n\r\n);
// get response
while(!feof($fp)) {
*/
todo - do something other than fgets with this.
it would be better to get the whole response then close 
fp, then move on to doing what you need - instead of
doing your database stuff right away.
*/
echo fgets($fp, 4096);
}
//close fp - we are done with it
fclose($fp);
}
Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] grabbing data from other peoples sites

2005-03-17 Thread Martin Norland
Incidentally, as with many other messages that arrive at this list - if 
you happen to be using a certain *wonderful* email client that thinks it 
knows better than the sender, click the Extra line breaks in this 
message were removed.  To restore, click here yellow info box - to 
avoid the migraine of trying to read unsplit code.

Cheers,
Martin Norland wrote:
Perry, Matthew (Fire Marshal's Office) wrote:
I guess my real question is how to parse the output from someone else's
site.  Setting up the lookup procedure from data in my database and 
filling
their form with the address is the easy part.  How do I make their form
submit, parse the output, store it, and then reuse it in another 
function?
I have never tried something like this before.
- Matthew
[snip]
just fyi - you should test this on your own site until it's working as 
you expect, then start poking at them - it's only proper, and you can 
debug better that way.  You may want to see about setting a referrer as 
well, they may check for it.  Lastly - if they require a cookie of some 
sort, you'll have to figure that bit out :)  Should be doable, just need 
two requests/etc.

example modified from php manual user contrib notes for fsockopen ( joe 
at edwardsconsultants dot com (10-Aug-2003 08:56) original example )
//
oh - and it's untested by yours truly.
//
$proto = http;
$host = foobarfoobar.com;
$port = 80; // or 443 for https
$path = /where/on/their/site/lookup_backend.php;
$our_data = array ( address = 55 main street );
$poststring = ;
// build our post
foreach ($our_data as $key = $val) {
$poststring .= urlencode($key) . = . urlencode($val) . ;
}
// strip off trailing ampersand
if ($poststring != ) { $poststring = substr($poststring, 0, -1); }

// done with setup - now let's move on to the action
$fp = fsockopen($proto.'://'.$host, $port, $errno, $errstr, $timeout = 30);
if (!fp) {
echo $errstr ($errno)\n;
} else {
// send request
fputs($fp, POST $path HTTP/1.1\r\n);
fputs($fp, Host: $host\r\n);
fputs($fp, Content-type: application/x-www-form-urlencoded\r\n);
fputs($fp, Content-length: .strlen($poststring).\r\n);
fputs($fp, Connection: close\r\n\r\n);
fputs($fp, $poststring . \r\n\r\n);
// get response
while(!feof($fp)) {
*/
todo - do something other than fgets with this.
it would be better to get the whole response then close
fp, then move on to doing what you need - instead of
doing your database stuff right away.
*/
echo fgets($fp, 4096);
}
//close fp - we are done with it
fclose($fp);
}

Cheers,

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

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


Re: [PHP-DB] grabbing data from other peoples sites

2005-03-16 Thread Martin Norland
Perry, Matthew (Fire Marshal's Office) wrote:
[snip]
What this has to do with PHP
Is there a way to write some sort of PHP script that accesses to the county
auditors website, automatically enters the info into their form, grabs
whatever information is outputted, imports the data into our SQL Server, and
repeats the process for all addresses in our database?
I will of course research the legality of this before we implement the
script.  I just wanted to know if this was even feasible before we meet
about this.  I don't even know where we should start.
Sure, you're just issuing POST requests with data from your database, 
and parsing the output - and entering that extracted data back into your 
database again.  A better question, however, would be how are you 
planning to handle this once you are ready to run it - are you just 
storing the address at each corner of your 'covered regions'?  You'll 
need some kind of fuzzy lookup to be able to do all this.

Maybe a better solution would be to just link directly to the county 
auditors website with instructions, allowing the users to do their 
queries as they're needed?  Even if you have every current covered 
address on file, people may mistype things - new buildings are created - 
roads are renamed, etc.

Someone should contact maps.google.com and see about adding this sort of 
information to that :)

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

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


Re: [PHP-DB] Variable Variable Array

2005-03-10 Thread Martin Norland
Ryan Jameson (USA) wrote:
Hi Folks,
I've been using variable variables for years with PHP.
$var = myVarName;
$$var = Some Val;
echo $myVarName; //outputs Some Val
[snip]
Example:
$var['first']='bob';
$var['second']='frank';
$varName = myVarName;
$$varName = $var;
echo $$varName['second']; //should output frank but doesn't. :-\
-
echo $var['second']; //should output frank works fine.
Try adding
	$frank = 'woopsie!';
to the top of your script and running it.
-
	echo ${$VarName}['second'];
is what you want - you want to be very clear what order these things 
need to be analyzed in, especially when dealing with arrays and the likes.

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

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


Re: [PHP-DB] Variable Variable Array

2005-03-10 Thread Martin Norland
Evert|Rooftop Solutions wrote:
Ryan Jameson (USA) wrote:
I've been using variable variables for years with PHP.
I'm not really sure this is really good practice. Sure, php allows it 
but I think you should try to avoid them.
[snip]
It's excellent practice to use dynamic variables* when you need them. 
There are simply no practical ways around them in many cases, and they 
can make cleaner and shorter code in many many places.

For truly dynamic pieces of code, there's really just no other way 
(creating an arbitrary class object for an arbitrary database table and 
calling common methods (e.g. validate_data(), add()) on said classes.

Of course, when you're doing things like this, you need to make sure 
you're sanity checking your data that much more, as you can get into 
namespace issues if you aren't careful.

but if you're careful, you can get fun scary things like this!
$this-{$this-form} = new $this-form;
or this!
	$this-result[$table_name][$view_name] = 
${{$table_name}{$view_name}}-add($view_data);

... be sure to comment your code :)
* Note: I call them dynamic variables, I have no clue if that's the 
'accepted' term for them.  Makes sense to me, though.

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

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


Re: [PHP-DB] big data base

2005-03-09 Thread Martin Norland
luis medrano wrote:
Hi All,
I need you help. I need to design a very big data base, around 900GB
or more of information but I never had design or manage this magnitude
of information before. I really appreciate if you can point me to
documentation to how can do this properly  or you can help me with
some experiance you have doing this.
I wasn't going to chime in, but after reading some replies I feel I have to.
Bottom line - you need to give more details.
The design of the database will not depend greatly on the amount of data 
inside it, unless there are operations/calculations to be done on/with 
it.  Most people talk number of rows / tables / read|write operations / 
joins / etc. when talking database design, instead of size - as with 
proper indexes, the size can affect things very little.

For example - if you're designing a database to store 20GB raw movie 
files - then you might want to rethink storing the gigs of data inside 
the database, then suddenly you aren't working with a large database 
at all.

So, if you can't give more details - you're going to have to search on 
your own.  Otherwise, you might want to speak up with some more info so 
you can get better recommendations.

My only suggestion with the information you've given - is basically what 
Bastien said - multiple big iron and big fast hard disks / SAN.  Other 
than that, I can only suggest that you design it well :)

P.S.
 - I wanted to toss in a troll reply about trying SQLLite, since it 
comes with PHP! - but that's mean
P.P.S.
 - I was also tempted to link to a great tutorial on this - an 
arbitrary resume writing tutorial, as a mean spiteful joke about being 
in over your head - but that's just too mean.  It all depends on the 
system requirements, your budget, and your time.

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

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


Re: [PHP-DB] Merge result set of query?

2005-03-09 Thread Martin Norland
ioannes wrote:
My first attempt was to use $result=array_merge($result1,$result2) - 
doesn't work.  'not a valid resource'

I have two databases with different connections, so MySQL UNION query 
would not work.

How do I merge the result set of the queries in that case?
You're going to have to merge the results within PHP.
not a valid resource is an error you get when you try to read from a 
result set and what you pass it isn't a resource for a result set.

I think you're doing something along the lines of:
$result1 = query_database_one($somequery);
$result2 = query_database_two($someotherquery);
$result = array_merge($result1, $result2);
while (mysql_fetch_row($result)) {
// foo
}
...
Which won't work on any level.  mysql_fetch_row takes a resource, it's a 
pointer to give the database to retrieve the row.  When you do your 
query to the database, the database does the query but doesn't return 
the full result - instead it just returns a resource to the result, so 
you can get it as you need it.

I suggest you start from that information and work forward.
cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Merge result set of query?

2005-03-09 Thread Martin Norland
Jochem Maas wrote:
Martin Norland wrote:
ioannes wrote:
My first attempt was to use $result=array_merge($result1,$result2) - 
doesn't work.  'not a valid resource'

I have two databases with different connections, so MySQL UNION query 
would not work.

How do I merge the result set of the queries in that case?

You're going to have to merge the results within PHP.
not a valid resource is an error you get when you try to read from a 
result set and what you pass it isn't a resource for a result set.

I think you're doing something along the lines of:
$result1 = query_database_one($somequery);
$result2 = query_database_two($someotherquery);
$result = array_merge($result1, $result2);
while (mysql_fetch_row($result)) {

while reading I thought, would this:
while (($row = mysql_fetch_row($result)) || ($row = 
mysql_fetch_row($result2)))
{
// just do it. 
}

.. work (due to shortcircuiting)? and how ugly is it?
// foo
}
That would work if you just wanted to iterate over both resultsets and 
do the same thing, yes. Say, if you had lists of users who signed up for 
something in two separate databases, you could print them all out with 
that.  Since he said union and not join - that is probably his intention.

I can't decide if that code is beautiful or horribly ugly though...  I 
would have to say it's beautiful so long as the 'just do it' is very 
short - if the 'just do it' should be a function - then you should just 
suck it up and do two while's.  Also, for every result in $result2, you 
have to poke at the first database and say any more yet?, which is 
hackish.

slick 'obfuscated perl' entry type fix though :) [okay, it's not 
obfuscated in the traditional sense]

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

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


Re: [PHP-DB] mysql_num_rows

2005-03-08 Thread Martin Norland
Calvin Lough wrote:
That means that you dont have any rows to work with. It could mean
that you are not connected to the database, or the query you performed
did not return any rows.
Calvin
On Tue, 8 Mar 2005 16:11:10 +0300, Tsegaye Woldegebriel
[EMAIL PROTECTED] wrote:
Dear Sir or Madame,
I found the following error,
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /home/xxx/public_html/sitename/dynamicfile.php on line 61
What is the reason?
I want anyone who knows to answer to reply me.
Thank you in advance for sharing your precious time.
Just to clarify - you won't get this error if a valid SQL query is 
performed and it returns no rows.  This means just what it says - the 
argument passed to it is not the result of a valid SQL query that has 
been executed on the server. (note: result of a query, not the query 
itself - it should print_r as a number not as a select blah - it's a 
result resource, a pointer of sorts).

  More likely is the query is invalid, go ahead and print_r() the 
variable being passed to mysql_num_rows() on line 61 (put it before the 
mysql_num_rows call) and see what info you get back in there.

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

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


Re: [PHP-DB] Shopping Cart

2005-03-07 Thread Martin Norland
 the search, 
sort them however you want - default to product id, have an option to 
sort by price, etc.

  It's just a listing of products, like before, they just happen to be 
filtered to a specific vehicle/make/model/etc.  Join that cart search to 
the products table on the pid, pull the information of interest, and 
have at it.  That cart search is just a table holding metadata on a 
product, there's no need to list it until you've already chosen a 
specific product.

If you're talking about not knowing how to sort it in SQL:
$my_order_field = 'products.price';
$order_direction = 'ASC'; // DESC
SELECT cart_search.*, products.price, products.desc, products.cat_num 
from cart_search, WHERE make='{$_POST[make]}' AND 
model='{$_POST[model]}' AND year='{$_POST[year]}' AND products.pid = 
cart_search.pid ORDER BY $my_order_field $order_direction;

but maybe I'm misunderstanding the problem, you seem to have everything 
under control...

P.S. - If you have it (the data) in digital form, I highly recommend 
setting up an import.  Your interface won't get the testing it would 
otherwise, but it will sure save a huge heap of hours, for someone at 
least.  If you get updates in digital form, you can always diff them and 
just add the new bits.  The error rate approaches zero much faster 
without the human factor.

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

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


Re: [PHP-DB] data grabbing and mathematics!

2005-03-07 Thread Martin Norland
JeRRy wrote:
Hi,
I have 23 tables, well I have more but these 23 tables
are the main agenda regarding this question.
In each of the table is a column titled score and a
column titled nickname ... These are the two columns
we need for this.
[snip]
Now I want the scores added up.  So using the + not *
(times) but just adding.  So for Bob is 5 + 3 = 8 and
this figure must than be placed in another table with
that name.
What I want to do is just have one code written up so
I don't need to change it.  So in other words the code
would include all 22 tables and the method to add each
other together and update to the actual main scoring
table.
So the score aRE updated once a week.  I don't mind if
I need to trigger the update (preffered) from a php
page/script.  That's not the problem but I want to
know what code I would use to grab these details and
add them up using all 22 tables in the one script.  So
each time the script is ran it will re-calculate all
tables to make sure they are correct if an update is
made to a score.
So the script would grab all 22 tables score and
nickname and than match the nickname and update their
score in the scoring table.
What I have is this:
My Tables are round 1 through to round22 and the
scoring totals go into table called tipping.
So round1 through to 22 need to be calculated and
keeping the totals for each nickname correct with
their totals.  Don't want the scores to be jumbled
with a different nickname.
How would I do this that would be a pretty fast
process and reliable?
If you need more information please let me know.  Each
round table will have identical Nicknames in each,
none will have more or few, same amount.
Keeping in mind each round that has not had a total
set is defaulted as nothing in the score field, it's
blank.  But if it's required to have a value of 0 in
there for the calculations to work I can default this
in.
If anyone can help me here it would be great, I have
been stuck on this for a while.  There is only going
to be like 15 names max in each round to do totals for
so it's not a huge database.  

Thanks for your time.
[snip]
well - two options spring to mind...
1) use a single table, with 23 columns instead of 2.  Then sum the 
columns in your query.
 - 1 query, no loops required.
2) have your script pull everything and add it all up.
 - 22 queries, a loop for each, array storing scores  indexed by name.

anything else is going to be a join from hell.  With only 22 tables and 
15 rows in each table, you literally won't be able to blink before 
either of these methods would be finished calculating your totals.

Whatever you code up will be as reliable as the code used for it :)
A better question to ask is, will this be something that cycles yearly 
or regularly?  If so, you'll want to be storing some identifier for the 
event/session/quarter/year/etc. - in which case any join option would be 
insanely further compliated, and all of your queries would need the 
chunk added.

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

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


Re: [PHP-DB] regex question

2005-03-07 Thread Martin Norland
Chip Wiegand wrote:
I am writing some regex on a php form to validate input and have come up 
with this, for example -

if (empty($first) || !eregi(^[A-Za-z]+[- ]?[A-Za-z]+$, $first))
for checking a persons name. This allows a single name, or a hyphenated 
double name, or a non-hyphenated double name, and it works. My question is 
this - why is the third set followed by a '+' optional? I thought the + 
meant the preceding group is present 1 or more times. The ? means the 
preceding group is present 0 or more times. Why is it that when I put a ? 
in the place of the + after the last ] 

if (empty($first) || !eregi(^[A-Za-z]+[- ]?[A-Za-z]?$, $first))
the regex is broken?
The ? doesn't mean 0 or more, it means 'optional' - 0 or 1 times.
without specific examples on what works or what breaks, I can't explain 
it much better than this - but rest assured, that's your problem.

now I'm sitting here wondering if ?* and ?+ are interchangeable, and 
thinking so.

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

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


Re: [PHP-DB] Re:data grabbing and mathematics!

2005-03-07 Thread Martin Norland
Neil Smith [MVP, Digital media] wrote:
At 17:15 07/03/2005 +, you wrote:
well - two options spring to mind...
1) use a single table, with 23 columns instead of 2.  Then sum the 
columns in your query.
 - 1 query, no loops required.
2) have your script pull everything and add it all up.
 - 22 queries, a loop for each, array storing scores  indexed by name.
Actually I disagree strongly unless your intention is to be able to read 
the rows yourself !
As the stated intention is to add up scores (doing the maths) in fact 
much more efficiently you want to have just 3 columns in a single table, 
tblBlah :

UserRoundNumber RoundScore
Bob 1   6
Bob 2   2
Bob 3   3
Steve   1   5
Steve   3   1
Steve   4   6
[snip]
Now you've got a list of rounds and the average score per round. And you 
don't have to write a gigantic query across 23 tables like SELECT 
tbl1.RoundScore, tbl2.RoundScore, tbl3.RoundScore, tbl4.RoundScore  
even if that was practical (you'd have to use outer joins and the result 
set would be huge).

Using multiple tables, or even multiple columns is deeply inefficient 
for this. You can set up a couple of queries to merge all the tables 
into one in a few minutes, it's called database refactoring and in your 
case would improve the manageability of your data by10x.
[snip]
  Using multiple tables was described for comparison reasons, to show 
why it was not a good idea.

  Using multiple columns is the most space/time efficient - assuming 
players aren't only playing a few rounds.  It is, however, not the most 
*flexible*, as you're saying.  You need to modify the number of columns 
if things ever change, though you aren't limited to the number of players.

  Your database is fully normalized, but has the penalty of storing 
more data (minor), and is slightly more work on him if he wishes to 
display a summary, which I assumed was also part of his intention.

  Your way is the way I would do it for a full proper application, my 
suggestions were the way I would do it if it is something where the 
rules simply don't change (think sports/etc.) - I gave quick and simple 
suggestions for (what I saw as) a quick and simple app.

  I agree with your solution wholly, if his deadline isn't in 2 hours. 
 Unfortunately, all too often our deadlines are yesterday.

For this sort of table, you would create an index on each of the 3 
columns to imccrease the query speed massively. A nice side effect apart 
from speed, is that data stored in this way takes up no space if a (new) 
user hasn't completed any rounds (for example ;-)
[snip]
One should be indexing all their tables properly :P
All good valid points, well said.
Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Shopping Cart

2005-03-07 Thread Martin Norland
Wendell Frohwein wrote:
Hi martin, thanks for the email. I'm sorting it out slowly but surely. I
was just a little over worked the night I wrote that novel of an email.
I don't know if you saw my latest email titled Mysql Result. That's
the last step I am at. I used a select statement across multiple tables
to get all the values that I wanted. I forgot because I was so tired
that, once I had those values in there that I could sort by anything I
wanted to.
If you have a solution for my Mysql Result problem, that would help me
out alot. Most people are saying that I have to do a sub query, so I am
not really sure. Thanks though.
-Wendell Frohwein 
[snipped from another email]
 I wanted to know if it would be possible for it to output it like so:

 +--+---+-+--+
 | makename | modelname | versionname |years |
 +--+---+-+--+
 | Acura| Integra   | RS  | 92,93|
 | Acura| Integra   | GSR | 94,95,96,97,98,99,01 |
 +--+---+-+--+
[snip]
As penance for suggesting the quick way out in another posting, I've 
answered your question!

(I would've answered anyway - I'm a softie.  I got distracted this 
morning with the whole 'work' thing - sorry for the delay.)

I remembered doing this before - and sure enough:
GROUP_CONCAT: http://dev.mysql.com/doc/mysql/en/group-by-functions.html
The relevant bits:

GROUP_CONCAT([DISTINCT] expr [,expr ...]
 [ORDER BY {unsigned_integer | col_name | expr}
 [ASC | DESC] [,col_name ...]]
 [SEPARATOR str_val])
mysql SELECT student_name,
- GROUP_CONCAT(test_score)
- FROM student
- GROUP BY student_name;
Or:
mysql SELECT student_name,
- GROUP_CONCAT(DISTINCT test_score
-   ORDER BY test_score DESC SEPARATOR ' ')
- FROM student
- GROUP BY student_name;

The default separator is the comma.  Just toss in a 'GROUP_CONCAT(year) 
AS year' and appropriate 'GROUP BY' clause and have at it.

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

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


Re: [PHP-DB] mysql, php error

2005-03-07 Thread Martin Norland
James wrote:
I'm pretty new to this...I've set this book example up on my PC and it's 
fine.
I've attempted this on two Macs...

Here's the error I get when I try to run the application.  What does the 
error mean?

UNHANDLED ERROR on line 84 in 
/Library/WebServer/Documents/wda2-winestore/index.php.
[PHP Error 20050307145950]Error: Non-static method DB::connect() should 
not be called statically (error #2048).
[snip]
You're calling a classes method statically when it cannot be called as 
such - the function makes references to $this, or has otherwise been 
shown to be non-static.

You need to create an instance of the object, then call the method 
through it.

E.G. instead of:
DB::connect('some','variables');
you have to use:
$mydb = new DB;
$mydb-connect('some','variables');
Without the exact code, I can only give you examples of about how it 
should look - but that's the gist of it.

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

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


Re: [PHP-DB] Copying a set of database records

2005-03-04 Thread Martin Norland
Jesper Goos wrote:
Hi
It can't be done in a single SQL query as SQL can't make recursive 
requests.
You will have to use PL/SQL, and I don't think MySql supports that.
[snip]
bubble burst=true mysql_version_required=4.1
http://dev.mysql.com/doc/mysql/en/subqueries.html
/bubble
Steve McGill wrote:
I have a table with about 100 records all related to one product.
I want to create a new product, based on the details from the old 
product.

So in PHP, I would fetch the 100 records, alter the productID, and then
insert it 100 in 100 separate SQL queries.
Is there any way I can do this in one SQL query, somehow using a 
combination of insert and select?
[snip]
Optionally, you could do it in multiple queries using a temporary table. 
 Yes it's not a single mysql query, but it doesn't have to pop out and 
do any iteration in PHP, which does keep it cleaner and more organized.

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

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


Re: [PHP-DB] php5-sessions next

2005-03-03 Thread Martin Norland
mel list_php wrote:
Dear Martin,
Thank you very much for that, I made the suggested changes.
The problem was again coming from the session.save_path directive which 
was not well configured.

With your settings I know have a wonderful display of undefined index, 
coming from all that non instantiated variables...at least I know what I 
have to do now!!
[snip]
No problem, glad to help!
The extra errors is strange actually - that's E_STRICT error reporting. 
 E_ALL doesn't include E_STRICT, so it's further odd that the line:

error_reporting  =  E_ALL  ~E_NOTICE  ~E_STRICT
return strict errors - it should read return all errors, except notice, 
and except strict.  In any case, you can change it to

error_reporting  =  E_ALL  ~E_NOTICE
 In PHP 4 and PHP 5 the default value is E_ALL  ~E_NOTICE. This 
setting does not show E_NOTICE level errors. You may want to show them 
during development.

I don't develop with E_STRICT enabled - but then again, that's mainly 
because I could spend probably a month cleaning up uninitialized 
variables / array references and still not be close to finished.  I'd 
love to turn it on for a new project (though I might end up turning it 
right back off!), but it's just not feasible with my existing projects.

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

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


Re: [PHP-DB] php5-sessions next

2005-03-02 Thread Martin Norland
mel list_php wrote:
Hi again,
I erased and recreated my php.ini file from the php ini recommended.
In my application I use a suthentication of the user against a database 
table, once the user is allowed I  set a session variable at true.

I test this variable at the beginning of each script.
With php4 no problem, in each script I have:
@session_start();
if (!$_SESSION['allowed']) exit();
With php5, I'm unable to navigate through different protected pages, 
each time I have to re-login.

I don't know if it is something in my php.ini that is wrong, or if the 
session support has been modified between php4 and 5?
I tried to find information on the web but without success.

Comparing the section dedicated to session in phpinfo on my 4.3 and on 
4.5, the only difference is on 4.3 session.save_path=/tmp whereas for 
php5 even if specified in the php.ini it still has no value.

I'm a bit stuck here, anybody has an idea?
Whenever you run into errors - the first thing to do is start getting 
error messages back.  There are two ways to do this: 1) modify your 
php.ini to make sure it's reporting errors usefully, and check your logs 
 - 2) modify your code that is EXPRESSLY SUPPRESSING ERRORS to not do so.

1) in php.ini (E_STRICT might be php5 only, I don't recall exactly - 
shouldn't hurt if it's undefined and you  ~ it)

error_reporting  =  E_ALL  ~E_NOTICE  ~E_STRICT
2) in code
@session_start();
becomes
session_start();
... in addition, there is an option that many developers do not change 
in php.ini between development and live sites - and they should:

; Print out errors (as a part of the output).  For production web sites,
; you're strongly encouraged to turn this feature off, and use error logging
; instead (see below).  Keeping display_errors enabled on a production 
web site
; may reveal security information to end users, such as file paths on 
your Web
; server, your database schema or other information.
display_errors = Off


you'll want to couple this with some of the following:

; Log errors to specified file.
;error_log = filename
; Log errors to syslog (Event Log on NT, not valid in Windows 95).
error_log = syslog

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

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


Re: [PHP-DB] preg_match html tags

2005-03-02 Thread Martin Norland
[EMAIL PROTECTED] wrote:
I am trying to get a string of text in an html page using preg_match. The 
text starts after the Purpose/p tag and ends before the next /p tag.  
When using preg_match it captures the first /p tag on the page and not 
the one after my starting point. 

Here is my starting point:
preg_match(/Purpose\\/p\/i, $fpRead, $matches_new)
Here is my ending point:
preg_match(/(\/p)/s, $fpRead,$m_new);
I have also tried using offset
preg_match(/(\/p)/s, $fpRead,$m_new, $matches_new[0]);
Does anyone have any suggestions? I also don't know if my syntax is 
correct for the string /p...

Thanks
Any help will be appreciated. 

Kathy
Kathy A Wright | Keane Inc. | Suite: 
Outside: 617-517-1706 | E-mail: [EMAIL PROTECTED]
[ Mailing: 100 City Sq.  Charlestown, MA 02129 USA ]
You want to match the second expression starting after that Purpose/p. 
 Use:

preg_match(/(\/p)/s, $matches_new[0], $m_new);
.. check the documentation on php.net for that function, you don't pass 
it an offset - it takes an optional flag to return the offset along with 
the matches.  You may have been thinking of:

strpos($haystack, $needle, [$offset])
 - which is what I would recommend using for the first part (since you 
want the first occurrence), then using that with substr() to get the 
first occurrence of a closing /p to get the string you want.
[ warning - wholly untested code :) ]

$start = strpos($fpRead, Purpose/p);
$end = strpos($fpRead, /p, $start);
// make what we're doing clearer for the mailing list
// also helps in case offsets are a little strange.
$length = $end - $start;
$what_i_want = $substr($fpRead($start,$length));
cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Updating many records at a time

2005-03-01 Thread Martin Norland
Steve McGill wrote:
I have a situation where I am doing lots of complex sorting on records that
already exist in a MySQL table. The table has a 'sort_order' field which
means I can do a simple ORDER BY sort_order to keep it nice and quick on
SELECT, it's only UPDATE which is slow.
If I change the order that I want 1 rows to be displayed, I am currently
making 1 SQL queries such as:
UPDATE products SET sort_order=0 WHERE id='5';
UPDATE products SET sort_order=1 WHERE id='2';
UPDATE products SET sort_order=2 WHERE id='32';
and so on.
Obviously I'd love to be able to put all of this into one query.
Is there some way I can combine this with IN() ?
UPDATE products set sort_order= WHERE id IN('5','2','32');
Many thanks in advance for any help / advice.
What is the exact operation you're doing?  Is there any possibility you 
can do UPDATE products SET sort_order=sort_order+1 WHERE sort_order  
30 for e.g. - as in you insert an 'item' at spot 30 and want all the 
rest below it to be bumped up one.

You can certainly use IN(), but there is a (quite high) limit on how 
long the query string can be.  It's pretty ridiculously high actually, 
but something to consider.

Personally, I'd look at how you're doing things - see if there isn't an 
alternative way to do it like outlined above.  I'm assuming these aren't 
just some precalculated ordering, they're manually ordered for some 
reason?  If it's not 'we want to manually order them' - In a products 
database, I would think you could just have an ORDER BY product_group, 
product_name or some such.

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

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


Re: [PHP-DB] Pear help

2005-02-28 Thread Martin Norland
Craig Hoffman wrote:
Hi There,
I'm trying to configure my OS X box to work with PEAR.  Everything seems 
to be working (updating PEAR libraries, etc.) except when I run my test 
script I get the following error:

Fatal error: Cannot redeclare class db in /usr/lib/php/DB.php on line 271
Here is my test script:
?php
require 'DB.php';
if (class_exists('DB')){
print 'Ok';
} else {
print 'Nope';
}
?
I've included the path in my PHP.INI file and I still get this error.  
I've tested this script on another PEAR server and it works fine.
Does anyone have any ideas?  If this is wrong list, my apologies.  Any 
help would be greatly appreciated.
Comment out the 'require' line - and run your test script.  I expect 
you'll get the result Ok.  If so, you have something somewhere that's 
already including DB.php.

  Are you running this test script from within something, or do you 
actually include some 'common libraries' (your own custom, or some 
frameworks?).  You may also try changing it to require_once, in case 
something is already require'ing it.

The error is clearly stating that there's already a class DB defined. 
 It's defined somewhere.

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

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


Re: [PHP-DB] Pear help

2005-02-28 Thread Martin Norland
Craig Hoffman wrote:
Thanks for getting back to me... Comments below -
On Feb 28, 2005, at 10:49 AM, Martin Norland wrote:
Craig Hoffman wrote:
Hi There,
I'm trying to configure my OS X box to work with PEAR.  Everything 
seems to be working (updating PEAR libraries, etc.) except when I run 
my test script I get the following error:
Fatal error: Cannot redeclare class db in /usr/lib/php/DB.php on line 
271
[snip]
The error is clearly stating that there's already a class DB 
defined.  It's defined somewhere.
I'm not sure if this relevant, but I have used db.php (another file) in 
an include statements to connect mysql for a few websites.
Try printing the results of get_declared_classes() and go from there. 
Maybe class names are case sensitive, I've never had to find out.

in any case, as I said - it definitely has already seen a declaration of 
class db somewhere, the question is finding where that is and whether 
it's useful or not.

One last bit - is DB.php the class you're supposed to use in PEAR, or 
are you supposed to use something out of the DB directory within PEAR 
(or is that just the DB specific stuff which is handled by the parent)?

I've been working too abstracted a level lately, can't recall :)
Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] PHP form processing

2005-02-28 Thread Martin Norland
Ron Piggott wrote:
Is there a way to find out the IP address of the computer submitting a
form --- other than through a cookie.  Is there a header command or
something like this?  Ron
Response:
  rtfm / wrong list
Answer:
 for Apache, $_SERVER['REMOTE_ADDR'];
Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] password in md5 to connect to mysql instead of clear password

2005-02-25 Thread Martin Norland
Gael Lams wrote:
Hi all
I use the classic following rows to connect to a mysql
database. I always put $passsword in clear in the php
connection file and I wonder whether there is a way to
have it in md5 so that someone reading the file could
not use it to connect to the db. I googled a bit but
find only threads explaining how to have password
saved in md5 inside a mysql table which is not I would
like to do
[snip]
No.  Think about it - if your script is able to connect using this MD5 
hash of the password - anyone who could read that script could similarly 
just connect using the MD5.  Store your password in an included file 
outside of the webroot.

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

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


Re: [PHP-DB] MySQLPHP decrypt(password)

2005-02-25 Thread Martin Norland
moses Woldeselassie wrote:
hi all
I am using password() to crypt a user password online. but how do i 
decrypt a user password, when user forgot his/her password?

kind regards
m
You don't - that's the point.  You have to provide them with a way to 
reset their password, based on some other method of authentication. 
Traditionally this is done with mailing a user a password reset link, 
and having that link only available for a short period of time.

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

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


Re: [PHP-DB] most popular places

2005-02-25 Thread Martin Norland
Merlin wrote:
I am trying to do a tricky task with PHP and MySQl 4.0.x
There are 3 content tables where each of them contains a city_id
and there is a 4th table which holds the city_id and the acording city_name
Now I would like to find out the most used city names.
For example:
memberspictures reports
343
298
988
So the most used city_ids are
8
3
9
To find this out would be a chelenging task, but to merge them with the 
city name is even more difficult

I am working on this quite a while now and cant find a way. Maybe 
someone of you guys could give me a smart push.
[snip]
SELECT COUNT(m.city_id), other.city_name FROM members as m, other GROUP 
BY m.city_id WHERE m.city_id = other.city_id;

can't think off the top of my head any easy way to do that together with 
all the tables in one query, seems like it should be possible though. 
This should get you pointed in the right direction if you aren't already 
(note - sql is untested, and I always hose my GROUP BY's on the first 
try - but it should be close :) )

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

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


Re: [PHP-DB] password in md5 to connect to mysql instead of clear password

2005-02-25 Thread Martin Norland
[never made it to list, no idea why - been 26 hours - resending.]
[ may have been since it had reply-to field before to - funny...]
Gael Lams wrote:
Hi all
I use the classic following rows to connect to a mysql
database. I always put $passsword in clear in the php
connection file and I wonder whether there is a way to
have it in md5 so that someone reading the file could
not use it to connect to the db. I googled a bit but
find only threads explaining how to have password
saved in md5 inside a mysql table which is not I would
like to do
[snip]
No.  Think about it - if your script is able to connect using this MD5
hash of the password - anyone who could read that script could similarly
just connect using the MD5.  Store your password in an included file
outside of the webroot.
Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Notice: Undefined index: op

2005-02-22 Thread Martin Norland
J. Connolly wrote:
I get the error message:
*Notice*: Undefined index: op
When trying to set up a form. I have looked everywhere for the solution. 
I don't understnadn how to define that index. The come it comes from is:

if ($_POST['op'] != 'ds') {
   $display_block = 
   form action=\$_SERVER[PHP_SELF]\ method=\POST\
   Your E-mail Address:
   input type=text name=\email\ size=40 maxlength=150/
  input type=radio name=\action\ value=\sub\ checked/subscribebr/
  input type=radio name=\action\ value=\unsub\ /unsubscribe
   input type=\hidden\ name=\op\ value=\ds\/
   input type=submit name=\submit\ value=\Submit Form\/
   /form;
}
I am trying to create a form which allows my users to join a mailing 
list. I conceptually understand what the problem is but cannot find out 
how to solve the problem. I cannot find out how to define 'op'. Please 
do not tell me to lower my error reporting levels. I would rather fix 
the problems. Thank you,
Joseph
$_POST is likely empty, because the user requesting the page has likely 
not submitted the form (yet).  What you probably want (since you aren't 
going to lower the error reporting levels) is:

if ( isset($_POST['op'])  $_POST['op'] == 'ds' ) {
// do your operation here
} else {
// print your form/etc. here
}
You may want to use a different quoting style - I can't recall the name, 
but it's taken from perl

echo EOF
	form action=$_SERVER[PHP_SELF] method=POST
...
the rest of your stuff, then on its own line right at the beginning of 
the line (no tabs/etc. :( )
...
EOF;

it basically echo's until it sees that delimiter, that could be EOD or 
STOP or whatever (well, there might be reserved words issues - I could 
more easily check if I could remember the name of the quoting style...)

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

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


Re: [PHP-DB] Notice: Undefined index: op

2005-02-22 Thread Martin Norland
Bret Hughes wrote:
On Tue, 2005-02-22 at 10:49, Matt M. wrote:
On Tue, 22 Feb 2005 10:47:43 -0600, Matt M. [EMAIL PROTECTED] wrote:
[snip]
try:
if (isset($_POST['op'])  $_POST['op'] != 'ds')
sorry for 2 emails, looks like you would want
if (!isset($_POST['op']) || $_POST['op'] != 'ds')
I vote for the first one.
Bret
Your vote is misplaced - the first one isn't what he wanted... with that 
statement, his form will never be printed and it can never be set.

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

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


Re: [PHP-DB] Re: checkbox into mysql using php input type=checkbox name=list

2005-02-17 Thread Martin Norland
Bastien Koert wrote:
if its all going into one col, then implode the array into a string
$data = implode(,,$_POST['games']);
Then insert the data. Still doesn't relieve you of the need to validate 
the user data.

Bastien
[snip]
No no no - you're confusing the guy further.  He's taking an array post 
variable, foreaching it (resulting in a string in $value) and then using 
string indexes.
$value == 'football'
$value[0] == 'f'
etc.
[unsnip - more to come]
From: moses Woldeselassie [EMAIL PROTECTED]
I did try that, but the input is going into one column or it is take 
the last array value and put it each chart in the table.

input type=checkbox name=games[] value=football /
in that case, these are the value i got in mysql:  f, o, o, t
 foreach($_POST['games'] AS $game = $value)
  $valuecount = count($_POST['games']);
for($i =0; $i  $valuecount; $i++)
$sql = mysql_query(insert into interest 
values('$value[0]','$value[1]','$value[2]','$value[3]'));
[snip]
what he wants is (I think):
foreach($_POST['games'] AS $game_name) {
$sql = mysql_query(insert into interest values('$game_name'););
}
or something similar.  The idea is that they check 3 boxes for football, 
soccer, and hockey - and it inserts three rows into the database.  It 
seems like we want to be inserting more than just the game though - 
surely the user it's associated with / etc.

Moses - be sure to use curly brackets {} around blocks.  Your above code 
 only runs the $valuecount =  bit inside the foreach, which is why 
you were spared it running 'squared' times (e.g. 2 games = 4 times, 3 = 
9, 4 = 16).  The foreach and the for($i= code above are both there to 
accomplish the same thing, but $value stores the last seen value, so it 
would have looked as if you were still inside the foreach's scope. 
Stick with the foreach imo, since you don't need the counter.  (you can 
get it back by using your foreach, the counter is the $game = part - 
in my example I left it out since it's unnecessary.

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

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


Re: [PHP-DB] Intermittent odbc_connect() problem with iodbc/openlink

2005-02-17 Thread Martin Norland
Crone, James wrote:
I'm having intermittent problems with odbc_connect().  Here's the
situation
I'm trying to connect to a Sybase Adaptive Server Anywhere database
running on Win2K from my web server using Solaris, Apache, PHP, iODBC,
and OpenLink's ODBC universal data access driver for MSSQL/Sybase.
About 75% of the time, my php scripts talk to the Sybase system fine.
However, the other 25% of the time nothing really happens.  IE reports a
Page cannot be displayed error, while Firefox acts like it may do
something for a fraction of a second, but then just stays on the
currently loaded page.
 

I have tracing turned on in iODBC.  When things work fine, a lengthy
trace file is generated and everything seems to be in order.  When
things don't work, all I get is the following:
[snip]
No connect errors are generated either in the trace file or in the
browser's display.  It's almost as if the process just dies without
saying anything about why it happened.
[snip]
What do your servers error logs say?  This sounds suspiciously like the 
behavior one gets when php runs out of memory.  If so, it should have an 
Unable to allocate # bytes  type message in the error log.  Check 
that, and increase memory_limit in your php.ini if this is the case.

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

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


Re: [PHP-DB] Database visible via mysql CLI but not MOD_PHP with same username

2005-02-15 Thread Martin Norland
Elliot Mackenzie wrote:
I have encountered a hidden database issue with mod_php, apache2 and
mySQL that I have thus far been unable to resolve.  

I am able to connect to the mysql socket using mysql_connect, but then
find that mysql_list_dbs only returns the test database.  This
*sounded* like an issue with the SHOW DATABASES privilege until I found
I was able to log in to the same MySQL server *as the same user* with
the provided command-line client (mysql) and SHOW DATABASES would
display all the other databases on this system.
Furthermore, I tried connecting as root, and again found only the test
database was visible to PHP.  If I dropped the test database, no
databases were visible to PHP (regardless of how many databases were
visible using SHOW DATABASES).  If I created test, tester,
testing, hello etc, then the test database would reappear to PHP,
but no other databases were visible.
I also tried to connect PHP to MySQL as a super-user, and encountered
the exact same issue.
Steps to confirm question:
1) Connect using php, drop 'test' database.
2) Confirm php no longer sees 'test' database.
3) Connect using mysql client, confirm test database is missing.
4) -\
	4a) if so, check mysql database to confirm permissions for root include 
'%' databases and not just 'test'.

4b) if not, change php code to connect to correct mysql server.
Apologies that this may not be very useful, but your problem is 
extremely odd - if it's *not* a permissions / database error.

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

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


Re: [PHP-DB] Join on single table

2005-02-11 Thread Martin Norland
Matthew Weier O'Phinney wrote:
I have a table which contains the following:
id (primary key, auto incrementing)
app_id (integer, foreign key)
resource_id (integer, foreign key)
word
score
(This is a search index.) I want to find all resource_ids from one app_id
that match resource_ids in another app_id by word. 
Is this at or near what you're looking for?  I don't see any need for 
killing yourself making the temporary tables/etc. - but maybe I'm 
missing something. (obviously replace both 'tablename's with your tables 
name)

SELECT b.app_id, b.resource_id, b.word, b.score FROM tablename AS a, 
tablename AS b WHERE a.app_id != b.app_id AND a.word = b.word;

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

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


Re: [PHP-DB] Excel headers not working anymore

2005-02-11 Thread Martin Norland
Perry, Matthew (Fire Marshal's Office) wrote:
Good morning,
I have been using PHP4.1, Apache, and MySQL for a few years now and have
never had a problem with my Excel headers.  When I want to output html to
Excel I place the following on the top of the page:
?header (Content-type: application/vnd.ms-excel);
header (Content-Disposition: attachment );
After moving to PHP 4.3, MS SQL Server, Windows 2000 Server I am having
problems with this header.  I get the message:
Internet Explorer cannot download myfile.php from myintranet.net
1) is your server still configured to recognize ? as php (and only 
php)?  You may want to make that ?php to be more sure.  The headers 
likely aren't being sent if it's prompting to download .php - seems like 
it's not recognizing the extension, perhaps it's disabled for a certain 
pattern.
You could also try changing it to:

header(Content-disposition: attachment; filename=\$filename\);
to ensure that it's going off (set $filename obviously, something 
distinct like my_excel.xls)

2) Are you using ssl and sessions?  You'll find some fun and strange 
behavior trying to save output from an ssl connection and sessions - 
because sessions force no-cache, and (IE in particular) has real issues 
with storing the output of a no-cache'd https - you can't save it 
locally or open with an external application, because either way it has 
to store it somewhere other than memory, which would be caching.

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

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


Re: [PHP-DB] Store $_SESSION in MySQL table

2005-02-11 Thread Martin Norland
[EMAIL PROTECTED] wrote:
Greetings all.
While trying to create a session-based advertising model that does not rely on 
the existence of cookies, I ran into trouble: I can't figure out how to place 
the entire $_SESSION array into a MySQL table row, then retrieve it and use the 
information from one page to the next.
The best that I can do is copy the PHPSESSID into a MySQL row, then dissect the 
$_SESSION array so that each of its parts can be stored in a separate row of 
the same record. Then, with the $_GET variable, I am able to get the 
MySQL_last_id and retreive the information from the correct field, and it works 
across pages.
The only problem is this: should the $_SESSION array grow with more data--say, 
adding a first name variable, and a time-of-day varaible--then I need to update 
the MySQL table whenever I do this. Not a big deal, I know, but I'm frustrated 
with this.
One more thing: one of the variables in the $_SESSION array is an img src 
url, so it screws up the mysql insert, even when I use serialize.
Thanks for any help you can give.
--V
.oO Advertising? ack! - Should I help him or not? :P
serialize() and base64encode() are your friend.
You can even create a class to store this information, if you wanted - 
so long as you have the class include()'d before you unserialize the 
object.  In all likelihood, however, you'll prefer just the straight 
$_SESSION.

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

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


Re: [PHP-DB] Excel headers not working anymore

2005-02-11 Thread Martin Norland
Perry, Matthew (Fire Marshal's Office) wrote:
Wow!
Removing the file that controlled the session array fixed the problem
(suggestion 2).
I was using ssl and session data and would never have guessed it would trip
things up.  I would have stared at this problem for weeks and probably not
have solved the problem.
Also I will change my code to include ?php instead of ? from now on just
to be sure.
Thank you very much for your help.
- Matthew Perry
The following is what I use - it allows caching but forces it not to be 
cached (it's a report, so it's changing every time).  It's a little 
redundant, because these items are a little bit of a pain to follow.  I 
have these running before the session is set - you may only need the 
session_cache_limiter call, come to think, since I'm setting these 
before the session starts and the others likely get overwritten.

?php
header('Cache-Control: private, must-revalidate');
header('Pragma: private'); // allow private caching
header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT); // set to 
be modified 'now'
session_cache_limiter(private, must-revalidate); // allow private 
caching, but cache MUST check output
// rest of script
?

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

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


Re: [PHP-DB] Reg Exp to change c:\dir\dir\pic.jpg to dir/pic.jpg - to upload image path

2005-02-10 Thread Martin Norland
ioannes wrote:
I am trying to upload images - in fact an image path - from a PC.
I use the input  tag:
INPUT NAME=addpic TYPE=file
which nicely gives an input textfield and Browse button!  This gives me, in the input box, eg:
c:\pics\subdir\pic1.jpg
The relative path on the server is something like: 
subdir/pics1.jpg
thus I need to transform the string:
c:\subdir\pics\pics1.jpg
into: 
pics/pics1.jpg

I can use str_replace() to change \ into /.  I am looking for an expression from some clever person to get rid of c:\subdir\ given that I don't know the exact 'subdir' or name of the image.
Maybe it's just early, and I haven't had my caffeine yet - but it seems 
to me something fairly basic is being overlooked...

a web browser doesn't even give you this information!
if you really need it, for whatever reason, you're going to have to pull 
the information out of the file input through javascript.  IIRC you can 
read from a file input, but I know for a fact you can't change it (at 
least, not without perhaps an exploit or some horrible activex 
why_would_this_ever_be_enabled_microsoft_you_fools() function calls.)

You're better off providing keywords, categories, folders or labels to 
go along with the images for your users, instead of trying to match 
their organization with yours.

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

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


Re: [PHP-DB] Reg Exp to change c:\dir\dir\pic.jpg to dir/pic.jpg-to upload image path

2005-02-10 Thread Martin Norland
ioannes wrote:
OK.  Makes sense, since I needed to change the form tag to upload files. 
Clearly, then it was not uploading the path.

Thanks
If by local, in your example, you mean it gives you pic1.jpg - then 
I will agree.  No browser I've ever seen sends 
C:\pics\subdir\pic1.jpg. It will *display* that to the user, but it 
doesn't submit the local path, it just uploads the file and gives the 
filename.

No problem.
In the future, unless you have a specific reason to take a mailing 
off-list, please leave it so others can reply to it or find the answers 
/ solutions / clarification when searching archives and the likes.  It's 
just polite :)
(this is part of why I try to always set the reply-to to the list)

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

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


Re: [PHP-DB] javascript and php

2005-02-08 Thread Martin Norland
Perry, Matthew (Fire Marshal's Office) wrote:
Hello all,
I am having difficulties working with a JavaScript menu that should load on
each page of my intranet site.
[snip]
hint - you're already on the wrong list.  Read on.
Here is a brief background of the problem:
[snip]
4)   I am using a JavaScript application for my navigation menu.  I
chose this because I need collapsing menus.  There are lots of functions
under each category; if I were to use HTML for the menu, my users would have
to scroll way down to get to where they want to go - especially the ones
still using 800X600 monitor resolution.  A php function calls the JavaScript
menu and changes what is displayed based on the session array data.  

Here is the problem:
 My JavaScript menu DOES NOT always display.  It displays about 95% of the
time.  When it displays, it displays correctly (based on the session data).
When it doesn't display, I hit reload and it usually reappears.  What's
worse, it seems to happen randomly!  I could click the same link 10 times
and it will work perfectly.  The 11th time it might not show up.
Here is the small amount of information I know about the problem:
I have read through the list server achieves and think the problem may lie
with the fact that Javascript has to run at the Web Browser end and PHP has
to run at Server Side.  This probably explains how it is possible that the
two are not in sync but it does not explain WHY this happens about 5% of the
time.  It also does not explain why it happens only to the JavaScript while
always displaying the results of my php functions.
[snip]
Your problem is that your javascript menu functions don't use an onload 
handler.  What you need to realize is that the DOM may not have finished 
loading all the objects in the page, even though the object may have 
been printed out to the browser.

so the (pseudo code) equivalent of:
---
input type=submit id=op name=op value=Operation /
script language=JavaScript
operation_button = my_find_item_func('op');
/script
---
may be holding null for 'operation_button' because op hasn't been added 
to the DOM yet.  You have to wait until the page fully loads, then call 
a function to find that 'op' button.

The reason it works most of the time, is probably because it's not being 
triggered until you mouseover the menu.  Try loading the page with your 
mouse nowhere near where the menus should go, and the problem may 
'disappear' (note: obviously not a solution).  There's no guarantee, but 
that's a distinct possibility.

Search for body.onload or window.onload functions.
Also, whatever dropdown code you're using - if they don't describe doing 
this, you probably can find better.  Any sane packaged dropdown code 
should be explicit about requiring the user to use onload to instantiate 
things.

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

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


Re: [PHP-DB] mysqli connection problem

2005-02-08 Thread Martin Norland
My intention of setting the reply-to was not to offend, or claim you 
were wrong - merely to move the discussion to the list I felt (and still 
feel - as I've done it again) is most appropriate for the question.

anyway, back to the task at hand
( first: I'm assuming you restarted apache after changing your php.ini - 
otherwise, that's your problem. )

Whatever the case, the error message clearly shows that it is not 
reading the value, however it's set - because the error is still showing 
a blank string for the socket.  If it were a permissions problem with 
the socket, you wouldn't be getting that exact error - at the very 
least, it would still show the correct socket path.  More likely, it 
would also error with a cannot open socket or equivalent.

You may wish to examine ini_get(), ini_get_all(), phpinfo(), or 
php_ini_scanned_files(), to verify if it is set, or to see if it's being 
overwritten somewhere.

Cheers,
Denis Gerasimov wrote:
Didn't help me. MySQL socket does exist - /var/lib/mysql/mysql.sock (default
location).
mysqli.default_socket is NOT set to null but to this value (manually, as you
advised)
Again,
1. Connection to localhost still fails with message Can't connect to local
MySQL server through socket '' (111)
2. Connection to server's domain name fails too (!) with message Access
denied for user 'user'@'example.com' (using password: YES)
3. Connection to localhost through mysql shows the following config
mysql status
--
mysql  Ver 14.7 Distrib 4.1.9, for pc-linux-gnu (i686)
Connection id:  42
Current database:
Current user:   [EMAIL PROTECTED]
SSL:Not in use
Current pager:  stdout
Using outfile:  ''
Using delimiter:;
Server version: 4.1.9-standard
Protocol version:   10
Connection: Localhost via UNIX socket
Server characterset:latin1
Db characterset:latin1
Client characterset:latin1
Conn.  characterset:latin1
UNIX socket:/var/lib/mysql/mysql.sock
Uptime: 1 day 3 hours 1 min 7 sec
Threads: 3  Questions: 272  Slow queries: 0  Opens: 64  Flush tables: 1
Open tables: 26  Queries per second avg: 0.003
--
Seems to be a security issue... Any more ideas about these symptoms?

-
I can't see any reason why you wouldn't be able to use the same socket -
you're connecting to the same exact server, it's just a path.  You
should be perfectly able to set your mysqli.default_socket to the same
as the mysql.default_socket.  I can't tell you what the default for your
system is, but there are php functions to get configuration options, if
you don't have it in any obvious places.
Cheers,
--
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]


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

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


Re: [PHP-DB] mysqli connection problem

2005-02-07 Thread Martin Norland
Denis Gerasimov wrote:
Hello,
This question was asked many times, but I can't find a good answer.
I am getting this error message while trying to connect to MySQL server (PHP
+ PEAR::DB_DataObject):
Can't connect to local MySQL server through socket '' (111)
(notice '' - is that right?)
Does anyone have any ideas about how to get rid of this error?
Configuration:
* RedHat Enterprise Linux AS3
* Apache 2.0.46
* PHP 5.0.2
* MySQL 4.1.9, mysqli ext.
Thanks!
[Note: reply-to set to php-db as it's multimailed and I don't see this 
as a mysql general issue, nor php general, but feh.]

Looks to be set blank/null/etc.
You may be slightly tricked by the existence of both of these - from 
your standard php.ini...
-
; Default socket name for local MySQL connects.  If empty, uses the built-in
mysql.default_socket =

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysqli.default_socket =
-
I can't see any reason why you wouldn't be able to use the same socket - 
you're connecting to the same exact server, it's just a path.  You 
should be perfectly able to set your mysqli.default_socket to the same 
as the mysql.default_socket.  I can't tell you what the default for your 
system is, but there are php functions to get configuration options, if 
you don't have it in any obvious places.

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

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


Re: [PHP-DB] PHP5 classes mysql bug ?

2005-02-03 Thread Martin Norland
Viacheslav Kaloshin wrote:
Here is testcase
PHP 5.0.3 (cli) (built: Dec 17 2004 10:47:41)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies
?php
class MySQL {
	private $mysql_link=0;
	private $mysql_result=0;
	
	function __construct()	{
		$host=localhost;
		$basename=test;
		$username=test;
		$userpassword=;
		
		$link=mysql_pconnect($host,$username,$userpassword);
		if($link)
			{ mysql_select_db($link); 
$this-$mysql_link=$link;
echo At constructor: ;
echo $this-$mysql_link;
echo \n;
return 0;
			}
			else
			{
return 1;
			}
	}
	function __destruct() {
		echo At destructor ;
		echo $this-$mysql_link;
		echo \n;
			if($this-$mysql_link) { mysql_close($this-$mysql_link); }
	}
	
	function query($query_string) {
		
		echo before query: ;
		echo $this-$mysql_link;
		echo \n;
		$this-$mysql_result=mysql_query($query_string);
		// can change to this
		#$this-$mysql_result=mysql_query($query_string, $this-$mysql_link);
		echo after query: ;
		echo $this-$mysql_link;
		echo \n;
		if($this-$mysql_result)
			{ return 0; }
			else
			{ return 1; }
	}
	function result() {
		return mysql_num_rows($this-$mysql_result);
	}
	function fetch() {
		return mysql_fetch_array($this-$mysql_result, MYSQL_NUM);
	}
	function clear() {
		return mysql_free_result($this-$mysql_result);
	}
	
}

$m= new MySQL();
$m-query(select 1+2);
$res=$m-result(); 
$res=$m-fetch();
$m-clear();
$m-query(select 2+3);
$res=$m-result();
$res=$m-fetch();
$m-clear();

?
this script output should shwo the same id. but in my case i see next lines:
At constructor: Resource id #4
before query: Resource id #4
after query: Resource id #5
before query: Resource id #5
after query: Resource id #6
At destructor Resource id #6
What i am not understand?
You just posted a mail saying problem solved, RTFM - but I just spent a 
few minutes tracking it down before realizing it was staring me in the 
face - and I didn't want others to miss out on the fun.

Basically, it boils down to the fact that you were accessing the same 
objects properties throughout all your accesses within the class. 
Namely, $this-who_fricking_knows. (technically $this-null I suppose... 
interesting question, don't feel like creating a dummy class just to 
find out though).

$this-$mysql_link should have been $this-mysql_link
$this-$mysql_result should have been $this-mysql_result
etc.
dynamic variables are very handy however.  You'll find yourself using 
them a lot if you have lots of similar tables/etc. that you need to 
write the same 'thing' for over and over again.

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

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


Re: [PHP-DB] database connectivity problem

2005-02-02 Thread Martin Norland
Adams, Jonathan K. [C] wrote:
Thanks Martin...
You were right... I had to make Apache run as sybase (gasp!)
for it to work
really funky but it works...
Probably better to figure out where the permissions are needed (no doubt 
somewhere in the filesystem) and see about adding one or the other to 
the group.  suExec might also be of some worth.

I'm sure there are solutions other than running apache as user sybase.
Still - glad it's working for you at least!
Cheers,
--
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] insert (database)

2005-02-02 Thread Martin Norland
Jochem Maas wrote:
Yemi Obembe wrote:
the objective of the script below is to first search if a subscriber 
is already in a list before subscribing his email (so as to prevent 
double subscription). the select part works finebut the insert 
doesnt. know why?
 
if ($v = strtolower($_POST['email'])) {

what happens when $_POST['email'] is equal to
'script
document.location = http://www.evilkid.net/?stolencookie+document.cookie;
/script';
or something like that? Just something to think about.
Then the malicious user gets to send their own cookies for this site to 
another site of their choosing :P.  I would be more worried about it 
being equal to things like:

Spam my Enemy [EMAIL PROTECTED]
+ Spam my Enemy also [EMAIL PROTECTED]
+ etc.
  or
\r\nFrom: Idiots Inc. [EMAIL PROTECTED]
  or
'; Delete from arbitrary_table_name where 'yes'='yes
All of which are easily prevented with some attention to detail.  (or in 
some cases newer versions of software, which explicitly allow only one 
statement per call).  Finally - the concept of bind variables (or 
equivalent) are your friend (as Jochem already knows with firebird iirc).

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

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


Re: [PHP-DB] Programmer required

2005-02-02 Thread Martin Norland
Miles Thompson wrote:
This is waaay off topic, but:
I hope you mean retired, who will presumably work for less.
Why would you want one who's not current?
Just wondering - Miles
At 09:47 AM 2/2/2005, ioannes wrote:
I'm looking for a programmer, preferably in London or UK, who has been 
maybe out of work for a few years, to discuss an easy project with.  
Pass the request on to your friends.

John
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
I believe the intention of asking for someone who's been out of work for 
a few years, was to find someone desperate - perhaps they've proposed 
this project multiple times and nobody wants to touch it :)

I didn't know you could say off topic on this list... guess you just 
can't say its abbreviated form in the subject or - ah heck, who knows.

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

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


Re: [PHP-DB] mysql 4.1-4.0

2005-02-02 Thread Martin Norland
blackwater dev wrote:
Why is this query handled differently in 4.1?
4.0
select lower(concat(last_name,id)) from client where prim_id=1
returns johnson1
4.1
same query returns Johnson1
Why don't the lower work in 4.1 when you concatonate with a number?
No idea.
select concat(lower(last_name),id) from client where prim_id=1;
Cheers,
--
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] database connectivity problem

2005-02-01 Thread Martin Norland
Adams, Jonathan K. [C] wrote:
Here is the error: Warning: sybase_connect() [function.sybase-connect]:
Sybase: Unable to allocate connection record
My configuration - The database is Sybase ASE 12.0 running on Solaris 8
The webserver is Apache 1.3.33 with PHP 5 running Solaris 9
The sybase libraries are shared via NFS, which is how I built the apache
Well, that error certainly doesn't look like it can't see the libraries 
- it looks more like it can't write somewhere.  Are you sure there is 
sufficient memory for the script [perhaps increase memory_limit in 
php.ini], and that wherever php might need to store the connection 
record externally (if applicable) is writable?

Unfortunately - you may not be alone:
http://bugs.php.net/bug.php?id=30721
http://bugs.php.net/bug.php?id=17489
Cheers,
--
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Re: Warning: ocilogon(): _oci_open_server: â in d:\program files\apachegroup\apache\htdocs\codebase\oci8test2.php on line 3

2005-02-01 Thread Martin Norland
JeRRy wrote:
snip
I am getting the error below while trying to execute
the code below:
Warning: ocilogon(): _oci_open_server: â in
d:\program files\apache
group\apache\htdocs\codebase\oci8test2.php on line 3
/snip
Aha line 3.  Open oci8test2.php in notepad or
something and browse to line three.  Hit your down
arrow twice. ;)
snip
?php
$c=OCILogon(scott,tiger);
/*
if ($c=OCILogon(scott, tiger, orcl)) {
  echo Successfully connected to Oracle.\n;
  OCILogoff($c);
} else {
  $err = OCIError();
  echo Oracle Connect Error  . $err[text];
}
*/
?
/snip
Okay lets read the error:
Warning: ocilogon(): _oci_open_server: â in
d:\program files\apache
group\apache\htdocs\codebase\oci8test2.php on line 3
so ocilogon is producing some sort of error, it kindly
gives us the line number to make it easier to find. :)
 Sometimes helpful but not always if you have alot of
includes in it. ;)
So I'd say it's this part the error is:
if ($c=OCILogon(scott, tiger, orcl)) {
I didn't take this one up initially because it's all carbs - no 
nutritional value.

The entirety of his example is commented except for the single line 
(line 3) calling OCILogon.  Since the error isn't that the function is 
undefined, and it (to my eyes) describes nothing - I stayed quiet.

The line you're suggesting he check (line 6) is in fact commented out. 
It does bring to light, however, the suggestion that he check whether he 
should be passing more arguments to the function.

You make a good point - that is that the example code is there to make 
sure things are working, and then to start changing it - get a good 
baseline, and work from there.  Sound advice - would that more heeded it.

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

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


Re: [PHP-DB] Re: [PHP] Re: [PHP-DB] Developer needed in London

2005-01-28 Thread Martin Norland
Jochem Maas wrote:
Jochem Maas wrote:
Underodog H.R. wrote:
Sorry for using the list in this way, wont happen again.

I just noticed that they crossposted rather than post twice.
That's three times now I've seen the statement that it won't happen again!
Unforgivable!
Seriously though - their name is set to Underodog - that *is* pretty 
damned bad.  Unless they're manually tweaking the From: field everytime 
they send mail from jobs@ - in which case, woops.

( I don't subscribe to general because I like getting *some* work done @ 
work - otherwise I'd just be 'at the ready' for support all day long - 
afaik it's fairly high traffic, yes?)
Cheers,
--
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Hyphens and MySQL

2005-01-28 Thread Martin Norland
Mark Benson wrote:
I am having problems with entering data into MySQL from a PHP script. I am 
taking the data from an array generated by a CSV parsing routine. That in 
itself works great, however I have large number of data units with '-' 
characters in (hyphens) and it is causing the SQL queries to dump out with an 
error in the syntax. I can't get around it by putting a slash in front of them 
(using 'addcslashes'), it will just not at all accept them.
Are they the 'wrong' type of slash? Is there an easy way to search and 
replace/remove characters in a string in PHP?
If you're quoting these values, you should be having no problem.
e.g. INSERT into TABLE_FOO (colname) values ('-');
but this will error: INSERT into TABLE_FOO (colname) values (-);
Cheers,
--
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] odd results when running this

2005-01-28 Thread Martin Norland
Chip Wiegand wrote:
Okay, so I have got the php bits working in this web page but it is 
running 3 times every time the page loads, and I see no reason why (I have 
opened this page in two differant browsers). The code for the entire page 
is pasted below, it includes some calls to include files which are not 
included in this message of course (and this file is itself included in 
another file), the page can be seen at this address: 
http://www.simradusa.com/index-test.php
If anyone can see any reason for the script to run 3 times please let me 
know.
Thanks,
Chip
[snip]
?
$sql=select * from hotspots;
$result = mysql_query($sql);
while ( $row = mysql_fetch_array($result)) 
   { 
 printf(pimg src=\hotspots/latest1.gif\ alt=\%s\ 
title=\%s\/pp class=\footnote\%s/p, $row[alt-text], 
$row[title-text], $row[desc-text]);
   printf(pimg src=\hotspots/latest2.gif\ alt=\%s\ 
title=\%s\/pp class=\footnote\%s/p, $row[alt-text], 
$row[title-text], $row[desc-text]); 
   printf(pimg src=\hotspots/latest3.gif\ alt=\%s\ 
title=\%s\/pp class=\footnote\%s/p, $row[alt-text], 
$row[title-text], $row[desc-text]);
 } 
?
Looking at the page, and the code block - the code likely isn't running 
three times.  You have 3 rows in the database, and in your while() loop, 
you print out the data for each row 3 times.  You'll notice on the 
sidebar in the webpage you have essentially 9 'blocks' of news - they 
images for them loop (a b c, a b c, a b c) and the text for them repeats 
( d d d , e e e , f f f ).

Change your loop to print just once, and have a counter that sets the 
image to load (and if the counter goes beyond 3 - either have it not 
display the image, or add more images :), or limit the query to only 
return the latest three (add limit 0, 3 to the query) )

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

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


[PHP-DB] Notice for those running MySQL on Windows

2005-01-27 Thread Martin Norland
http://it.slashdot.org/article.pl?sid=05/01/27/1546222
Summary: if your mysql is actually listening on the network (not just 
localhost) you might get wormed - brief perusal says it has to do with 
weak root passwords.

It's basically a spyware worm or some such - but certainly not something 
anyone would *want* on their box.

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

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


  1   2   >