[PHP] sort in while(list($vars) = mysql_fetch_row($result))

2008-02-27 Thread Verdon Vaillancourt

Hi,

I'm running into some sorting issues using a while(list($vars) =  
mysql_fetch_row($result)). I can provide more code if needed, but  
thought I would try this little bit first to see if I'm missing a  
fundamental concept and not a detail.


In a nutshell, I have a query first..
$result = mysql_query(select id, text, url, m_order from menu where  
level = 2  active = 1 order by m_order);


.. the result of this query is sorted correctly by m_order


Then I pass it through this..
while(list($id, $text, $url, $m_order) = mysql_fetch_row($result)) {
  $out .= $text - $m_order \n;
}
echo $out;

.. it is now no longer in the order it was in the query. In some  
results it is, in others it's not.



Am I missing something basic?

Thanks,
verdon

Ps. Please cc me if replying as I am on digest  mode

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



Re: [PHP] sort in while(list($vars) = mysql_fetch_row($result))

2008-02-27 Thread Verdon Vaillancourt


On 27-Feb-08, at 9:23 AM, Daniel Brown wrote:

On Wed, Feb 27, 2008 at 7:58 AM, Verdon Vaillancourt  
[EMAIL PROTECTED] wrote:

[snip!]

 Then I pass it through this..
 while(list($id, $text, $url, $m_order) = mysql_fetch_row($result)) {
   $out .= $text - $m_order \n;
 }
 echo $out;


Is there a reason you're not simplifying this to the following?

?
while($row = mysql_fetch_array($result)) {
$out .= $row['text']. - .$row['m_order'].\n;
}


Hi Dan,

Thanks for the input. The only reason is that I'm inheriting this  
from someone else and am asked to do a 'quick' fix to get it working  
again. The whole script is a little kludgy and it may be better to  
redo it. Is there anything fundamentally wrong with the while(list())  
approach, or is it just messy?


Best rgds,
vern

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



[PHP] Truncate words in multiple paragraphs

2006-02-03 Thread Verdon Vaillancourt

Hi :)

I am using the following function (that I found in the user comments on 
php.net manual) for trimming the number of words accepted via a form 
field


// Truncation is by word limit, not character limit. So if you limit
// to 255, then it will cut off a text item to 255 words, not 255 
characters

function trim_text ($string, $truncation=250) {
$string = preg_split(/\s+/,$string,($truncation+1));
unset($string[(sizeof($string)-1)]);
return implode(' ',$string);
}

This works well, except it is also removing any line breaks. For 
instance...


inputting


Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper 
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem 
vel eum iriure dolor in hendrerit in vulputate velit esse molestie 
consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et 
accumsan et iusto odio dignissim qui blandit praesent luptatum zzril 
delenit augue duis dolore te feugait nulla facilisi.


Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam 
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat 
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation 
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.



returns


Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper 
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem 
vel eum iriure dolor in hendrerit in vulputate velit esse molestie 
consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et 
accumsan et iusto odio dignissim qui blandit praesent luptatum zzril 
delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor 
sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod 
tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim 
ad minim veniam, quis nostrud exerci tation ullamcorper suscipit 
lobortis nisl ut aliquip ex ea commodo consequat.


I'd like to (need to) retain the line breaks. Any suggestions?

Thanks,
verdon

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



Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread Verdon Vaillancourt

On 3-Feb-06, at 12:25 PM, John Meyer wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Verdon Vaillancourt wrote:

Hi :)

I am using the following function (that I found in the user comments 
on
php.net manual) for trimming the number of words accepted via a form 
field


// Truncation is by word limit, not character limit. So if you limit
// to 255, then it will cut off a text item to 255 words, not 255
characters
function trim_text ($string, $truncation=250) {
$string = preg_split(/\s+/,$string,($truncation+1));
unset($string[(sizeof($string)-1)]);
return implode(' ',$string);
}



How about
$string = nl2br($string);
$string = trim_text($string);
$string = str_replace(br /,\n,$string);
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD45Hzj60GAoLuoDkRAjSqAKCxvGlJmSCVHozWBDjjZnKMEZOfSwCfenVj
lRSChtsMRqRnOYdZpk5YQ0c=
=Dnly
-END PGP SIGNATURE-



That's clever :)

Thanks,
verdon

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



Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread Verdon Vaillancourt

Hi Richard,

I quickly realized this and fooled with a few variations. Also have to 
take into account that the br or the br / get counted as 1 or 2 
words respectively, and so the trim can end up in the wrong place. I've 
tried fiddling with counting the number of br's in the string and 
adding that to the truncation limit before the preg_split, but this is 
still not ideal.


I'm going to have a look at your other suggestion too.

Thanks for your thoughts :)
verdon

On 3-Feb-06, at 4:21 PM, Richard Lynch wrote:




This would work if you replace the br / with br -- Otherwise, it's
too likely to break up br / in the trim_text function and then you
end up with:

start of string ... almost 255 words, blah blah blahbr

On Fri, February 3, 2006 11:25 am, John Meyer wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Verdon Vaillancourt wrote:

Hi :)

I am using the following function (that I found in the user comments
on
php.net manual) for trimming the number of words accepted via a form
field

// Truncation is by word limit, not character limit. So if you limit
// to 255, then it will cut off a text item to 255 words, not 255
characters
function trim_text ($string, $truncation=250) {
$string = preg_split(/\s+/,$string,($truncation+1));
unset($string[(sizeof($string)-1)]);
return implode(' ',$string);
}



How about
$string = nl2br($string);
$string = trim_text($string);
$string = str_replace(br /,\n,$string);
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD45Hzj60GAoLuoDkRAjSqAKCxvGlJmSCVHozWBDjjZnKMEZOfSwCfenVj
lRSChtsMRqRnOYdZpk5YQ0c=
=Dnly
-END PGP SIGNATURE-

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





--
Like Music?
http://l-i-e.com/artists.htm






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



Re: [PHP] Truncate words in multiple paragraphs

2006-02-03 Thread Verdon Vaillancourt


On 3-Feb-06, at 4:19 PM, Richard Lynch wrote:


On Fri, February 3, 2006 10:54 am, Verdon Vaillancourt wrote:

I am using the following function (that I found in the user comments
on
php.net manual) for trimming the number of words accepted via a form
field

// Truncation is by word limit, not character limit. So if you limit
// to 255, then it will cut off a text item to 255 words, not 255
characters
function trim_text ($string, $truncation=250) {
$string = preg_split(/\s+/,$string,($truncation+1));


This splits it apart on any whitespace.


unset($string[(sizeof($string)-1)]);
return implode(' ',$string);


This re-assembles it with spaces as the only whitespace.


}


There's probably some way to do it with built-in functions, but here's
a solution:

function trim_text($string, $truncation = 250){
  //search for words/whitespace
  for($w=false,$l=strlen($string),$c=0,$t=0; $t$truncation 
$c$l;$c++){
$char = $string[$c];
//detect change of state from 'word' to 'whitespace':
if (!$w  strstr( \t\r\n, $char)){
  $w = true;
}
elseif($w  !strstr( \t\r\n, $char)){
  $w = false;
  $t++;
}
  }
  return substr($string, 0, $c);
}

This is NOT going to be fast on large pieces of text, because PHP loop
is relatively slow -- So if somebody posts a working function using
built-in PHP functions, it will probably be faster.

This mostly works too, and in my circumstances, I'm not using it on any 
large blocks. I also like that it takes tabs into account.


One thing, if I feed it a string of say 300 words in multiple 
paragraphs, it returns a string of 251 words... 250 intact words and 
the first letter of the 251st word (at least in the tests I've done so 
far)


regards,
verdon




--
Like Music?
http://l-i-e.com/artists.htm






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



[PHP] Looking for commercial coder

2005-02-22 Thread Verdon Vaillancourt
Hi :)
I am looking for a competent coder to help me with a shipping module 
for an e-commerce project I am working on. Essentially I need a script 
that can check a Canadian postal code and/or US zip code (from the 
cart) against a flat-file or db table, find it's zone in a series of 
ranges of codes, grab the correct value for the weight of the products 
in the cart, and pass it back to the cart. The cart I am working with 
is Zen-Cart. I am not looking for a freebie.

For example, my postal code might be: P1B 7E9
The zone chart uses the 1st 3 chars, and looks something like:
Range   Zone
A0A-A0N 11
G6E-G6K 5
J5Y-J6A 4
R5A-R6W 8
T9E 6
A1A-A1S 11
G6L-G6T 5
J6E 4
R7A-R7C 7
T9G 9
A1V-A2N 11
Then there's a weight/price ratio for each zone.
If I really have to, I'll tackle this myself, but I'd rather contract 
it out and invest my own time elsewhere. If you have the skills to do 
this, and are interested and available, please contact me off-list.

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


Re: [PHP] $_SERVER['REQUEST_URI'] being trimmed

2005-02-05 Thread Verdon Vaillancourt
On 3-Feb-05, at 3:46 PM, Richard Lynch wrote:
Your very problem is that you are NOT encoding the URL data, so the
browser is trying to do it for you, only it can't be sure whether  is
supposed to be data or is supposed to separate your URL arguments.
http://php.net/urlencode
Thanks for the tip re urlencode(). I had tried that before I posted, 
but I was doing it at the wrong side of the process. I was using it in 
my switch file on the referrer being returned to location: instead of 
on the link I was passing to my switch file. When I changed my link 
to...

a href=/switch.php?userLangChoice=framp;sender=?php echo 
urlencode($_SERVER['REQUEST_URI']); ?French/a

...the problem was fixed. DOH!

You may also want to just include the switch.php whenever 
userLangChoice
is set in the URL:

--- langchoic.inc -
?php
  if (isset($_GET['userLangChoice'])){
setCookie($_GET['userLangChoice']);
  }
?
You can simply: ?php include 'langchoice.inc'? on every page or in a
globals file you already include, and then you're not wasting a bunch 
of
HTTP connections bouncing around with the header or worrying about your
URL getting munged.

?php
  include 'langchoice.inc';
  echo a href=\$_SERVER[PHP_SELF]?userLangChoice=fr\French/a;
  echo a href=\$_SERVER[PHP_SELF]?userLangChoice=en\English/a;
?
I tried a few quick tests with this method and variations of it. I 
could get it to set a cookie like '[en] = ' or '[fr] = ' but I could 
not get it to set a cookie like '[userLang] = en'. Even if I worked 
that out though, there is a disadvantage to this approach, in that 
(AFAIK) the page has to be refreshed before the server will be aware of 
the new cookie value on the client, not desirable in this situation 
where I'm offering bilingual content.

My thoughts in using the switch.php file was to set the cookie, make 
the server aware of it so it can deliver appropriate content, and 
return to the URL intact at the end of the process, without any new 
vars in it.

With your reminder about urlencode, this is all playing nicely now.
Thanks,
verdon

Verdon Vaillancourt wrote:
I am trying to build a simple mechanism to allow visitors to set a 
site
preference (stored in a cookie) by clicking on a link. I want the
cookie set and the original page reloaded with the new cookie set, 
when
a visitor clicks on the link.

My link looks like this...
a href=/switch.php?userLangChoice=framp;sender=?php echo
$_SERVER['REQUEST_URI']; ?French/a
My file switch.php looks like this...
?php
setcookie(userLang, $userLangChoice);
 if ($sender == )
$sender = index.php;
 else
$sender = $sender;
  header(location:.$sender);
?
Now, for the most part this works fine, but in some cases, my 
referring
URL ($sender) is being truncated. Simple URLs such as
'/listingsearch.php?Category%5B%5D=Hunting' work fine, although it is
being returned as '/listingsearch.php?Category[]=Hunting'. More 
complex
URLs like
'/listingsearch.php?
Accommodation%5B%5D=OutpostCategory%5B%5D=FishingRegion%5B%5D=North-
West' are being truncated at the first variable down to
'/listingsearch.php?Accommodation[]=Outpost'

Is there something I can do to make sure the referring URL is not
truncated and it would also be nice if it was left alone and not
encoded or decoded.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] $_SERVER['REQUEST_URI'] being trimmed

2005-02-03 Thread Verdon Vaillancourt
Hi :)
I am trying to build a simple mechanism to allow visitors to set a site  
preference (stored in a cookie) by clicking on a link. I want the  
cookie set and the original page reloaded with the new cookie set, when  
a visitor clicks on the link.

My link looks like this...
a href=/switch.php?userLangChoice=framp;sender=?php echo  
$_SERVER['REQUEST_URI']; ?French/a

My file switch.php looks like this...
?php
setcookie(userLang, $userLangChoice);
if ($sender == )
$sender = index.php;
else
$sender = $sender;

 header(location:.$sender);
?
Now, for the most part this works fine, but in some cases, my referring  
URL ($sender) is being truncated. Simple URLs such as  
'/listingsearch.php?Category%5B%5D=Hunting' work fine, although it is  
being returned as '/listingsearch.php?Category[]=Hunting'. More complex  
URLs like  
'/listingsearch.php? 
Accommodation%5B%5D=OutpostCategory%5B%5D=FishingRegion%5B%5D=North- 
West' are being truncated at the first variable down to  
'/listingsearch.php?Accommodation[]=Outpost'

Is there something I can do to make sure the referring URL is not  
truncated and it would also be nice if it was left alone and not  
encoded or decoded.

Any thoughts? Thanks,
verdon
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] $_SERVER['REQUEST_URI'] being trimmed

2005-02-03 Thread Verdon Vaillancourt
Thanks for the input Mikey...
I guess I'm just not sure how to, and I had already hit on this method 
that is almost doing the trick :)

salut,
verdon
On 3-Feb-05, at 2:46 PM, Mikey wrote:
Any thoughts? Thanks,
verdon
Why don't you just use JavaScript to set the cookie and then reload 
the page
that you are on?

HTH,
Mikey

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


[PHP] breadcrumb app...

2004-07-10 Thread Verdon Vaillancourt
There's also a nice gpl class for this available at 
http://www.phpclasses.org/browse/package/1192.html or 
http://www.baskettcase.com/classes/breadcrumb/

It's easy to hack also if you need to add further function
On 10-Jul-04, at 9:45 AM, [EMAIL PROTECTED] wrote:
Subject: breadcrumb app...
Reply-To: [EMAIL PROTECTED]
hi...
has anybody seen a reasonably good/basic breadcrumb app that works... 
new
pages are displayed to the user based upon the user's menu selection...

i'd like to be able to provide a trail at the top of the page, kind of
like..
home - food - fruit - squash
were the user could then select one of the links of the trail, which 
would
take the user to the earlier page...

searching google results in hundreds of results, but i'm not sure which
examples are good/poor!!
thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Putting a stop in a foreach

2004-05-09 Thread Verdon Vaillancourt
Hi :)

I'm trying to put a stop in a foreach statement following the user
suggestion here, php.net/manual/en/control-structures.foreach.php

Not really knowing what I am doing, I am running into some synatx problems.
I'm sure I'm doing something really stupid, can anybody point it out?

This is the original statement that works...

foreach ($this-_content as $item) {
if ($item['type'] == 'item'){
$elements['ITEM_LINK'] = $item['link'];
$elements['ITEM_TITLE'] = $item['title'];
$elements[TARGET] = $this-_target;
$items .= PHPWS_Template::processTemplate($elements,
phpwsrssfeeds, block_item.tpl);
}
} 


This is my attempt to count items and put a stop in the foreach so it only
returns 5 items.

foreach ($this-_content as $n = $item) {
if ($n==5) { 
break;
} else { 
if ($this-_content[$n] = $item['type'] == 'item'){
$elements['ITEM_LINK'] = $this-_content[$n] = $item['link'];
$elements['ITEM_TITLE'] = $this-_content[$n] = $item['title'];
$elements[TARGET] = $this-_target;
$items .= PHPWS_Template::processTemplate($elements,
phpwsrssfeeds, block_item.tpl);
}
}
}

Php doesn't like the syntax on any of the,
$this-_content[$n] = $item['type']
, etc lines


TIA,
Verdon

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



Re: [PHP] Putting a stop in a foreach

2004-05-09 Thread Verdon Vaillancourt
Hmm, yes I see. Thank you.

I guess what I should look at then is getting the key value (internal
counter/pointer) in the array going to the foreach. Like this example...

$a = array( 1,2,3,17 );

$i =0;/* for illustrative purposes only */

foreach ( $a as $v ) {
    echo \$ a[$i ]= $v. \n ;
   $i ++; 
}

Once I have that key value (internal counter) I should be able to do
something with it? What I really want to do (since I can't easily get at the
query building the array being passed to the foreach) is get the foreach to
stop outputting results at a certain limit.

Thanks again,
Verdon


On 5/9/04 11:34 AM, Matt Schroebel [EMAIL PROTECTED] wrote:

 It's good to understand what foreach is doing:
 ?php
 $car['GM'] = 'Impala';
 $car['TOYOTA'] = 'Corolla';
 $car['HONDA'] = 'Civic';
 
 foreach ($car as $manufacturer = $ model) {
 echo $manufacturer - $model br /\n;
 }
 ?
 
 Results:
 GM - Impala
 TOYOTA - Corolla
 HONDA - Civic
 
 
 

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



[PHP] Re: Putting a stop in a foreach - SOLVED

2004-05-09 Thread Verdon Vaillancourt
Hi Torsten, Aidan and Matt

Both of Torsten's and Aidan's suggestions worked, though the number of
returned results using Aidan's method isn't what I expected. This could be
the result of something else and I'm trying to puzzle out why. Matt helped
clarify my basic misunderstanding in what the foreach statement was doing.

Conceptually though, Torsten's and Aidan's suggestions both work.

On 5/9/04 12:11 PM, Torsten Roehr wrote:

 Sorry, I mixed up the for and the foreach syntaxes. Here my (hopefully
 correct) loop proposal:
 
 for ($i; $i  5; $i++) {
 
if (is_array($this-_content)  is_array($this-_content[$i]) 
 $this-_content[$i]['type'] == 'item') {
  $elements['ITEM_LINK']  = $this-_content[$i]['link'];
  $elements['ITEM_TITLE'] = $this-_content[$i]['title'];
  $elements['TARGET'] = $this-_target;
  $items .= PHPWS_Template::processTemplate($elements, 'phpwsrssfeeds',
 'block_item.tpl');
   }
 }
 
 $elements and items should be initialized before the loop.
 
 
 Please try and report if it helped.
 
 Regards, Torsten



On 5/9/04 12:11 PM, Aidan Lister wrote:

 Simple!
 
 $i = 0;
 foreach ($foos as $foo)
 {
 // do stuff
 
   $i++;
   if ($i  5) break;
 }
 
 Cheers
 
 
 Verdon Vaillancourt [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Hi :)
 
 I'm trying to put a stop in a foreach statement following the user
 suggestion here, php.net/manual/en/control-structures.foreach.php
 
 Not really knowing what I am doing, I am running into some synatx
 problems.
 I'm sure I'm doing something really stupid, can anybody point it out?
 
 This is the original statement that works...
 
 foreach ($this-_content as $item) {
 if ($item['type'] == 'item'){
 $elements['ITEM_LINK'] = $item['link'];
 $elements['ITEM_TITLE'] = $item['title'];
 $elements[TARGET] = $this-_target;
 $items .= PHPWS_Template::processTemplate($elements,
 phpwsrssfeeds, block_item.tpl);
 }
 }
 
 
 This is my attempt to count items and put a stop in the foreach so it only
 returns 5 items.
 
 foreach ($this-_content as $n = $item) {
 if ($n==5) {
 break;
 } else {
 if ($this-_content[$n] = $item['type'] == 'item'){
 $elements['ITEM_LINK'] = $this-_content[$n] = $item['link'];
 $elements['ITEM_TITLE'] = $this-_content[$n] =
 $item['title'];
 $elements[TARGET] = $this-_target;
 $items .= PHPWS_Template::processTemplate($elements,
 phpwsrssfeeds, block_item.tpl);
 }
 }
 }
 
 Php doesn't like the syntax on any of the,
 $this-_content[$n] = $item['type']
 , etc lines
 

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



[PHP] Finding value in multi-dimensional array

2004-04-09 Thread Verdon Vaillancourt
Hi, being somewhat of a noob, I hope I'm using the right language to phrase
this question...

In a project I am working with, I have a multi-dimensional array in session
when a user logs in. Visually, it looks something like this...

OBJ_user
username = value
isAdmin = value
modSettings =  contacts = array
news = array
listings = firstname = value
lastname = value
active = value
phone = value
gallery = array
anothermod = array
userID = value
js = value


I'm trying to check the value of active for an if() statement and can't seem
to figure out the correct syntax to get it to work. I've tried

if($_SESSION[OBJ_user]-modSettings[listings]-active == 1) {
then do something;
} else {
then do something else;
}

if($_SESSION[OBJ_user][modSettings][listings][active]) {
then do something;
} else {
then do something else;
}

if($_SESSION[OBJ_user][modSettings][listings][active] == 1) {
then do something;
} else {
then do something else;
}

and none of them work even though I know the session value is there.

Any advice as to what I'm doing wrong?

Thanks,
verdon

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



Re: [PHP] Finding value in multi-dimensional array

2004-04-09 Thread Verdon Vaillancourt
Sorry, my example was poor :) Thanks for the print_r tip. When added to the
bottom of the page,

print_r($_SESSION[OBJ_user]);

Prints...

phpws_user Object
(
[user_id] = 5
[username] = agent
[password] = 77abcd5cb2ef4a366c2749ea9931c79e
[email] = [EMAIL PROTECTED]
[admin_switch] = 1
[deity] = 
[groups] = Array
(
)

[modSettings] = Array
(
[listings] = Array
(
[active] = 1
[first_name] = Agent
[last_name] = Guy
)

)

[permissions] = Array
(
[MOD_debug] = 1
)

[groupPermissions] =
[groupModSettings] =
[error] = Array
(
)

[temp_var] = 
[last_on] = 1081527610
[js_on] = 1
[user_settings] =
[group_id] = 
[group_name] =
[description] =
[members] = 
)

So, should my reference be...

if($_SESSION[OBJ_user][modSettings][listings]-active == 1)

That didn't seem to work, but if it should, perhaps I need to look somewhere
else?

Thanks,
Verdon



On 4/9/04 4:06 PM, Richard Harb [EMAIL PROTECTED] wrote:

 do a print_r() for the structure. -- print_r($_SESSION[OBJ_user]);
 and look at the page source.
 
 at each level ...
 if is says array refer to it with ['property']
 if obj (stdClass or otherwise) use - that arrow thingy
 
 I am not sure what the arrows in you desc mean, whether it's key/value
 pair of the array or hints to it being an object's property.
 
 hth
 
 Richard
 
 Friday, April 9, 2004, 9:43:36 PM, you wrote:
 
 Hi, being somewhat of a noob, I hope I'm using the right language to phrase
 this question...
 
 In a project I am working with, I have a multi-dimensional array in session
 when a user logs in. Visually, it looks something like this...
 
 OBJ_user
 username = value
 isAdmin = value
 modSettings =  contacts = array
 news = array
 listings = firstname = value
 lastname = value
 active = value
 phone = value
 gallery = array
 anothermod = array
 userID = value
 js = value
 
 
 I'm trying to check the value of active for an if() statement and can't seem
 to figure out the correct syntax to get it to work. I've tried
 
 if($_SESSION[OBJ_user]-modSettings[listings]-active == 1) {
 then do something;
 } else {
 then do something else;
 }
 
 if($_SESSION[OBJ_user][modSettings][listings][active]) {
 then do something;
 } else {
 then do something else;
 }
 
 if($_SESSION[OBJ_user][modSettings][listings][active] == 1) {
 then do something;
 } else {
 then do something else;
 }
 
 and none of them work even though I know the session value is there.
 
 Any advice as to what I'm doing wrong?
 
 Thanks,
 verdon
 
 
 
 
 
 

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



Re: [PHP] Finding value in multi-dimensional array - Solved

2004-04-09 Thread Verdon Vaillancourt
Hi,

Thanks much to Richard and Andy for the input :)  This one did the job...

if($_SESSION['OBJ_user']-modSettings['listings']['active'] == '1') {

I'm still not entirely sure I understand the syntax ;)

verdon


 From: Richard Harb [EMAIL PROTECTED]
 Date: Fri, 9 Apr 2004 22:49:44 +0200

 Let's see:
 if($_SESSION['OBJ_user']-modSettings['listings']['active'] == '1') {
 
 That should be it ...
 
 Sidenote: use single quotes whenever the string needn't be evaluated
 (i.e. is a variable itself) you save a couple cycles every time.
 


 phpws_user Object
 (
   [user_id] = 5
   [username] = agent
   [password] = 77abcd5cb2ef4a366c2749ea9931c79e
   [email] = [EMAIL PROTECTED]
 
   [modSettings] = Array
   (
   [listings] = Array
   (
   [active] = 1
   [first_name] = Agent
   [last_name] = Guy
   )
 
   )
 
   [error] = Array
   (
   )
 
   [temp_var] = 
   [last_on] = 1081527610
   [js_on] = 1
   [user_settings] =
 )
 
 

On 4/9/04 4:06 PM, Richard Harb [EMAIL PROTECTED] wrote:

 do a print_r() for the structure. -- print_r($_SESSION[OBJ_user]);
 and look at the page source.
 
 at each level ...
 if is says array refer to it with ['property']
 if obj (stdClass or otherwise) use - that arrow thingy
 

 
 Friday, April 9, 2004, 9:43:36 PM, you wrote:
 
 Hi, being somewhat of a noob, I hope I'm using the right language to phrase
 this question...
 
 In a project I am working with, I have a multi-dimensional array in session
 when a user logs in. Visually, it looks something like...

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



[PHP] Simple while loop skipping first row of array

2004-02-15 Thread Verdon Vaillancourt
I'm not sure I phrased my subject well, but...

The following is just to build a select menu from a table query result set.
It sort of works, but doesn't return the first row in the result set, ie if
I have the following rows in the table 'cats';

id  title
==
1   Pears
2   Oranges
3   Apples
4   Bananas

echo select name=\cats\;
$result = mysql_query(select * from cats order by title);
$categories = mysql_fetch_array($result);
if ($categories) {
while ($c = mysql_fetch_array($result)) {
echo option value=\$c[id]\$c[title]/option;
}
}
echo /select;


The resulting select menu will only include Bananas, Oranges, Pears.

Am I missing something terribly obvious to one less newbie than me?

TIA, 
Verdon

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



Re: [PHP] Simple while loop skipping first row of array

2004-02-15 Thread Verdon Vaillancourt
That did the trick, and I learned something new. thanks :)
verdon

On 2/15/04 11:38 AM, Duncan [EMAIL PROTECTED] wrote:

 Problem is, that the first row is already in the $categories variable -
 since you have the first mysql_fetch_array call there.
 change it to:
 
 echo select name=\cats\;
 $result = mysql_query(select * from cats order by title);
 while ($c = mysql_fetch_array($result)) {
  echo option value=\$c[id]\$c[title]/option;
 }
 echo /select;
 
 
 ...and it should work just fine.
 
 Verdon Vaillancourt wrote:
 
 I'm not sure I phrased my subject well, but...
 
 The following is just to build a select menu from a table query result set.
 It sort of works, but doesn't return the first row in the result set, ie if
 I have the following rows in the table 'cats';
 
 id  title
 ==
 1   Pears
 2   Oranges
 3   Apples
 4   Bananas
 
 echo select name=\cats\;
 $result = mysql_query(select * from cats order by title);
 $categories = mysql_fetch_array($result);
 if ($categories) {
while ($c = mysql_fetch_array($result)) {
echo option value=\$c[id]\$c[title]/option;
}
 }
 echo /select;
 
 
 The resulting select menu will only include Bananas, Oranges, Pears.
 
 Am I missing something terribly obvious to one less newbie than me?
 
 TIA, 
 Verdon
 
  
 
 
 
 

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



[PHP] Using a perl regex

2004-02-11 Thread Verdon Vaillancourt
Hi,

I am trying to use a perl regular expression to validate a form field where
I am allowing someone to edit a sql date-time stamp in the format of
'2004-02-05 21:43:34'.

I have found a pattern that works (at
http://www.regexplib.com/RETester.aspx?regexp_id=93) which is;

20\d{2}(-|\/)((0[1-9])|(1[0-2]))(-|\/)((0[1-9])|([1-2][0-9])|(3[0-1]))(T|\s)
(([0-1][0-9])|(2[0-3])):([0-5][0-9]):([0-5][0-9])

However, when I try to use it in a php if statement like this;

if 
(!ereg(20\d{2}(-|\/)((0[1-9])|(1[0-2]))(-|\/)((0[1-9])|([1-2][0-9])|(3[0-1]
))(T|\s)(([0-1][0-9])|(2[0-3])):([0-5][0-9]):([0-5][0-9]),$date_time)) {
echo pYou must provide a date and time in the format -MM-DD
HH:MM:SS/p;
echo forminput type=\button\ value=\Go back\
onClick=\history.back()\/form;
}


It doesn't match and allow valid strings through.

Any suggestions?

TIA, 
Verdon

Ps. Please cc me in any replies to list as I am in digest mode.

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



Re: [PHP] Using a perl regex

2004-02-11 Thread Verdon Vaillancourt
I should have prefaced my subject with NEWBIE :)

Thanks, I'll give it a try.

Best regards, verdon


On 2/11/04 12:12 PM, Richard Davey [EMAIL PROTECTED] wrote:

 Hello Verdon,
 
 Wednesday, February 11, 2004, 5:09:22 PM, you wrote:
 
 VV I am trying to use a perl regular expression to validate a form field
 where
 
 VV 
 (!ereg(20\d{2}(-|\/)((0[1-9])|(1[0-2]))(-|\/)((0[1-9])|([1-2][0-9])|(3[0-1]
 
 Surely you should be using preg_match() (i.e. a perl syntax reg exp) ?

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



Re: [PHP] Using a perl regex

2004-02-11 Thread Verdon Vaillancourt
I thought I might have tried that and just did again.

I receive the error;
Warning :  Delimiter must not be alphanumeric or backslash in
/server/path/to/functions.php on line 

I'm not sure if this means I have to escape something in the pattern, but
will look further.

Cheers,
Verdon


On 2/11/04 12:12 PM, Richard Davey [EMAIL PROTECTED] wrote:

 Hello Verdon,
 
 Wednesday, February 11, 2004, 5:09:22 PM, you wrote:
 
 VV I am trying to use a perl regular expression to validate a form field
 where
 
 VV 
 (!ereg(20\d{2}(-|\/)((0[1-9])|(1[0-2]))(-|\/)((0[1-9])|([1-2][0-9])|(3[0-1]
 
 Surely you should be using preg_match() (i.e. a perl syntax reg exp) ?

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



Re: [PHP] Using a perl regex

2004-02-11 Thread Verdon Vaillancourt
Thanks Kelly (and Richard),

That did the job :)

Salut,
Verdon


On 2/11/04 12:22 PM, Kelly Hallman [EMAIL PROTECTED] wrote:

 On Wed, 11 Feb 2004, Verdon Vaillancourt wrote:
 I thought I might have tried that and just did again.
 
 I receive the error; Warning :  Delimiter must not be alphanumeric or
 backslash in /server/path/to/functions.php on line 
 
 I'm not sure if this means I have to escape something in the pattern,
 but will look further.
 
 I think it means you need to put a delimiter around your regex...
 Typically you would use slashes (preg_match(/regex/)) but the character
 can be other than slash.. i.e. not alphanumeric or backslash :)

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



[PHP] Re: php-general Digest 28 Oct 2003 17:26:53 -0000 Issue 2382

2003-10-28 Thread Verdon Vaillancourt
There's a nice GPL class that does this quite well. It could save you a lot
of work and will definitely provide an example.

Check out;
http://www.phpclasses.org/search.html?words=linked_selectgo_search=1



On 10/28/03 12:26 PM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 - Original Message -
 From: Robb Kerr [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, October 28, 2003 5:59 PM
 Subject: Re: [PHP] Menu populated based on previous menu
 
 
 Thanx for the tips. I'll search the JavaScript sites and see what I can
 come up with.
 --
 Robb Kerr
 Digital IGUANA
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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



Re: [PHP] Menu populated based on previous menu

2003-10-28 Thread Verdon Vaillancourt
There's a nice GPL class that does this quite well. It could save you a lot
of work and will definitely provide an example.

Check out;
http://www.phpclasses.org/search.html?words=linked_selectgo_search=1



On 10/28/03 12:26 PM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 - Original Message -
 From: Robb Kerr [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, October 28, 2003 5:59 PM
 Subject: Re: [PHP] Menu populated based on previous menu
 
 
 Thanx for the tips. I'll search the JavaScript sites and see what I can
 come up with.
 --
 Robb Kerr
 Digital IGUANA
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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



[PHP] GD lib security issues

2003-09-10 Thread Verdon vaillancourt
Hi,

I use a fairly standard sort of reseller package (*nix and hsphere based)
for hosting sites. Although the versions of php and mySQL are fairly up to
date, the version of GD lib is frozen at 1.6.2. When I question my provider
about this and when GD v2.x would be available, they replied that there were
security issues with GD 2.x in a shared environment and that they wouldn't
be offering this version of GD until these had been reviewed and addressed.

I haven't had much luck finding out what these issues might be and wondered
if anyone else could shed some light on this? Perhaps the right sort of
information might help me to encourage them to upgrade.

Thanks,
verdon

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



[PHP] Re: Including classes inside functions vs outside - scope/global[solved]

2003-09-02 Thread Verdon vaillancourt
Hi Greg,

I've been on a holiday and just got to ttry this last night. Worked like a
charm. Thank You!

Salut, verdon


 Hi Verdon,
 
 Be sure that $connobj is declared as a global variable in the
 mysql_connection.php file.  You can do this in two ways:
 
 1) instead of $connobj = blah, use $GLOBALS['connobj'] = blah 2) global
 $connobj; $connobj = blah
 
 Regards, Greg -- phpDocumentor http://www.phpdoc.org
 
 Verdon Vaillancourt wrote: Hi :)
 
 Somewhat newbie question...
 
 I'm trying to include some open source classes into a project I am working
 on. The classes build a set of relational select menus from the contents of
 two tables. I have not trouble using the classes in a simple test page, but
 am running into problems when I try to use them as part of a function. For
 instance...

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



[PHP] Including classes inside functions vs outside - scope/globalquestion?

2003-08-28 Thread Verdon vaillancourt
Hi :)

Somewhat newbie question...

I'm trying to include some open source classes into a project I am working
on. The classes build a set of relational select menus from the contents of
two tables. I have not trouble using the classes in a simple test page, but
am running into problems when I try to use them as part of a function. For
instance the following works just fine...

?
session_start();
session_register(session);

include_once(config.php);
include_once (functions.php);
include_once(head.php);
loginCheck(3);
global $config;

echo a bunch of my own stuff;

// this is the class stuff I am trying to include
require(mysql_connection.php);
require(mysql_recordset.php);
require (linked_select_class.php);
$conn = new mysql_conn(localhost,user,pass,database) ;
$conn-init() ;
$ls = new linked_select(conn,testselect,clients,Select
Client,id,company,1,pieces,Select
Piece,id,title,client_id,0,1) ;
$ls-create_javascript();
$ls-create_base_select();
$ls-create_sub_select_multi();
// the end of the class stuff

echo a bunch more of my own stuff;

include(foot.php);
?

While this does not...

?
session_start();
session_register(session);

include_once(config.php);
include_once (functions.php);
include_once(head.php);
loginCheck(3);
global $config;


function whatever() {
global $config;
echo a bunch of my own stuff;
// this is the class stuff I am trying to include
require(mysql_connection.php);
require(mysql_recordset.php);
require (linked_select_class.php);
$conn = new mysql_conn(localhost,user,pass,database) ;
$conn-init() ;
$ls = new linked_select(conn,testselect,clients,Select
Client,id,company,1,pieces,Select
Piece,id,title,client_id,0,1) ;
$ls-create_javascript();
$ls-create_base_select();
$ls-create_sub_select_multi();
// the end of the class stuff
echo a bunch more of my own stuff;
}

$main_content = whatever();
echo $main_content;

include(foot.php);
?

It returns an error like 'Call to undefined function:  debug() in
/xxx/xxx/mysql_recordset.php on line 40'. When I check this line out, it is
' $GLOBALS[$this-connobj]-debug() ;'.

Now I know this function exists (it's in the required file
'mysql_connection.php'), and works from my simple test. Quickly commenting
out the line 40 allows the page to finish rendering, but the select menus
are empty, so my guess is the 'connobj' is not being passed along or the 3
required class files are not talking to each other in some way ;)

Doing some reading in the manual tells me it's a scope issue (I think). I
thought though that $GLOBALS was a super global but I guess I just don't get
the concept yet. I've tried declaring all sorts of things as global in my
function whatever() to no avail.

Is there something really basic that I am missing in understanding, or is
this a more complex thing?

TIA,
Verdon
Ps. Cc'ing to me when/if replying to list would be appreciated as I am on
digest mode :)

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



Re: [PHP] I wish I knew more about multi-dimensional arrays

2003-08-23 Thread Verdon vaillancourt
Hey bigdog, that's beautiful! I laughed, I cried, so elegant ;)

Thanks, that did the job nicely.

Salut,
verdon



On 8/23/03 2:02 AM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 From: Ray Hunter [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 Date: Fri, 22 Aug 2003 11:03:10 -0600
 To: 'PHP-General' [EMAIL PROTECTED]
 Subject: Re: [PHP] I wish I knew more about multi-dimensional arrays
 
 mysql result as a multi-dimensional array:
 
 while( $row = mysql_fetch_array($result) ) {
 $rows[] = $row;
 }
 
 now you have a multi-dimensional array that contains each row in rows...
 
 examples:
 row 1 col 1 - $rows[0][0]
 row 3 col 2 - $rows[3][2]
 
 hth
 
 --
 bigdog
 
 
 On Fri, 2003-08-22 at 10:37, Verdon vaillancourt wrote:
 Hi, please don't chuckle (too loudly) at my attempts to learn ;)
 
 I'm trying to create what I think would be a multi-dimensional array from a
 mysql result set, to use in some example code I got off this list last week.
 


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



[PHP] I wish I knew more about multi-dimensional arrays

2003-08-22 Thread Verdon vaillancourt
Hi, please don't chuckle (too loudly) at my attempts to learn ;)

I'm trying to create what I think would be a multi-dimensional array from a
mysql result set, to use in some example code I got off this list last week.

The example renedring code I want to work with is...

?php

$data = array('A', 'B', 'C', 'D', 'E', 'F', 'G');
$rowlength = 3;

echo (table);
for ($i = 0; $i  sizeof ($data); $i += $rowlength)
{
echo (tr);
for ($j = 0; $j  $rowlength; $j++)
{
if (isset ($data[$i+$j]))
{
echo (td{$data[$i+$j]}/td);
} else {
echo (tdnbsp;/td);
}
}
echo (/tr);
}
echo (/table);



?

I trying to create the $data array from my query results like this...

$sql = select * from table limit 0,5;
$result = mysql_query ($sql);
$number = mysql_numrows ($result);

for ($x = 0; $x  sizeof (mysql_fetch_array($result)); $x ++) {
$data = implode (',',$result[$x]);
}

I had hoped this would get me the six arrays on the page (where I could then
extract the values). I've also tried a number of similar approaches but am
consistently getting six error messages on the page along the lines of

Warning :  implode() [ function.implode ]: Bad arguments. in

I know I'm missing something basic and would appreciate any pointers.

Thanks,
Verdon


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



Re: [PHP] Nestled 'while's or 'for's or 'foreach's -- I'm lost

2003-08-21 Thread Verdon vaillancourt
 On Sun, 17 Aug 2003 15:47:04 -0400, I wrote:
 I'm trying to take a paged result set and divide it into two chunks for
 displaying on the page. Basically making something that looks like a typical
 thumbnail gallery... ...I've include a rather lengthy bit of pseudo code that
 represents basically where I'm at now...


Thanks David, Petre, and Curt


David, this is exactly what I was so poorly trying to get at ;) I just have
to consider my found result set of rows as array('A', 'B', 'C', 'D', 'E',
'F', 'G', 'H') Your example renders the data in the way I was looking for.
Thanks!

 On 8/17/03 3:57 PM, David Otton [EMAIL PROTECTED] wrote:

 $data = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H');
 $rowlength = 3;
 
 echo (table);
 for ($i = 0; $i  sizeof ($data); $i += $rowlength)
 {
 echo (tr);
 for ($j = 0; $j  $rowlength; $j++)
 {
 if (isset ($data[$i+$j]))
 {
 echo (td{$data[$i+$j]}/td);
 } else {
 echo (tdnbsp;/td);
 }
 }
 echo (/tr);
 }
 echo (/table);
 


Petre, you were right also. I was able to get my pseudo method to work,
though it was a mess ;)  Your example has provided some guidance in
re-thinking. Best Regards.

 On 8/17/03 4:18 PM, Petre Agenbag [EMAIL PROTECTED] wrote:

 ...instead of using your elaborate ways of running through the
 result set and extracting the variables, use something like this:
 
 $sql = whatever;
 $result = mysql_query($sql);
 
 echo 'tabletrtdID/td.../tr
 
 while ($myrow = mysql_fetch_assoc($result)) {
 extract($myrow);
 //or $id = $myrow[id]; etc.
 ...
 //construct your table here
 echo 'trtd'.$id.'/td.../tr';
 ...
 }
 echo '/table';
 
 
 ... mistakes in the pseudo code below is that you open a the table inside
 the while and close it as well (which is fine if you want to create a table
 for each row you display , BUT, you close the table again AFTER the while,
 that *could* cause the HTML to freak out. So, the reason your app is not
 working is probably not PHP related, but related to the fact that you are
 creating erroneous HTML with your PHP. The pseudo code you are using *should*
 work, although, as I stated above, there are easier and more efficient ways of
 doing the same thing as per my example...
 


Curt, another way of looking at it. Thank You.

 From: Curt Zirzow [EMAIL PROTECTED]
 Date: Sun, 17 Aug 2003 23:24:49 +

 This can easily be done using the mod operator (%):
 
 $cols_per_page = 3;
 $cols_per_page_break = $cols_per_page - 1;  // just to speed the loop
 
 echo table;
 echo trthCol Headings/th/tr;
 
 $counter = 0;
 while($row = db_fetch_row() ) {
 
 $new_row = $counter++ % $cols_per_page;
 if ($new_row == 0 ) {
   echo tr; // open a row
 }
 
 echo tdCol Data/td;
 
 if ($new_row == $cols_per_page_break ) {
   // close and open a row
   print /tr;
 }
 }
 
 // Make sure the row was closed in case of uneven recordset.
 if ( ( ($counter - 1) % $cols_per_page) != $cols_per_page_break ) {
 // close and open a row
 // cause we didn't close it in the loop
 print /tr;
 }
 
 echo /table; //close row and table
 
 um.. ok, so it wasnt that easy.. I made this a little more
 complicated than I was expecting it to be.
 
 btw, this is completely untested.
 


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



[PHP] Nestled 'while's or 'for's or 'foreach's -- I'm lost

2003-08-17 Thread Verdon vaillancourt
Hi, somewhat newbie warning :)

I'm trying to take a paged result set and divide it into two chunks for
displaying on the page. Basically making something that looks like a typical
thumbnail gallery. I'm limiting my result set to 6 records and want to
display it as 2 rows of 3 cells with a record in each cell. I've had no
trouble getting my result set, paging etc. I'm not having much luck
splitting my result into 2 chunks. I've tried nestling 'while' statements
with a number of arguments and either end up with no results or a loop that
seemingly never ends. That lead me to looking at some other apps which
seemed to use a variety of ways to achieve what I want. That lead me to
looking at 'for' and 'foreach' in the php manual. And that lead me to being
more confused than I was before I started ;) Sometimes there's just too many
ways to skin a cat, eh!

Below, I've include a rather lengthy bit of pseudo code that represents
basically where I'm at now. This particular version returns no results,
though I know it's just the nestled while's that are causing this. The
results are there. My research makes me think that I should replace the
nestled while's with 'foreach's. I was kind of hoping that before I spend a
few hours trying to puzzle out how to use the 'foreach's correctly that
somebody would venture an opinion as to whether or not that would be the way
to go.

Thanks in advance for any advice,
Verdon

-- pseudo code --

?php

$limitPerPage = 6 ;
$initStartLimit = 0;

if (!isset( $startLimit )) {
$startLimit = $initStartLimit ;
}

$querylimit =  limit $startLimit,$limitPerPage  ;
$nextStartLimit = $startLimit + $limitPerPage ;
$previousStartLimit = $startLimit - $limitPerPage ;

if ( $sortby !=  ) {
$sorted =  order by $sortby  ;
}

$bareQuery = select * from pieces order by rank;
$queryall = $bareQuery .$sorted .$querylimit;
$resultall = mysql_query ($queryall);
$numberall = mysql_numrows ($resultall);

if ( $numberall == 0) {
echo No Records Found ! ;
} else if ( $numberall  0) {

$x = 0;

echo h2Page of Pieces/h2;

while ( $x  $numberall ) {
 
// Retreiving data and putting it in local variables for each row
$id = mysql_result ($resultall ,$x ,id);
$title = mysql_result ($resultall ,$x ,title);
$description = mysql_result ($resultall ,$x ,description);
$thumb = mysql_result ($resultall ,$x ,thumb);
$company = mysql_result ($resultall ,$x ,company);

echo table cellspacing=\0\;
echo tr;

while ($x = 0  $x  4)
{

echo td;
if ($thumb) {
echo thumbnail with a link;
} else {
echo text with a link;
}
echo br /strong$title/strong;
echo br /$company;
echo br /$description;
echo /td;
$x ++;
}

echo /tr;
echo tr;

while ($x  3  $x  $numberall)
{

echo td;
if ($thumb) {
echo thumbnail with a link;
} else {
echo text with a link;
}
echo br /strong$title/strong;
echo br /$company;
echo br /$description;
echo /td;
$x ++;
}

echo /tr;
echo /table;

$x ++; 
} // end while
echo /tablebr /;

echo div class=\footLinks\;
echo Previous links;
echo Next links;
echo /div;

}// end if numberall  0

?


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



Re: [PHP] Reformatting phone number string from user input

2003-08-14 Thread Verdon vaillancourt
Yes,

I found some examples in the archives that measured a clean string and
formatted it according to whether it found 4 (is an error), 7 (xxx-), 10
(xxx-xxx-) or 11 (x-xxx-xxx-). I'm going to work with this sort of
logic and standardize the format (or maybe just the length of string) before
inserting into my db. I haven't completely decided if it's better to store
1234567890 and format it on retrieval or to format it first and store
123-456-7890. I guess unless I plan to do math or something with the raw
data later (not too likely for a phone number), it probably doesn't make
much difference.

Thanks again :)


On 8/10/03 2:25 PM, John W. Holmes [EMAIL PROTECTED] wrote:

 After you replace all of the non numeric characters, if the length is 7,
 you can add the default area code.

 Verdon vaillancourt wrote:
 
 Thanks John,
 
 That does look a lot tidier. I tried a similar approach early on, but was
 trying to specifically match '(' and ')' and was running into lots of
 trouble with my syntax, in specific, properly escaping \( and \) so they
 were not treated as paranthesis/operators/whatever. This is much simpler. I
 like simple :)
 
 Now I can focus on inserting a default area code, if the user does not ;)
 


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



Re: [PHP] Reformatting phone number string from user input

2003-08-14 Thread Verdon vaillancourt
Thanks John,

That does look a lot tidier. I tried a similar approach early on, but was
trying to specifically match '(' and ')' and was running into lots of
trouble with my syntax, in specific, properly escaping \( and \) so they
were not treated as paranthesis/operators/whatever. This is much simpler. I
like simple :)

Now I can focus on inserting a default area code, if the user does not ;)

Salut,
Verdon


On 8/10/03 2:04 PM, John W. Holmes [EMAIL PROTECTED] wrote:

 Verdon vaillancourt wrote:
 
 Hi :)
 
 I've been working on reformatting a phone number string from user input via
 a form field. Ultimately, my goal is to format all phone numbers in the same
 way regardless of whether a user inputs '(123) 456-7890', '123-456-7890',
 '123.456.7890', etc. before I insert them into a db.
 
 I know I've got a ways to go, but so far, after trying a few things I found
 in the manual, I'm going in this direction...
 
 $patterns[0] = /\(/;
 $patterns[1] = /\)/;
 $patterns[2] = /-/;
 
 $replacements[0] = ;
 $replacements[1] = ;
 $replacements[2] =  ;
 
 $phone = preg_replace($patterns, $replacements, $phone);
 
 This will change '(123) 456-7890' to '123 456 7890' which is what I am
 after. I'm just wondering if there is a better or more elegant way to handle
 this before I start trying to cover all the bases?
 
 Could do something like this:
 
 $phone = preg_replace('/[^0-9]/','',$phone);
 if(strlen($phone) != 10)
 { echo phone number is not valid!; }
 $phone = substr($phone,0,3) . ' ' . substr($phone,3,3) . ' ' .
 substr($phone,-4);
 
 Which should cover all of the bases. :)


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



[PHP] Reformatting phone number string from user input

2003-08-10 Thread Verdon vaillancourt
Hi :)

I've been working on reformatting a phone number string from user input via
a form field. Ultimately, my goal is to format all phone numbers in the same
way regardless of whether a user inputs '(123) 456-7890', '123-456-7890',
'123.456.7890', etc. before I insert them into a db.

I know I've got a ways to go, but so far, after trying a few things I found
in the manual, I'm going in this direction...

$patterns[0] = /\(/;
$patterns[1] = /\)/;
$patterns[2] = /-/;

$replacements[0] = ;
$replacements[1] = ;
$replacements[2] =  ;

$phone = preg_replace($patterns, $replacements, $phone);

This will change '(123) 456-7890' to '123 456 7890' which is what I am
after. I'm just wondering if there is a better or more elegant way to handle
this before I start trying to cover all the bases?

Note: I found a variety of examples in the mailing list archives, but none
of them seem to use the method above. Hmmm, does that mean I'm taking the
long way around ;) I know I could just copy some examples from there, but
I'm trying to use this as a learning opportunity and there seems to be more
than one way to skin the cat (no offence to cat lovers ;)

TIA for any advice,
Verdon


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



[PHP] Purging old files from directories

2003-08-01 Thread Verdon vaillancourt
Hi :)

I need to write a script that will scan/read a given directory's contents
and delete files older than a certain date. Ideally, this will be a script
that runs via cron once a week and deletes all files it finds in the
directory older than 2 weeks from the current date. I do currently have
scripts running via cron and that's no problem. I'm not sure where to begin
with the other components

I'm not looking to be spoon-fed, but I was hoping that someone could point
me in the right direction to start researching.

Best regards,
Verdon


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



Re: [PHP] Purging old files from directories

2003-08-01 Thread Verdon vaillancourt
Thank you :)

On 8/1/03 10:06 AM, Marek Kilimajer [EMAIL PROTECTED] wrote:

 Begin in the manual:
 Directory functions
 Filesystem functions - filemtime()


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



[PHP] Re: MAIL( ) - Send mail using another SMTP

2003-06-21 Thread Verdon Vaillancourt
I think you can do this with an .htaccess file instead of the php.ini file
:)


On 6/21/03 6:29 AM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 From: Chinmoy Barua [EMAIL PROTECTED]
 Date: Fri, 20 Jun 2003 23:46:06 -0700 (PDT)
 To: [EMAIL PROTECTED]
 Subject: MAIL( ) - Send mail using another SMTP
 
 Hello Everybody,
 
 I don't have sendmail/qmail on my web server where i
 installed PHP. But I want to send mails from web
 server using PHP.
 
 Can anybody tell me, how can i use another SMTP server
 to send mails? I don't like to change php.ini on my
 web server.
 
 Thank You,
 - Chinmoy


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



Re: [PHP] Re: MAIL( ) - Send mail using another SMTP

2003-06-21 Thread Verdon Vaillancourt
Something like this...

Add the following into a .htaccess file for your domain(s)

php_value SMTP  smtp.yourhost.com



On 6/21/03 7:51 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 how do you do this   please explain




[PHP] Checking for existence of file

2003-03-25 Thread Verdon Vaillancourt
HI :)

I've got a function (crude but works) that checks for a value in the url and
then I call an image based on that value.

if (isset($_GET['menu'])) {
$img_pick = substr($_GET['menu'],0,1);
} else { $img_pick = 1; }

echo img src=\/images/mast_$img_pick.jpg\;

What I'd like to do is check the directory 'images' first to see if
'mast_$img_pick.jpg' exists and if it doesn't, call a different image such
as 'mast_default.jpg'. I'm sure this isn't hard, I'm just not sure how to
start.

TIA, verdon
Ps. Please cc me if replying to list


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



Re: [PHP] Wildcard fromURL

2003-03-14 Thread Verdon Vaillancourt
Hi Chris,

Thanks for the pointer :) I found some other interesting reference and ideas
on using this in the manual. Now I just need to provide some error checking
in case $_GET['menu'] isn't defined in the URL (that should be pretty
straight fwd) and in case it is defined, but a corresponding image doesn't
exist (in this case because a user could potentially add a menu item to the
db for which there is no pre-existing graphic). That might prove a little
tougher. I guess I could define an array of available images and check
$_GET['menu'] against that, and specify a default if there isn't a match.

Cheers,
Verdon


On 3/13/03 4:10 PM, Chris Hayes [EMAIL PROTECTED] wrote:

 To read the value of menu in the url, do not use 'menu', but use
 $_GET['menu']  (since PHP 4.1.0)
 
 To check for '2*' you cannot do what you propose.
 Because PHP is such a friendly language with 'types' you could use a string
 function to pick the first character
 
 $img_pick=subtr($_GET['menu'],0,1);
 (check the manual on substr() to be sure, in the online manual on www.php.net)
 
 The maximum of numbers is 10 (0-9), so you may want to just make a separate
 value in the url for this.
 
 I thionk you can omit the if-list now.
 
 
 
 echo = img src=\foo_$imgNo.jpg\;
 
 
 
 At 21:55 13-3-2003, you wrote:
 
 mod.php?mod=userpagemenu=215page_id=xxx
 mod.php?mod=userpagemenu=20001page_id=xxx
 mod.php?mod=site_mapmenu=20010
 
 And would want all the following pages to load an image named something like
 foo_1.jgp
 mod.php?mod=userpagemenu=1page_id=xxx
 submit.phpmenu=100
 mod.php?mod=userpagemenu=10002page_id=xxx
 
 In all cases, I know for sure that in the URL I will find menu=x*
 
 Can I set something up like;
 
 if(menu = '2*') { $ImgNo = '2'; }
 if(menu = '1*') { $ImgNo = '1'; }
 if(menu = '') { $ImgNo = '3'; }


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



[PHP] Wildcard fromURL

2003-03-13 Thread Verdon Vaillancourt
Hi :)

I want to place a particular image on a page based on the URL of the page. I
have a variety of standard patterns to match in the URL. For instance;

I would want all the following pages to load an image named something like
foo_2.jpg
mod.php?mod=userpagemenu=2page_id=xxx
mod.php?mod=userpagemenu=200page_id=xxx
mod.php?mod=userpagemenu=215page_id=xxx
mod.php?mod=userpagemenu=20001page_id=xxx
mod.php?mod=site_mapmenu=20010

And would want all the following pages to load an image named something like
foo_1.jgp
mod.php?mod=userpagemenu=1page_id=xxx
submit.phpmenu=100
mod.php?mod=userpagemenu=10002page_id=xxx

In all cases, I know for sure that in the URL I will find menu=x*

Can I set something up like;

if(menu = '2*') { $ImgNo = '2'; }
if(menu = '1*') { $ImgNo = '1'; }
if(menu = '') { $ImgNo = '3'; }

echo = img src=\foo_$imgNo.jpg\;

salut,
Verdon

Ps. If replying, please cc me as I am on digest


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



[PHP] Re: Multiple page form

2002-11-26 Thread Verdon Vaillancourt
You might also want to look at this solution. It seems functional and
elegant, worked simply for me...

http://codewalkers.com/tutorials.php?show=28page=1


 On 11/26/2002 01:42 PM, Shane McBride wrote:
 It's been a while since I have done any PHP work. I am creating an online
 employment application using multiple forms for a client. I was going to use
 PHP. I don't remember if I need to pass variables along with the form for
 each page, or can I just call them on the last page.
 
 The application form is very long. Any ideas? There may be a script that
 exists already?
 
 Yes, you may want to try this class. It lets you compose and process
 multipage forms in two modes: sequential access (wizard like with
 buttons Next ,  Back, Finish  and cancel) and random access
 (tabbed pages like with edit or view only modes).
 
 http://www.phpclasses.org/multipageforms
 
 
 http://www.phpclasses.org/browse.html/file/348/view/1/name/test_random_form_pa
 ge.html
 
 http://www.phpclasses.org/browse.html/file/349/view/1/name/test_sequential_for
 m_page.html
 
 -- 
 
 Regards,
 Manuel Lemos



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




[PHP] Parsing an array from a posted form

2002-11-20 Thread Verdon Vaillancourt
Hi All :)

I have a form that is being passed to a mail function when submitted. It is
working OK, except that I am having trouble with values from arrays such as
checkbox lists. For example, I have a list such as:

input type=checkbox name=graphicFormat[] value=eps / .eps
input type=checkbox name=graphicFormat[] value=jpg / .jpg
input type=checkbox name=graphicFormat[] value=tif / .tif
input type=checkbox name=graphicFormat[] value=gif / .gif
input type=checkbox name=graphicFormat[] value=png / .png
input type=checkbox name=graphicFormat[] value=psd / .psd
input type=checkbox name=graphicFormat[] value=bmp / .bmp
input type=checkbox name=graphicFormat[] value=other / other

I am using something like:

for ($z=0;$zcount($graphicFormat);$z++) {
  $graphicFormat = stripslashes($graphicFormat[$z]);
}

Which will return a count of the number of items in the array. What I want
returned is a string of the values selected such as:

eps, gif, other

Any suggestions?

Best Regards,
verdon

Ps. Please cc me as I am on digest mode
Pps. Please excuse if my question is TOO fundamental


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




Re: [PHP] Parsing an array from a posted form

2002-11-20 Thread Verdon Vaillancourt
A sincere thanks to John for the prompt and succinct answer. I've seen many
answers from John on this list and am much appreciative of his generosity.

Best regards, verdon  :)


On 11/20/02 3:07 PM, 1LT John W. Holmes [EMAIL PROTECTED] wrote:

 I have a form that is...
... 
 Which will return a count of the number of items in the array. What I want
 returned is a string of the values selected such as:
 
 eps, gif, other
 
 $string = implode(,,$graphicFormat);
 
 To see how many checkboxes were selected, use
 
 $num = count($graphicFormat);
 
 ---John Holmes...
 
 


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




[PHP] Storing/passing variables through multiple-part function/casestatement

2002-10-14 Thread Verdon Vaillancourt

Hi,

I¹m trying to cobble together a case where where data is retrieved from one
row of a mySQL table, the row is deleted, the retrieved data is inserted
into a new row in different table. Most of my code seems to be working (I
think the data is being retrieved, the old row is being deleted, the new row
is being created) but I am not getting a grip on how to pass the retrieved
data into the sql insert statement for the new row in the second table. I¹m
sure I¹m missing something very basic and would appreciate any help
extended. The case statement as is now, is below.

TIA, verdon

Ps. Please cc me in any answer to the list as I am on digest mode

case finishPending:
if ($user_dblocation)
{
mysql_select_db($user_dbname) or die (Unable to select
database);

$result = mysql_query(select uid, uname, name, url, email,
femail, pass, company, bio, description, address, city, province, postcode,
phone, fax, tollfree, otherphone, cat AS uid, uname, name, url, email,
femail, pass, company, bio, description, address, city, province, postcode,
phone, fax, tollfree, otherphone, cat from  . $table_prefix.users_que
where uid='$approve_uid');
list($uname) = mysql_fetch_row($result);

mysql_query(lock tables  . $table_prefix.users_que WRITE);
mysql_query(delete from  . $table_prefix.users_que where
uid='$approve_uid');
mysql_query(unlock tables);
mysql_select_db($dbname) or die (Unable to select
database);
}
else
{
$result = mysql_query(select uid, uname, name, url, email,
femail, pass, company, bio, description, address, city, province, postcode,
phone, fax, tollfree, otherphone, cat AS uid, uname, name, url, email,
femail, pass, company, bio, description, address, city, province, postcode,
phone, fax, tollfree, otherphone, cat from  . $table_prefix.users_que
where uid='$approve_uid');
list($uname) = mysql_fetch_row($result);

mysql_query(lock tables  . $table_prefix.users_que WRITE);
mysql_query(delete from  . $table_prefix.users_que where
uid='$approve_uid');
mysql_query(unlock tables);
}

mysql_query(LOCK TABLES  . $table_prefix.stories WRITE);
mysql_query(UPDATE  . $table_prefix.stories SET
informant='$anonymous' WHERE informant='$uname');
mysql_query(UPDATE  . $table_prefix.stories SET aid='$anonymous'
WHERE aid='$uname');
mysql_query(UNLOCK TABLES);

global $uid, $uname, $name, $url, $email, $femail, $pass, $company,
$bio, $description, $address, $city, $province, $postcode, $phone, $fax,
$tollfree, $otherphone, $cat;

$sql = insert into .$table_prefix.users
(name,uname,email,femail,url,pass,company,bio,description,address,city,provi
nce,postcode,phone,fax,tollfree,otherphone,cat,conversionflag) values
('$name','$uname','$email','$femail','$url','$pass','$company','$bio','$desc
ription','$address','$city','$province','$postcode','$phone','$fax','$tollfr
ee','$otherphone','$cat','1');

if ($user_dblocation)
{
mysql_select_db($user_dbname) or die (Unable to select
database);
mysql_query(lock tables  . $table_prefix.users WRITE);
$result = mysql_query($sql);
mysql_query(unlock tables);
mysql_select_db($dbname) or die (Unable to select
database);
}
else
{
mysql_query(lock tables  . $table_prefix.users WRITE);
$result = mysql_query($sql);
mysql_query(unlock tables);
}

if (!$result)
{
echo mysql_errno(). : .mysql_error(). br /;
return;
}

html_header_location(admin.php?op=adminMain);
echo mysql_error();
break;




Re: [PHP] Storing/passing variables through multiple-partfunction/casestatement

2002-10-14 Thread Verdon Vaillancourt

I have to get the data from table1, delete the data from table1, put the
data into table2. I'm either not getting the data from table1 or am not
passing it to table2, I'm not sure which.

On 10/14/02 6:37 PM, John W. Holmes [EMAIL PROTECTED] wrote:

 INSERT INTO table2 SELECT * FROM table1 WHERE ...
 DELETE FROM table1 WHERE ...
 
 Where are you stuck?
 
 ---John Holmes...
 
 -Original Message-
 From: Verdon Vaillancourt [mailto:[EMAIL PROTECTED]]
 Sent: Monday, October 14, 2002 4:31 PM
 To: PHP-General
 Subject: [PHP] Storing/passing variables through multiple-part
 function/casestatement
 
 Hi,
 
 I¹m trying to cobble together a case where where data is retrieved
 from
 one
 row of a mySQL table, the row is deleted, the retrieved data is
 inserted
 into a new row in different table. Most of my code seems to be working
 (I
 think the data is being retrieved, the old row is being deleted, the
 new
 row
 is being created) but I am not getting a grip on how to pass the
 retrieved
 data into the sql insert statement for the new row in the second
 table.
 I¹m
 sure I¹m missing something very basic and would appreciate any help
 extended. The case statement as is now, is below.
 
 TIA, verdon
 
 Ps. Please cc me in any answer to the list as I am on digest mode
 
 case finishPending:
 if ($user_dblocation)
 {
 @mysql_select_db($user_dbname) or die (Unable to select
 database);
 
 $result = mysql_query(select uid, uname, name, url,
 email,
 femail, pass, company, bio, description, address, city, province,
 postcode,
 phone, fax, tollfree, otherphone, cat AS uid, uname, name, url, email,
 femail, pass, company, bio, description, address, city, province,
 postcode,
 phone, fax, tollfree, otherphone, cat from  .
 $table_prefix.users_que
 where uid='$approve_uid');
 list($uname) = mysql_fetch_row($result);
 
 mysql_query(lock tables  . $table_prefix.users_que
 WRITE);
 mysql_query(delete from  . $table_prefix.users_que
 where
 uid='$approve_uid');
 mysql_query(unlock tables);
 @mysql_select_db($dbname) or die (Unable to select
 database);
 }
 else
 {
 $result = mysql_query(select uid, uname, name, url,
 email,
 femail, pass, company, bio, description, address, city, province,
 postcode,
 phone, fax, tollfree, otherphone, cat AS uid, uname, name, url, email,
 femail, pass, company, bio, description, address, city, province,
 postcode,
 phone, fax, tollfree, otherphone, cat from  .
 $table_prefix.users_que
 where uid='$approve_uid');
 list($uname) = mysql_fetch_row($result);
 
 mysql_query(lock tables  . $table_prefix.users_que
 WRITE);
 mysql_query(delete from  . $table_prefix.users_que
 where
 uid='$approve_uid');
 mysql_query(unlock tables);
 }
 
 mysql_query(LOCK TABLES  . $table_prefix.stories WRITE);
 mysql_query(UPDATE  . $table_prefix.stories SET
 informant='$anonymous' WHERE informant='$uname');
 mysql_query(UPDATE  . $table_prefix.stories SET
 aid='$anonymous'
 WHERE aid='$uname');
 mysql_query(UNLOCK TABLES);
 
 global $uid, $uname, $name, $url, $email, $femail, $pass,
 $company,
 $bio, $description, $address, $city, $province, $postcode, $phone,
 $fax,
 $tollfree, $otherphone, $cat;
 
 $sql = insert into .$table_prefix.users
 
 (name,uname,email,femail,url,pass,company,bio,description,address,city,p
 ro
 vi
 nce,postcode,phone,fax,tollfree,otherphone,cat,conversionflag) values
 
 ('$name','$uname','$email','$femail','$url','$pass','$company','$bio','$
 de
 sc
 
 ription','$address','$city','$province','$postcode','$phone','$fax','$to
 ll
 fr
 ee','$otherphone','$cat','1');
 
 if ($user_dblocation)
 {
 @mysql_select_db($user_dbname) or die (Unable to select
 database);
 mysql_query(lock tables  . $table_prefix.users WRITE);
 $result = mysql_query($sql);
 mysql_query(unlock tables);
 @mysql_select_db($dbname) or die (Unable to select
 database);
 }
 else
 {
 mysql_query(lock tables  . $table_prefix.users WRITE);
 $result = mysql_query($sql);
 mysql_query(unlock tables);
 }
 
 if (!$result)
 {
 echo mysql_errno(). : .mysql_error(). br /;
 return;
 }
 
 html_header_location(admin.php?op=adminMain);
 echo mysql_error();
 break;
 
 
 
 


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




Re: [PHP] Storing/passing variables throughmultiple-partfunction/casestatement

2002-10-14 Thread Verdon Vaillancourt

On 10/14/02 11:07 PM, John W. Holmes [EMAIL PROTECTED] wrote:

 So you use the INSERT INTO ... SELECT ... to do the select from table 1
 and the insert into table 2. Then use a DELETE to erase the info from
 table 1. 
 
 Show your script so far, we can't help you much more without seeing what
 you're doing.
 
 ---John Holmes...
 

Hi John, Thanks for your input on this and a other question/answers I have
read on this list. I did get this working, though likely in not the most
elegant manner. 

For instance, if I understand your hint correctly, I didn't know you could
put INSERT INTO ... SELECT ... In the same statement!

I did have too much code in the 1st post I made on this topic and the
relevant parts likely got lost in the forest ;)  If you're curious, I have
quoted what is now working for me below.

Salut, verdon

if ($user_dblocation)
{
@mysql_select_db($user_dbname) or die (Unable to select
database);

$result = mysql_query(select uid, uname, name, url, email,
femail, pass, company, bio, description, address, city, province, postcode,
phone, fax, tollfree, otherphone, cat from  . $table_prefix.users_que
where uid='$approve_uid');
list($uid, $uname, $name, $url, $email, $femail, $pass,
$company, $bio, $description, $address, $city, $province, $postcode, $phone,
$fax, $tollfree, $otherphone, $cat) = mysql_fetch_row($result);

$sql = insert into .$table_prefix.users
(name,uname,email,femail,url,pass,company,bio,description,address,city,provi
nce,postcode,phone,fax,tollfree,otherphone,cat,conversionflag) values
('$name','$uname','$email','$femail','$url','$pass','$company','$bio','$desc
ription','$address','$city','$province','$postcode','$phone','$fax','$tollfr
ee','$otherphone','$cat','1');

if ($user_dblocation)
{
@mysql_select_db($user_dbname) or die (Unable to select
database);
mysql_query(lock tables  . $table_prefix.users WRITE);
$result = mysql_query($sql);
mysql_query(unlock tables);
@mysql_select_db($dbname) or die (Unable to select
database);
}
else
{
mysql_query(lock tables  . $table_prefix.users WRITE);
$result = mysql_query($sql);
mysql_query(unlock tables);
}

if (!$result)
{
echo mysql_errno(). : .mysql_error(). br /;
return;
}

mysql_query(lock tables  . $table_prefix.users_que WRITE);
mysql_query(delete from  . $table_prefix.users_que where
uid='$approve_uid');
mysql_query(unlock tables);
@mysql_select_db($dbname) or die (Unable to select
database);
}


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




[PHP] Dreaded expecting `T_VARIABLE' or... Error -- long post

2002-10-11 Thread Verdon Vaillancourt

Hi Apologies if this question has been answered before and I can't find it.
I have searched and although finding similar issues, I haven't been able to
fix. 

I have a file that creates a search for and then is supposed to post to
itself to retriev results. When I add the first function (the search form)
everything seems OK. The page renders, the select menus are populated from
my mySQL db. 

When I add the second function (the results). I start getting an error that
refers to a line number in my initial function that was previously OK. I
gather the error has something to do with syntax, but I can't find it.

I'll show some examples and then detail the error.

My intial code that creates the search form and works is:


PHP:



// Handles session initialization

include(open_session.php);

if(!isset($mainfile))

{
  include(mainfile.php);
}

// Global configuration data
include(config.php);

// Generates page header
include (header.php);

function sform() {

include(config.php);

$box_title = Search Form;

$box_stuff = table width=\100%\trtd align=\left\;

$box_stuff .= span class=\finePrint\Search hints can go
here/span/td/tr/table;

$box_stuff .= 

centerform action=\./search_users.php\ method=\post\

tabletrtd colspan=3 align=\left\h4Search for:/h4/td/tr

trtd align=\left\font size=\-1\Company/font/tdtd
align=\left\font size=\-1\Category/font/tdtd
align=\left\font size=\-1\City/font/td/tr

trtd align=\left\ valign=\top\input name=\company\/tdtd
align=\left\ valign=\top\

select name=\cat\ size=\7\ multiple\n;


$cat_result = mysql_query(select cat, catkey, cattext, count(cat) AS
num_type FROM  . $table_prefix.users LEFT JOIN
 . $table_prefix.users_cat ON cat=catkey GROUP BY cattext ORDER BY
cattext);

$categories = mysql_fetch_array($cat_result);

if ($categories) {

while ($c2 = mysql_fetch_array($cat_result)) {

$num_type = $c2[num_type];

$box_stuff .= option name=\cat\ value=\$c2[catkey]\$c2[cattext] (
$num_type)/option;

}

}

$box_stuff .= 

/select

/td

td align=\left\ valign=\top\

select name=\city\ size=\7\ multiple\n;



$city_result = mysql_query(select city, count(city) AS num_type FROM
 . $table_prefix.users GROUP BY city ORDER BY city);

$cities = mysql_fetch_array($city_result);

if ($cities) {

while ($c3 = mysql_fetch_array($city_result)) {

$num_type3 = $c3[num_type];

$box_stuff .= option name=\city\ value=\$c3[city]\$c3[city] ($num
_type3)/option;

}

}

$box_stuff .= /select/td/tr\n;



$box_stuff .= 

trtd align=\left\ colspan=3 align=\center\input type=\submit\
value=\Search\ Note: searching for all can produce a large
page!/td/tr

/tableinput type=\hidden\ name=\op\ value=\search\ /

/form/center;



thememainbox($box_title, $box_stuff);

include(footer.php);

}



switch($op) {

case search:

search();

break;



default:

sform();

break;

  }






Now, when I add anything for the function search() , even a simple message
printed to the page such as:


PHP:



function search()

{

include('config.php');

global ;

$box_title = Search Results;

$box_stuff .= Results here;

thememainbox($box_title, $box_stuff);

include(footer.php);

}





I get the error: Parse error: parse error, expecting `T_VARIABLE' or `'$''
in /Library/WebServer/Documents/phpwebsite/search_users.php on line 45

BTW... line 45 is part of the initial funtion that was working before:


PHP:


$cat_result = mysql_query(select cat, catkey, cattext, count(cat) AS
num_type FROM  . $table_prefix.users LEFT JOIN
 . $table_prefix.users_cat ON cat=catkey GROUP BY cattext ORDER BY
cattext);

$categories = mysql_fetch_array($cat_result);

if ($categories) {

while ($c2 = mysql_fetch_array($cat_result)) {

$num_type = $c2[num_type];

$box_stuff .= option name=\cat\ value=\$c2[catkey]\$c2[cattext] (
$num_type)/option;

}  //THIS IS LINE 45

}




I feel that if I can get past this, I can likely get my actual search to
work. If you're curious, the following code is what I actually have in mind
for the search function. I just can't get far enough along to even test it.
I would surely appreciate any advice that anyone can extend.:


PHP:


function search() {

include(config.php);

global $company, $cat, $city, $catkey, $cattext, Order;

$box_title = Search Results;

if ($cat0) {

$classreq=AND catkey=$cat;

}

  if (!$Order) {

$Order=company;

}

$query = SELECT company, city, cat, catkey, cattext 

[PHP] Encrypting passwords in a flat file before import

2002-10-09 Thread Verdon Vaillancourt

Hi,

I hope this question isn't too basic...

I have a flat file (CSV) that I want to import into a mySQL db via
phpMyAdmin. The file has about 1200 rows and is in a format like:
value,value,password,value,value,etc
The passwords are in clear text. I need them to be encrypted in md5.

Is there any advice out there as to how I could process this flat-file
before I import into my db or after the fact?

Thanks, verdon
Ps. Please cc me if replying to list as I am on digest mode


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




[PHP] Trying to add table prefix variable to query

2002-09-10 Thread Verdon Vaillancourt

This query worked until I tried to add support for a table prefix in the
config file. Now it can¹t seem to find the table. Any pointers to what I am
doing wrong?

Thanks, v

Original query:
?php
...
include(config.php);

$open = mysql_pconnect($hostname,$user,$password);
mysql_select_db($db,$open);
$result = mysql($db,SELECT * FROM teams WHERE username =
'admin');
$i = 0;
$total_rows = mysql_numrows($result);

...
?

This is my query:
?php
...
include(config.php);

$open = mysql_pconnect($hostname,$user,$password);
mysql_select_db($db,$open);
$result = mysql($db,SELECT * FROM   . $table_prefix .  teams
WHERE username = 'admin');
$i = 0;
$total_rows = mysql_numrows($result);

...
?

This is my config file:
?php

$db = sports;
$hostname = localhost;
$password = mypassword;
$user = myuser;
$table_prefix = ccl_;

?

This is my table name:
ccl_teams

This is the error:
Warning: Supplied argument is not a valid MySQL result resource in...



Re: [PHP] Trying to add table prefix variable to query (solved)

2002-09-10 Thread Verdon Vaillancourt

Doh,... Thanks to all who replied so promptly with similar answers.

:) vern


On 9/10/02 9:13 AM, Jacob Miller [EMAIL PROTECTED] wrote:

 Make sure you don't have a space before the 2nd half of the table name
 
 Wrong:
 
 .. FROM  . $table_prefix .  teams
 
 this will produce FROM ccl_ teams
 
 Right:
 
 .. FROM  . $table_prefix . teams
 
 this will product FROM cc_teams
 
 - jacob


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




[PHP] Script for drawing

2002-09-06 Thread Verdon Vaillancourt

Hi List,

Is anyone aware of a script that would allow an image file to be read (like
a map) and then allow a user to add a dot (or any other shape) and/or text
to the image and then save the resulting image.

TIA, verdon


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




[PHP] Test if URL is alive before including a remote JS

2002-07-02 Thread Verdon Vaillancourt

Hi :)

Given I have some content embedded on my page by calling a remote JS and
occasionally the URL for the remote script is down causing my page to be
slow or fail, can I use the following example as a means to test and timeout
the remote server and skip the embedded JS, if the remote server isn't
responding properly?

?php
$fp = fsockopen (www.theweathernetwork.com, 80, $errno, $errstr, 5);
if (!$fp) {
echo sorry, not available;
} else {
echo script language=\JavaScript\ type=\text/javascript\
  !-- var city = \Muskoka_ON\; //--
  /script
  script language=\javascript\ type=\text/javascript\
  src=\http://www.theweathernetwork.com/weatherbutton/test.js\;
  /script;

}
?


TIA, verdon


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




Re: [PHP] Test if URL is alive before including a remote JS

2002-07-02 Thread Verdon Vaillancourt

Thanks Kevin,

Do I need to include 'fclose ($fp);' in there somewhere in this case?


On 7/2/02 3:41 PM, Kevin Stone [EMAIL PROTECTED] wrote:

 Or just fopen() would work fine.
 -Kevin
 
 - Original Message -
 Hi :)
 
 Given I have some content embedded on my page by calling a remote JS and
 occasionally the URL for the remote script is down causing my page to be
 slow or fail, can I use the following example as a means to test and
 timeout
 the remote server and skip the embedded JS, if the remote server isn't
 responding properly?
 
 ?php
 $fp = fsockopen (www.theweathernetwork.com, 80, $errno, $errstr, 5);
 if (!$fp) {
 echo sorry, not available;
 } else {
 echo script language=\JavaScript\ type=\text/javascript\
   !-- var city = \Muskoka_ON\; //--
   /script
   script language=\javascript\ type=\text/javascript\
   src=\http://www.theweathernetwork.com/weatherbutton/test.js\;
   /script;
 
 }
 ?


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




Re: [PHP] MacOSX / php.ini newbie question

2002-06-04 Thread Verdon Vaillancourt

Hi John,

Thanks for answering. Apparently not. I have tried both the builds provided
by Marc (well respected) at http://www.entropy.ch/software/macosx/ and the
default build included with Apple's MacOSX (10.1.4). Neither include these
files. Marc says that the file is not included and just instructs to write
it... I just can't find an example of the format. I only need a couple of
lines in it for the scripts I wish to run, and know what they are. I am just
unsure if the php.ini file needs specific lines to open and close, or if I
can just create a file with the declarations I require (and nothing else)
and save it in the correct location.

Cheers, verdon


On 6/4/02 11:26 AM, 1LT John W. Holmes [EMAIL PROTECTED] wrote:

 Did a php.ini-dist or php.ini-recommended file come with your installation
 files? Locate those, edit them accordingly, and save it as php.ini in
 /usr/lib/
 
 ---John Holmes...
 
 - Original Message -
 From: Verdon Vaillancourt [EMAIL PROTECTED]
 To: Peter [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Tuesday, June 04, 2002 9:04 AM
 Subject: Re: [PHP] MacOSX / php.ini newbie question
 
 
 Hi Peter, Thanks for the reply.
 
 Yes, I have searched using both locate and find in the terminal, and
 sherlock, though I don't think sherlock will find anything in system
 folders. BTW... I updated my locate db before doing the search.
 
 :) verdon
 
 
 On 6/3/02 10:19 PM, Peter [EMAIL PROTECTED] wrote:
 
 have you tried doing a general search for that file? ie search all of ur
 hdd
 ...
 
 -Original Message-
 From: Verdon Vaillancourt [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, 4 June 2002 11:15 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] MacOSX / php.ini newbie question
 
 
 Hi Apologies in advance if this question is simple. I haven't been able
 to
 find an answer...
 
 Is there no php.ini file in a php 4.1.2 install on MacOSX 10.1.4 (client
 not
 server) ? My php info/test page says that the path to the configuration
 file
 (php.ini) file is '/usr/lib', but it is not there (or anywhere else
 according to locate)
 
 Is this a file I can create myself or is there an example to be had
 somewhere?
 
 TIA, verdon
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


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




Re: [PHP] MacOSX / php.ini newbie question

2002-06-04 Thread Verdon Vaillancourt

Thanks Clay :)  got it!



On 6/4/02 1:49 PM, Clay Loveless [EMAIL PROTECTED] wrote:

 Verdon,
 
 Maybe you didn't see my response to your message yesterday, since I saw a
 few more posts from you after I replied wondering where you can get a
 php.ini file.
 
 Just go to http://www.php.net/downloads
 
 Download the .tar.gz file for the version you're using from entropy.ch
 
 Within, you will find php.ini-dist and php.ini-recommended. Move those
 out of the directory of unpacked PHP source, and delete the rest. (You won't
 need it, since you have the entropy.ch version.)
 
 Look through the two files.
 Decide which one you like.
 Edit if necessary.
 Rename to php.ini
 Upload to your /usr/lib directory on your server.
 
 That's it!
 
 -Clay
 
 
 -- Forwarded Message
 From: Clay Loveless [EMAIL PROTECTED]
 Date: Mon, 03 Jun 2002 19:11:10 -0700
 To: PHP-General [EMAIL PROTECTED]
 Subject: Re: [PHP] MacOSX / php.ini newbie question
 
 Verdon,
 
 I'm a fellow PHP'er on Mac OS X (Server) 10.1.4. : )
 
 You need to download the full distribution from php.net/downloads ... In
 there you will find a php.ini-dist file and php.ini-recommended file.
 
 Pick one that you like, edit as needed with BBEdit Lite (NOT TextEdit!),
 rename to php.ini and upload to /usr/lib. Restart Apache, and the newly
 installed php.ini file will be read in at that time.
 
 Good luck!
 
 -Clay
 
 
 From: Verdon Vaillancourt [EMAIL PROTECTED]
 Date: Mon, 03 Jun 2002 21:15:27 -0400
 To: [EMAIL PROTECTED]
 Subject: [PHP] MacOSX / php.ini newbie question
 
 Hi Apologies in advance if this question is simple. I haven't been able to
 find an answer...
 
 Is there no php.ini file in a php 4.1.2 install on MacOSX 10.1.4 (client not
 server) ? My php info/test page says that the path to the configuration file
 (php.ini) file is '/usr/lib', but it is not there (or anywhere else
 according to locate)
 
 Is this a file I can create myself or is there an example to be had
 somewhere?
 
 TIA, verdon
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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




Re: [PHP] MacOSX / php.ini newbie question

2002-06-04 Thread Verdon Vaillancourt

Hi Peter, Thanks for the reply.

Yes, I have searched using both locate and find in the terminal, and
sherlock, though I don't think sherlock will find anything in system
folders. BTW... I updated my locate db before doing the search.

:) verdon


On 6/3/02 10:19 PM, Peter [EMAIL PROTECTED] wrote:

 have you tried doing a general search for that file? ie search all of ur hdd
 ...
 
 -Original Message-
 From: Verdon Vaillancourt [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, 4 June 2002 11:15 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] MacOSX / php.ini newbie question
 
 
 Hi Apologies in advance if this question is simple. I haven't been able to
 find an answer...
 
 Is there no php.ini file in a php 4.1.2 install on MacOSX 10.1.4 (client not
 server) ? My php info/test page says that the path to the configuration file
 (php.ini) file is '/usr/lib', but it is not there (or anywhere else
 according to locate)
 
 Is this a file I can create myself or is there an example to be had
 somewhere?
 
 TIA, verdon
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


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




[PHP] MacOSX / php.ini newbie question

2002-06-03 Thread Verdon Vaillancourt

Hi Apologies in advance if this question is simple. I haven't been able to
find an answer...

Is there no php.ini file in a php 4.1.2 install on MacOSX 10.1.4 (client not
server) ? My php info/test page says that the path to the configuration file
(php.ini) file is '/usr/lib', but it is not there (or anywhere else
according to locate)

Is this a file I can create myself or is there an example to be had
somewhere?

TIA, verdon


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