RE: [PHP] Simple question: $_POST

2005-01-15 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

 To view the terms under which this email is
 distributed, please go to
 http://disclaimer.leedsmet.ac.uk/email.htm
 
 
 
  -Original Message-
  From: Stuart Felenstein
  Sent: 14/01/05 13:48
  
  When using $_POST vars is it required that a form
 is
  used ?
  
  In other words I can create an href link and echo
  variable and pick them up using $_GET in the
 following
  page. 
  
  No so with $_POST ?
 
 Short answer: correct.
 
 Long answer: well, this being PHP, there's pretty
 much always ways and
 means, e.g. cURL. 
 
 (I suspect, from the way you've asked the question,
 though, the short answer
 probably suffices! ;)
 
 Cheers!
 
 Mike
 
Yes, the short answer sufficed, though the different
responses were great and appreciated. I did not know
about java alternatives or cURL or other php
extensions.  More alternatives for the future.

Stuart

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



[PHP] Simple question: $_POST

2005-01-14 Thread Stuart Felenstein
When using $_POST vars is it required that a form is
used ?

In other words I can create an href link and echo
variable and pick them up using $_GET in the following
page. 

No so with $_POST ?


Stuart

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



[PHP] Question: arrays and form elements

2004-12-30 Thread Stuart Felenstein
Generally, when I set up a form where, for example,
I'll be taking multiple selections from a list I would
set the variable / element name as myvar[].  So I
have the brackets [] after the variable name to make
it an array. 

What I want to know is there a way to get around the
use  of this syntax ? If the variable name was just
myvar (no brackets) is there a way for me to still
grab all the selections and put them into an array ?

Hope this question is clear.

Thank you
Stuart 

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



Re: [PHP][SOLVED] Question: Repopulating form parameters

2004-12-13 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:


 I think will call it a day for this thread.

As I suspected a loop was needed to make this work. 
In the event that there are other idiots, such as
myself, that don't immediately figure out the exact
logic I'll post the code:

//The sql is Adodb syntax:
while(!$rsinds-EOF){
?
option value=?php echo
$rsinds-Fields('CareerIDs')?

//I could test for $inds here, doesn't seem to make a
//difference
?php foreach ($inds as $a) { ? 
?php if ($rsinds-Fields('CareerIDs')== $a) {echo
SELECTED;} } ?
?php echo $rsinds-Fields('CareerCategories') ?
/option
 ?php
$rsinds-MoveNext();
  }
  $rsinds-MoveFirst();

Stuart

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



RE: [PHP] Question: Repopulating form parameters

2004-12-13 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

   If in doubt, print it out (TM)
   
 echo '$Indbr', $Indbr, $Ind;
   
  $Ind
  '1','2','3','4'
  '1','2','3','4'
  
  Funny, they are both the same.
 
 Both?  There are three things printed out there,
 so both cannot be
 right.  2 of the 3 can be the same, or all of them
 can be the same, but not
 both.
 
 Cheers!
 
 Mike

I thought you were ignoring my posts ?
The issue was the difference between double and single
quotes. 
Stuart

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



Re: [PHP] Question: Repopulating form parameters

2004-12-13 Thread Stuart Felenstein

--- David Robley [EMAIL PROTECTED] wrote:

 On Mon, 13 Dec 2004 00:56, Stuart Felenstein wrote:
 
  
  --- Jason Wong [EMAIL PROTECTED] wrote:
  
  
  If in doubt, print it out (TM)
  
echo '$Indbr', $Indbr, $Ind;
  
  $Ind
  '1','2','3','4'
  '1','2','3','4'
  
  Funny, they are both the same.
 
 I think you are missing the point Jason was trying
 to make, which is the
 difference between '$Ind' and $Ind. If you look
 again, you will see that
 those are handled differently.
 
If you read the post Jason suggested I print out using
both single and double quotes.
Regardless that has very little to do with my
question.

Here is just another variation of my multiple select
list. 
option value=?php echo
$rsinds-Fields('CareerIDs')??php if
($rsinds-Fields('CareerIDs')== 5) {echo SELECTED;}
??php echo
$rsinds-Fields('CareerCategories')?/option

Here I was just testing with a specific value.
the line == 5 will set the value SELECTED correctly.
 If I put in 5, 6, or '5,','6', etc, I get an error. 
However, I don't believe that line works for multiple
values. What works is still a mystery to me.

Stuart

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


Re: [PHP] Question: Repopulating form parameters

2004-12-13 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

  Here is just another variation of my multiple
 select
  list.
  option value=?php echo
  $rsinds-Fields('CareerIDs')??php if
  ($rsinds-Fields('CareerIDs')== 5) {echo
 SELECTED;}
  ??php echo
  $rsinds-Fields('CareerCategories')?/option
 
  Here I was just testing with a specific value.
  the line == 5 will set the value SELECTED
 correctly.
   If I put in 5, 6, or '5,','6', etc, I get an
 error.
  However, I don't believe that line works for
 multiple
  values. What works is still a mystery to me.
 
 For heaven's sake, do you even know what the HTML
 *should* look like? Did you 
 construct an example to look at? If you're unable to
 construct your own 
 example just look at someone else's, go find a site
 that has multi-select 
 listboxes with pre-selected values and examine the
 HTML source.
 
heaven's sake ? bit over dramatic. The code above is
my created html. I've created a number of them, both
from a table and just listing out some options. To
repeat they all work . Yet all seem to have little in
common when the values are dynamic and from an array. 


Stuart

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


Re: [PHP] Question: Repopulating form parameters

2004-12-12 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

  Close but no cigar.  Since $Ind is already
 imploded my
  thinking is it need not be incremented in the echo
  statement ?
 
 You tell me, print_r() and var_dump() it before you
 use it and decide whether 
 it is correct.
 
 One final thing: '$Ind' is not the same as $Ind.
 


If I choose 1, 2 , 3 then

print_r($Ind); returns
'1','2','3'
This looks okay.

I'm passed the parsing errors. Semi colon was me
trying to stop parsing errors.  

?php
while($row = mysql_fetch_array($inds, MYSQL_BOTH)) {
echo 'option value='.$row['CareerIDs'].'';
if (!(strcmp($row_rsInd['CareerIDs'], $Ind)))
{echo SELECTED;}
echo $row['CareerCategories'].'/option';

I could not find a difference with '$Ind', or $Ind,
except I would think '$Ind' is correct, since  
would be a literal string.

Any more hints ? :)

Stuart

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



Re: [PHP] Question: Repopulating form parameters

2004-12-12 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

  I'm pretty sure I need to loop through the $_Get
 of
  the array.   Not sure , and haven't found anything
  that shows this.
 
 Yes, you need to reference $_GET to see whether an
 option was selected and 
 change the echo above accordingly.
 

Still stuck on this one.  I know I'm doing something
wrong and wouldn't mind some correction:

Code now:

if (count($Ind)  0 AND is_array($Ind)) {
$Ind = '.implode(',', $Ind).';

select name=Ind[] size=8 multiple=multiple
id=Ind[] 
?php
$selected = $_GET['Ind'];
while($row = mysql_fetch_array($inds, MYSQL_BOTH)) {
if ($selected==$row['CareerIDs']) echo ' selected';
echo 'option
value='.$row['CareerIDs'].''.$row['CareerCategories'].'/option';

}
?

Stuart

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



Re: [PHP] Question: Repopulating form parameters

2004-12-12 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

 On Sunday 12 December 2004 18:15, Stuart Felenstein
 wrote:
 
  Still stuck on this one.  I know I'm doing
 something
  wrong and wouldn't mind some correction:
 
 Did you mockup some test HTML in a wysisyg editor as
 suggested?

Yep like this :

select name=select size=10 multiple
option value=1 ?php if (!(strcmp(1,
None))) {echo SELECTED;} ?Black/option
option selected value=2 ?php if
(!(strcmp(2, None))) {echo SELECTED;}
?Blue/option
option value=3 ?php if (!(strcmp(3,
None))) {echo SELECTED;} ?Red/option
option value=4 ?php if (!(strcmp(4,
None))) {echo SELECTED;} ?Orange/option
option value=5 ?php if (!(strcmp(5,
None))) {echo SELECTED;} ?Purple/option
option selected value=6 ?php if
(!(strcmp(6, None))) {echo SELECTED;}
?Brown/option
  /select

Problem is arrays are hanging me up.

 Did you compare the mockup HTML with that produced
 by your code above?

//mockup 
option value=?php echo
$row_rsInd['CareerIDs']??php if
(!(strcmp($row_rsInd['CareerIDs'], 2))) {echo
SELECTED;} ??php echo
$row_rsInd['CareerCategories']?/option


//Attempt, problems with parsing errors:

select name=Ind[] size=8 multiple=multiple
id=Ind[] 
?php
while($row = mysql_fetch_array($inds, MYSQL_BOTH)) {
echo 'option value='.$row['CareerIDs'].'';
if (!(strcmp($row_rsInd['CareerIDs'], '$Ind')));
{echo SELECTED;}
.$row['CareerCategories'].'/option';
}


Close but no cigar.  Since $Ind is already imploded my
thinking is it need not be incremented in the echo
statement ?

Stuart

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



Re: [PHP] Question: Repopulating form parameters

2004-12-12 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

 
 If in doubt, print it out (TM)
 
   echo '$Indbr', $Indbr, $Ind;
 
$Ind
'1','2','3','4'
'1','2','3','4'

Funny, they are both the same.

Stuart

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


Re: [PHP] Question:maybe urldecode

2004-12-11 Thread Stuart Felenstein

--- Richard Lynch [EMAIL PROTECTED] wrote:

  I made the correction , using $_GET now.  Values
 are
  printing out, aside from the select lists (arrays)
  which print out as array.
 
 Yes.
 
 An array will print as Array
 
 You'll need to dig into the Array for what you need,
 or implode it, or
 something.
 
I'm imploding the arrays and the correct values are
returned.  Still this is what I'm struggling with:

If I put this querystring back into the url:

http://www.lurkingforwork.com/myownsearch.php?Ind[]=1JTitle=City=WinchesterDays=Recs=15Submit=Submit

The textfield City is repopulate with the value -
Winchester.
The select list Ind[] though is not.  

I thought perhaps I need to do a loop for the Ind[]
value, so I tried this:

select name=Ind[] size=8 multiple=multiple
id=Ind[] value=?php foreach ($Ind as $value) {
echo $value;}?

I was wrong there as well.  
Just to repeat.  I want to take the query string
created from the user's choices / search parameters
and repopulate the form by applying the querystring on
the form.  www.mysite.com/search?querystring.

Does this make sense ? Am I being clear in what I'm
asking ?

Stuart

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



[PHP] Question: Repopulating form parameters

2004-12-11 Thread Stuart Felenstein
I'm hoping that this question will be more succinct.
I am trying to repopulate a search form with a user's
chosen paramters.  I am running into a problem with
multiple select lists

First , this is the element when the form is first
presented to the user:

select name=Ind[] size=8 multiple=multiple
id=Ind[] 
?php while($row = mysql_fetch_array($inds,
YSQL_BOTH)) { echo 'option
value='.$row['CareerIDs'].''.$row['CareerCategories'].'/option';
}
?

So the element's option are taken from a table. 

Now I am grabbing the array and can print out the
chosen values correctly, either using an implode:

if (count($Ind)  0 AND is_array($Ind)) {
$Ind = '.implode(',', $Ind).';
}

or a for loop:

if (isset($Ind)) {
$j = count($Ind);
for($i=0; $i$j; $i++)
print_r($Ind[$i]);
}

What I can't do is getting the options that were
chosen to be highlighted in the select list.  
i.e if there are 5 options for user to choose from:
1-Banking 2-Arts 3-I.T. 4-Accounting 5-Retail

And user chooses 1-Banking and 5-Retail, when I
reapply the query string I want those 2 to be
highlighed in the options list.  
It is working fine for textfield.  

?Ind%5B%5D=1Ind%5B%5D=2JTitle=City=BronxDays=Recs=15Submit=Submit

If I apply the above query string, Bronx will be
populated in the Citytextfield
Not so, with the Ind[] array.

Anyone know what I am talking about ?

Stuart

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



Re: [PHP] Question: Repopulating form parameters

2004-12-11 Thread Stuart Felenstein
--- [EMAIL PROTECTED] wrote:

 you (just) need to mark the previously chosen items
 as selected in 
 the repopulated list. the highlighting part is a
 basic html/form 
 issue. i.e., if you have questions on this you
 should look at how, on 
 a simple (html-only) form, an item on a list is
 marked (highlighted) 
 as the default. obviously you have set up your code
 so that you know 
 what's been selected previously and then put out the
 necessary html 
 when you repopulate.
 
This makes sense, however I'm still spacing out trying
to figure out then where I place the option value
selected in this html / php code:

select name=Ind[] size=8 multiple=multiple
id=Ind[] 
?php while($row = mysql_fetch_array($inds,
MYSQL_BOTH)) { echo 'option
value='.$row['CareerIDs'].''.$row['CareerCategories'].'/option
'; ?

I'm pretty sure I need to loop through the $_Get of
the array.   Not sure , and haven't found anything
that shows this.

Stuart

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



Re: [PHP][Kill Thread] Question:maybe urldecode

2004-12-11 Thread Stuart Felenstein

--- Stuart Felenstein [EMAIL PROTECTED] wrote:

I am ending this thread. 

Stuart

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


RE: [PHP] Question:maybe urldecode

2004-12-10 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

 Please, stop giving us vague, generalized
 descriptions of your application,
 and how it is or isn't working right, and vague,
 generalized descriptions
 of the data it's supposed to be working with. 

I don't believe that the description of my issue was
vague. I provided not only what was expected but an
example.  It's still reasonable to believe that there
could only be a limited number of factors involved as
to what is missing from my script.  

 as it's become increasingly clear
 that you're just flailing
 around in the dark firing buckshot at imagined
 spooks with no real idea of
 what you're doing.

No real idea of what I'm doing ?  

 You might like to start with GET (and POST)
 parameters, as the first
 paragraph quoted above shows that you have no real
 understanding of this
 most basic concept, which is a key topic you must be
 able to comprehend if
 you're using forms.
 
I understand GET and POST.  
Sorry you feel that way.  Perhaps I have made a pain
of myself on the list.  I'm not really sure what the
requirements of the list are, to ask questions. 
Regardless I must have not met them.  I'll spare you
the trouble of avoiding my posts by not making any.

Thank you,
Stuart

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



RE: [PHP] Forms and viewing Text Area

2004-12-10 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

 echo nl2br(htmlspecialchars($text)) is my usual
 mantra for this.
 
nl2br will give you back the correct formatting, but
will leave br/'s in the output.

I just went through this issue the other day, what I
found worked for me was:

htmlspecialchars('string'),ENT_NOQUOTES);
Note- check the available parameters for
htmlspecialchars. I used ENT_NOQUOTES because I wanted
to preserve the single and double quotes in my text.

Hope this helps.

Stuart

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



Re: [PHP] Question:maybe urldecode

2004-12-10 Thread Stuart Felenstein
--- Jason Wong [EMAIL PROTECTED] wrote:

 Now in an earlier response I asked you to track your
 variables and see at 
 which point they cease to contain what you expect
 them to contain. Did you do 
 that? If you're not doing *your* part to help solve
 *your* problem then what 
 are you expecting from the list? Some magic hands?
 Maybe if you've been a 
 good boy and ask Santa nicely ...
 
I'm working through this logically, however logic
equates in my universe.  Tracking the variables is
meaningless right now since I haven't set them up in
the search form, outside of naming the form elements. 
When they get passed to the next page (results) they
exist  I've printed out the arrays, the
(SERVER(QUERY_STRING), the resultset, and the array
that is formed from exploding and imploding said
QueryString.

Where I now have done is added this code block into
the search page:

?php
$queryString = ($_SERVER['QUERY_STRING']);
$Ind = $_POST['Ind'];
$State = $_POST['State'];
$TType = $_POST['TType'];
$JTitle = $_POST['JTitle'];
$City = $_POST['City'];
$Days = $_POST['Days'];
$Recs = $_POST['Recs'];
?
It is not complete obviously. I'm working along the
lines of parsing the query string, and getting the
elements into the correct variables.  I imagine that
is only one way of accomplishing the task.  Once the
string values are parsed into the variables I can then
echo out the values in each form element, aka:

select name=Days id=Days title=?php
echo((isset($_POST[Days]))?$_POST[Days]:) ?

Currently to test and work through all of this I have
the search page set to action. The QueryString
though does return the correct values.

I'm sure none of this makes sense.  

Thank you,
Stuart

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



RE: [PHP] Question:maybe urldecode

2004-12-10 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:
 
 AARRGGHHH!  Vague, generalized, woolly!!
 
 SHOW US the relevant bits of code.  SHOW US what you
 get printed out,
 especially anything that isn't what you expect, and
 tell us exactly what you
 did expect.

 SPECIFICS, man, SPECIFICS!!
 
 SHOW US the form -- we can't even begin to guess
 what data your script will
 see without knowing what the form says.  Preferably
 tell us *exactly* what
 each control on the form was set to when you
 submitted it.

Each element takes the user input and passes it on to
the results page. What I also  want though it to put
the querystring back into the search page and have the
elements echo out the values chosen.

Let me demonstrate with one element:

tdform name=form1 id=form1 method=get
action=
select name=Ind[] size=8 multiple=multiple
id=Ind[]
?php   while($row = mysql_fetch_array($inds,
MYSQL_BOTH)) {echo 'option
value='.$row['CareerIDs'].''.$row['CareerCategories'].'/option';
} ?

Now what I've added: $Ind = $_POST['Ind'];

 
  $queryString = ($_SERVER['QUERY_STRING']);
 
 What is in $queryString after this? var_dump() it
 and show us the result.

This is the var_dump of the query string after I've
made some selections in the page.
string(80)
Ind%5B%5D=2Ind%5B%5D=3Ind%5B%5D=4JTitle=WebCity=Days=Recs=15Submit=Submit

 Is it what you expect?  If not, what *did* you
 expect?
Yes, this is what I expect.
 
 What is in $_POST before you start the next batch of
 assignments? var_dump()

Nothing is printing out on $_POST['var'] or $var
s makes sense.

I hope this is clearer with more relevant information.

Stuart 

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



Re: [PHP] Question:maybe urldecode

2004-12-10 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

  Nothing is printing out on $_POST['var'] or $var
  s makes sense.
 
 Now why are you looking in $_POST for your form
 values? They're in $_GET. You 
 said earlier that you understood POST and GET?

I made the correction , using $_GET now.  Values are
printing out, aside from the select lists (arrays)
which print out as array.

Now I can get the correct values into the text fields,
so they are working, but the drop downs and the select
lists are not.   

I'm not sure, if I need to parse the
(Server(QueryString) or implode the arrays ?This is
the big question for me.

Here is all the relevant code. Perhaps someone can see
what it is I'm doing wrong:

?
?php
$queryString = ($_SERVER['QUERY_STRING']);
$Ind = $_GET['Ind'];
$State = $_GET['State'];
$TType = $_GET['TType'];
$JTitle = $_GET['JTitle'];
$City = $_GET['City'];
$Days = $_GET['Days'];
?

form name=form1 id=form1 method=get
action=?=$PHP_SELF?

select name=Ind[] size=8 multiple=multiple
id=Ind[] 
?php
while($row = mysql_fetch_array($inds, MYSQL_BOTH)) {
echo 'option   
value='.$row['CareerIDs'].''.$row['CareerCategories'].'/option';

select name=State[] size=8 multiple=multiple
id=State[]
?php
while($row = mysql_fetch_array($stas, MYSQL_BOTH)) {
echo 'option 
value='.$row['StateID'].''.$row['States'].'/option

select name=TType[] size=8 multiple=multiple
id=TType[]
?php
while($row = mysql_fetch_array($terms, MYSQL_BOTH)) {
echo 'option   
value='.$row['TaxTermID'].''.$row['TaxTerm'].'/option';

input name=JTitle type=text id=JTitle
value=?php echo $JTitle ?
input name=City type=text id=City value=?php
echo $City ?

select name=Days id=Days 
option value=Please Select/option
?php
while($row = mysql_fetch_array($days, MYSQL_BOTH)) {
echo 'option   
value='.$row['DaysID'].''.$row['Days'].'/option';

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



[PHP] Question: urldecode

2004-12-09 Thread Stuart Felenstein
In my search page, the url returned comes back with
the ..err I forget what it's called, but query string
looks like this: %5B%5D=3.  I think the %5B and 5D
should be [].

What I think is needed is rawurldecode.  I've looked
through my code and think it belongs somewhere in this
block:

$queryString_rsVJ = ;
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode(, $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
if (stristr($param, pageNum_rsVJ) == false  
stristr($param, totalRows_rsVJ) == false) {
  array_push($newParams, $param);
}
  }
  if (count($newParams) != 0) {
$queryString_rsVJ =  .
htmlentities(implode(, $newParams));
  }
}

would doing something like this make sense?:

$queryString_rsVJ =  .
htmlentities(rawurldecode(implode(, $newParams)));

Feedback appreciated.

Thank you 
Stuart

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



RE: [PHP] Question: urldecode

2004-12-09 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

 Are you seeing the URL-encoded version *only* in
 your browser's
 Address/Location bar?  If so, that's perfectly
 normal and nothing to worry
 about -- it should be automatically decoded by the
 Web server before being
 passed to PHP.

 
 If you're seeing the encoded version actually in
 your PHP script, that
 sounds like a major problem, possibly indicating a
 missing urldecode() or
 extraneous urlencode() -- in which case, please post
 a more detailed
 analysis of your problem, examples of the unwanted
 behaviour, and the
 relevant portions of script.
 
I have no idea about what it means to see the encoded
version in my script. I have only one urldecode in the
script:

a href=SearchJobDetails.php?JobID=?php echo
urldecode($row_rsVJ['JobID']);?

No urlencodes anywhere. 
I'll assume it's decoded properly before going to php
because the script runs fine.  I just know that I've
seen the hex's normally converted in the browser bar.

Further, I was assuming I should add the urldecode to
the query string.  As I had posted originally.  From
the example in the manual it appears I might to pass
the params through a urldecode counter loop.  

Lastly, I wasn't concerned about the hex code, but I
just made some reconnections of scripts.  Users can
save their search parameters.  I am saving the query
string.  Now I had this set up before and the way it
was working , is when the user wanted to view or
edit their saved searches, the search page would come
back with all the parameters filled in including
shaded parameters in things like mult select lists and
menu dropdowns.  It's not working that way now , so my
first suspicion is perhaps the hex is effecting it.

I can post more of the script if that makes sense.

Stuart

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



RE: [PHP] Question:maybe urldecode

2004-12-09 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

  Lastly, I wasn't concerned about the hex code, but
 I just made some reconnections of scripts.  Users
 can save their search parameters.  I am saving the
 query string.  Now I had this set up before and the 
 way it was working , is when the user wanted to   
 view or edit their saved searches, the search page  
 would come back with all the parameters filled in   
 including shaded parameters in things like multi
 select lists and menu dropdowns.  It's not working  
 that way now so my first suspicion is perhaps the
hex  is effecting it.


I'm not sure if this particular is a matter of
debugging.  There is a different behaviour going on
and now I'm not sure if it would have anything to with
the hex.  The textfields in the query string are just
the variable name = value.  

Basically I'm throwing this out though since I'm
wondering if there is something that should be in the
search script , that when I apply a query string to it
would fill in the field (like magic hands)

As an example, if you click on the link , you'll see
industry has 2 choices selected , and city has a
value.
Now I can't reproduce this with my new script.

http://www.lurkingforwork.com/LFWSearch.php?s_Industry[]=2s_Industry[]=3s_LocationCity=Bronxs_JobTitle=s_PostStart=VendorJobsPageSize=


Stuart

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



Re: [PHP] Question:maybe urldecode

2004-12-09 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

  Basically I'm throwing this out though since I'm
  wondering if there is something that should be in
 the
  search script , that when I apply a query string
 to it
  would fill in the field (like magic hands)
 
 Yeah I wish I had some magic hands that writes my
 programs for me too. 
 Sadly ...
 
Jason, I don't think you read or understood my
question. As I said, it doesn't seem to be a debugging
scenario.I was asking if anyone would know a
reason why on one page , one could apply the query 
string to  url and the page would be filled in and
another page it doesnt work.  Please don't imply I'm
looking for someone to write my programs. The magic
hands was a reference to how the boxes are filled in
by placing the string in.

Stuart  

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



RE: [PHP] Question:maybe urldecode

2004-12-09 Thread Stuart Felenstein

--- Richard Lynch [EMAIL PROTECTED] wrote:

 Then your new script is broken, as clearly the GET
 paramters *ARE* there.

Sorry, I'm not following you.  Where are my GET
parameters ?  The way I've built my present script is
the reults page is grabbing the parameters.  Do I need
to set up GET parameters in the first/search page ?

 
 Is the new script on a different server or in a
 different directory? 
 Perhaps with register_globals turned OFF?
 
No , same server, The new scripts are in a different
directory then the previous one. They are not related
or call to each other.Register_globals are set to ON.

Stuart

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



RE: [PHP] Question:maybe urldecode

2004-12-09 Thread Stuart Felenstein

 --- Richard Lynch [EMAIL PROTECTED] wrote:
 
  Then your new script is broken, as clearly the GET
  paramters *ARE* there.
 
 Sorry, I'm not following you.  Where are my GET
 parameters ?  The way I've built my present script
 is
 the reults page is grabbing the parameters.  Do I
 need
 to set up GET parameters in the first/search page ?
 
  
  Is the new script on a different server or in a
  different directory? 
  Perhaps with register_globals turned OFF?
  
 No , same server, The new scripts are in a different
 directory then the previous one. They are not
 related
 or call to each other.Register_globals are set to
 ON.
 
I don't mean to drag this out as I have my work cut
out for me. I did want to add a few more factors that
perhaps is preventing this script from doing the
things I want. 

The first search / results form (the one that works):
a: is really proprietary code which is why I want to
dump it
b: It was created as one page and then I broke the
grid(results) portion off, so:
c: In the new scripts the search and results were
created seperately and most of the code is in the
results page. 
What I'm saying is in the search form, all that exists
is the form elements themselves and some resultsets
that feed the multi select lists and menu drop downs.

The results page, has the resultset for formulating
the return records, but it also has the query string
code that grabs the parameters explodes and implodes
them.  
I'm wondering if perhaps I need some of this code in
the search page. 

I wouldn't be throwing this out again, as the scripts
work, but it's that I need to get the query string
back into the search form and have it display the
parameters there.  I don't even know if that is a
standard function of search pages.  I've done some
googling but have not come up with something that
addresses this type of functionality.

Stuart

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



[PHP] Variables from database

2004-12-05 Thread Stuart Felenstein
I haven't try this yet but wondering if it's possible.
 
Can I do something like this:

select fieldone from table ;

$myvar = $fieldone ?

And more so could I do it with a where clause ?

i.e. select fieldone from table where fieldone = 3

$myvar = $fieldone ?

This is probably a stupid question.  I am also
wondering about syntax.

Thank you,
Stuart

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



[PHP] Differences in arrays

2004-12-02 Thread Stuart Felenstein
I have arrays set up in a user form.  One type is from
a multi-select list. (I'm passing these through a
multi page form as session variables)

The multi select list array code is like this:

To $_POST (going on to next page)I have this:

$_SESSION['industry'] = $_POST['L_Industry'];

Then in the final page where the database insert takes
place:

if ( is_array($_SESSION['industry'] ) ) {
foreach ($_SESSION['industry'] as $p ) {
$query = INSERT INTO Prof_Industries (ProfID, IndID)
VALUES ('$LID', '$p');  
 
$res4 = run_query($query);

This seems to work just fine as the printout(echo) :

INSERT INTO Prof_Industries (ProfID, IndID) VALUES
('118', '1')

NOW here is the problem:

I have 3 textfield elements all named school[]

To post those:

$_SESSION['schools'] = $_POST['school'];

Then in preparation for insert:

if ( is_array($_SESSION['schools'] ) ) {
foreach($_SESSION['schools'] as $h) {
$query = INSERT INTO Prof_Schools (ProfID, School)
VALUES ('$LID', '$h');
$res6 = run_query($query);
echo $query;
}
}
But here is the problem, it seems if the user didn't
input on all 3 textfields the query fails, because the
array is printing out like this:

INSERT INTO Profiles_Schools (ProfID, School) 
VALUES ('118', 'Baruch')

INSERT INTO Profiles_Schools (ProfID, School) 
VALUES ('118', '')

INSERT INTO Profiles_Schools (ProfID, School) VALUES
('118', '')

So you see there is no value for 2 and 3 as the user
didn't input.  But the array moves through the
elements anyway as the ProfID is assigned in the
query.

1-I guess I need a way to make sure in the foreach
that when the first empty element is reached the loop
dies.

2- Why would the second array behave differently then
the first ?

Stuart
Sorry for the long post. Just wanted to makre sure it
was clear in details.

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



Re: [PHP] Differences in arrays

2004-12-02 Thread Stuart Felenstein
--- Mike Smith [EMAIL PROTECTED] wrote:

 How about:
 
 
 if ( is_array($_SESSION['schools'] ) ) {
 foreach($_SESSION['schools'] as $h) {
 If($h!=){ //First added line
 $query = INSERT INTO Prof_Schools (ProfID, School)
 VALUES ('$LID', '$h');
 $res6 = run_query($query);
 echo $query;
 } //End added line
}
 }
Yes, I did that and it works correctly now. I was
tryin g to better understand why the difference in the
behaviour.  

Stuart

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



[PHP] Have I learned nothing . Foreach()

2004-11-30 Thread Stuart Felenstein
I thought this one was under my control.  Apparently
not.  

I'm getting a Warning: Invalid argument supplied for
foreach() in /home/mysite/public_html/mypage.php on
line 143

First, I have 3 form elements 
school[]
school[]
school[]

Here is how I initialize the session variable (after
user it's submit): 

$_SESSION['schools'] = $_POST['school'];

Then finally on the transaction page, some pages down
the road:

foreach($_SESSION['schools'] as $school)
{
$query = INSERT INTO mytable (ProfileID, School)
VALUES ($LID, '$school');
$res6 = run_query($query);
}

I can't for the life of me find the issue here.

Any pointers / help would be greatly appreciated.

Stuart

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



Re: [PHP] Have I learned nothing . Foreach()

2004-11-30 Thread Stuart Felenstein

--- Marek Kilimajer [EMAIL PROTECTED] wrote:

 
 print_r($_SESSION['schools']); here
 
  
  Then finally on the transaction page, some pages
 down
  the road:
  
 
 and also print_r($_SESSION['schools']); here
 
  foreach($_SESSION['schools'] as $school)
  {
 
 What have you find out?
 
They don't exist.  

Stuart

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



RE: [PHP] Have I learned nothing . Foreach()

2004-11-30 Thread Stuart Felenstein

--- Graham Cossey [EMAIL PROTECTED] wrote:

 You have got session_start(); at the top of each
 script haven't you?

Absolutely,  And the other variables are all working.

 Is the SID being passed down the chain of scripts? 
 Is this done by cookie or url?
 
cookie -or session. 

Stuart

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



[PHP] RE: [SOLVED][PHP] Have I learned nothing . Foreach()

2004-11-30 Thread Stuart Felenstein

--- Graham Cossey [EMAIL PROTECTED] wrote:

How embarassing. I had a typo 
elements were School
variables were school

Stuart

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



[PHP] Question: Search from , text fields

2004-11-30 Thread Stuart Felenstein
I'm building a search form where users can search for
people by zip code.  Trying to get an opinion here. 
Well maybe more then just one. 

Should I have seperate textfields, say (arbitrary) 3 ,
where they can put in 1 zip code per field.  Or do I
do it with one text field , using delimited entries - 

i.e 20199, 20294, 20599, 20054

Or the one text field with boolean.  

i.e 20199 AND 20294 OR 20599

I'm thinking boolean is the best, but being the
inexperienced lame brain I am , how difficult will it
be ?

by the way, this will be seraching a database field(s)

Alright I await the wisdom of PHP-General

Thank you ,
Stuart

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



RE: [PHP] How to $_POST from a grid

2004-11-25 Thread Stuart Felenstein

--- Graham Cossey [EMAIL PROTECTED] wrote:

 Hi Stuart
 
 Have you looked at the HTML generated by your PHP
 code?
 Using view source you'll see what values each of
 your 3 forms contains and
 therefore what will be submitted in the POST. My
 guess from one of your
 previous posts is that all 3 forms contain the same
 value in the (hidden) ID
 field. You were getting the value from a class but
 did not appear to be
 passing any kind of index to the class to determine
 which value to return.
 
 HTH
 Graham
 
Graham - hope your doing good!
It is 4:25am here but just fixed the problem. 
Solution - I created my standard repeat region around
all fields I want returned.  Within the repeat region
I put a form around the submit button and included the
hidden element as well in the form. So each record
returned has a seperate form around the button.  It
works! Records returned properly.

Stuart

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



[PHP] Date Format error

2004-11-25 Thread Stuart Felenstein
I'm getting a:
Parse error: parse error, unexpected '%' in
/home/mysite/public_html/userpage.php on line 120

 th scope=row?php echo
$rsVJ-Fields('DATE_FORMAT(LstUpdate,'%m/%d/%Y')');
?/th
  th scope=row?php echo
$rsVJ-Fields('DATE_FORMAT(InitOn,'%m/%d/%Y')');
?/th
  th scope=row?php echo
$rsVJ-Fields('DATE_FORMAT(PostStart,'%m/%d/%Y')');
?/th

Using this format /syntax
DATE_FORMAT(PostStart,'%m/%d/%Y')worked in a regular
database query.  Apparently not with echo.  I tried no
', also tried  around them, both produced nothing, no
error but no returned date.
Thank you 
Stuart

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



[PHP] How to $_POST from a grid

2004-11-24 Thread Stuart Felenstein
I have set up a record grid, where the user may see a
list of their records.  Repeat region, etc.
There is a button next to each record the user may
click to allow them to update the particular record.

This all worked fine with $_GET where I did a link on
the button to send the PrimaryID over. 
Now I'm attempting to use $_POST and not having the
same success.  
I moved the grid into a form and have a submit button
now for the update button.
Since the grid only is echos of the recordset fields,
how does it know the correct PrimaryID to send when I
hit the submit button. I'm thinking this is perhaps my
problem.

Can anyone help please
Stuart

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



Re: [PHP] How to $_POST from a grid

2004-11-24 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote: 
  Since the grid only is echos of the recordset
 fields,
  how does it know the correct PrimaryID to send
 when I
  hit the submit button. I'm thinking this is
 perhaps my
  problem.
 
 Hidden fields, or give the submit button a name
 that's based on the primaryID.
 
Thank you.
Close but not there yet.  I placed the hidden field in
the row with the repeat region on it.  Named it the
same as I did using the $_GET.  Problem is it's only
bringing up the last record returned.  i.e. 5 records
are on the grid.  Which ever one I chose to update,
the 5th record is the one coming up on the update
form.

Stuart

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



RE: [PHP] How to $_POST from a grid

2004-11-24 Thread Stuart Felenstein

--- Jay Blanchard
[EMAIL PROTECTED] wrote:

 Without a lick of code or a pointer to the grid on
 the web we would be
 hard pressed to offer solutions or advice. Arrays
 maybe? Hidden form
 fields?
 
Jay, fine - I thought I could spare you the code but
address what the problem might be.

In the grid, I am posting via $_POST the PrimaryID
via:
input name=JID type=hidden id=JID value=?php
echo $rsVJ-Fields('JID'); ?


Then in the update form: 

if (isset($_POST['JID'])) {
  $PJID = $_POST['JID'];

$query .= sprintf(SELECT * FROM vj_prm WHERE JID =
$PJID

I hope this is a better story ;)

Stuart

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



Re: [PHP] Re: How to $_POST from a grid

2004-11-24 Thread Stuart Felenstein

--- Daniel Schierbeck [EMAIL PROTECTED] wrote:


 I'd go with a POST form and a JavaScript
 
 form name=grid method=post
  input type=hidden name=primary_id /
  input type=button
 onclick=document.grid['hidden'].value='123' 
 value=foobar /
 /form
 
Yes , that is exactly what I'm doing but it's
returning only the last record.

So here below is an example of the grid results.  
with $_GET I click on one of the returns under
primaryID, if I choose 1stRecord, 1stRecord comes up
in the update form.  If I choose 3rdRecord, 3rdRecord
come s up in the update form.
With $_POST, and i have a form, tried it around each
record, around the whole grid , doesn't seem to
matter.
Regardless of choosing 1st 2nd or 3rd, 3rd is the one
that comes up in the udpate form.

+--+---+---+--+
|PrimaryID | Field2| Field3| Field3   |
+--+---+---+--+
+--+---+---+--+
|1stRecord | xx| xx| xx   |
+--+---+---+--+
+--+---+---+--+
|2ndRecord | xx| xx| xx   |
+--+---+---+--+
+--+---+---+--+
|3rdRecord | xx| xx| xx   |
+--+---+---+--+

Stuart

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



Re: [PHP] How to $_POST from a grid

2004-11-24 Thread Stuart Felenstein

--- David Bevan [EMAIL PROTECTED] wrote:


 Would it be possible to see the code that generates
 the grid?
 Both the php and HTML.
 -- 

I'm preferring not to post the code solely becasue I
don't want to expose all my database fields here. Of
course this may cost me the help I need. 

I'm doing my development in Dreamweaver though the
code is basic.  To get to the grid I'm passing over
the userID  .  Then basic a select statement in the
results grid with a while loop the returns all the
records related to the userID.  

It's just odd - because in Dreamweaver I build the
grid with one table row, place my echo fieldx in each
cell, then create a repeat region around the row. 
The repeat region is the while loop.

The behaviour though is different for whatever reason.
  Using a link with GET (paramter in the URL) it
distinguishes each primaryID correctly.  Yet with POST
no. As Jason just posted, yes it has individual submit
buttons, yet they solely return the last record.

Oh well.
Sorry for wasting everyone's time.

Stuart

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



[PHP] Question on query string

2004-11-16 Thread Stuart Felenstein
I hope this is a reasonable question:


This is the query string my search page is kicking out
to the results page.  It works fine but curious about
these codes or characters. And I know this maybe
unrelated to PHP, so I'll apologize in advance:
Why is each value preceeded by the %5B%5D ?  I think
the % is for wildcards, but for the life of me can't
figure out what 5B and 5D stand for.

Ind%5B%5D=2Ind%5B%5D=3Ind%5B%5D=4Ind%5B%5D=5..

Thank you 
Stuart

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



Re: [PHP] Question on query string

2004-11-16 Thread Stuart Felenstein
--- Richard Davey [EMAIL PROTECTED] wrote:


 Use urldecode() to get them back to normal again.

Changed the form action line to this: 

action=searchresults.php?Ind=?php echo
urldecode(((isset($_POST[Ind[]]))?$_POST[Ind[]]:))


Still getting this: 

?Ind%5B%5D=1Ind%5B%5D=2Ind%5B%5D=3

I'm under the assumption the values get passed from
search.php using urldecode() to searchresults.php. 
Maybe that is not the case.

Or should I do a $_GET['Ind'] = urlencode('Ind') on
searchresults.php ?

Stuart

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



RE: [PHP] Question on query string

2004-11-16 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:
 
 The main problem with the above snippet that I can
 see is that there's very
 unlikely to be such a thing as $_POST[Ind[]] --
 form fields with
 name=Ind[] will turn up as an array in
 $_POST[Ind] ($_POST[Ind][0],
 $_POST[Ind][1], etc.).  But the whole snippet
 looks very odd -- why are
 you trying to pass POSTed values as GET variables on
 (I presume) a form
 action??  Can you post a little context to the list
 to give us some idea
 what you're really trying to do.

Mike - 
Not sure what context would be useful.  The form
action is set to $_GET method.  I should have noticed
POST in there but set those urldecodes via Dreamweaver
bindings.  If you know what those are. Originally the
form was $_POST.  Now -  method=get  
The search.php form really does nothing with the
arrays.  In searchresults.php I am grabbing the
variables like this:

$HTTP_GET_VARS['Ind']
if (count($Ind)  0 AND is_array($Ind)) {
$s_Ind = '.implode(',', $Ind).';

Stuart

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



Re: [PHP] Question on query string

2004-11-16 Thread Stuart Felenstein
--- Jason Wong [EMAIL PROTECTED] wrote:
 
 When you're building a query string then (in
 general) there is no need for 
 urldecode(). On the contrary you want to use
 urlencode(), this is done on the 
 *value* of the individual parameters.
 
 And about this:  $_POST[Ind[]], it's obvious you
 haven't absorbed what I 
 said about this particular construct. Please re-read
 my previous post 
 regarding this and try to understand it.

 If the URL on the searchpage was constructed
 properly then on 
 searchresults.php the values passed can be read from
 $_GET directly with no 
 further processing (ie no need for urldecode() and
 other such nonsese) on 
 your part. But remember, you still need to validate
 the data you get from 
 $_GET (and in general from $_POST etc) before you
 use them.
 
Sorry, for some reason my email is out of synch today.
First the searchresults.php is reading the values
properly.  The queries are running correct-all fields.
 I'm still printing out the sql statement and those
are  without the hex values.

The method is $_GET , search.php is nothing more then
some form elements and fields.  
For searchresults.php (right below) is the way I'm
grabbing everything:

$HTTP_GET_VARS['Ind'];
// check any item is selected
if (count($Ind)  0 AND is_array($Ind)) {
$s_Ind = '.implode(',', $Ind).';
}
$HTTP_GET_VARS['State'];
// check any item is selected
if (count($State)  0 AND is_array($State)) {
$s_State = '.implode(',', $State).';
}
$HTTP_GET_VARS['TType'];
// check any item is selected
if (count($TType)  0 AND is_array($TType)) {
$s_TType = '.implode(',', $TType).';
}

//Textfields / Dropdown
$HTTP_GET_VARS['JTitle'];
$HTTP_GET_VARS['City'];
$HTTP_GET_VARS['Days']; 

I'm not seeing what is incorrect. I did try 
$HTTP_GET_VARS['Ind'] = urldecode('Ind'); (in
searchresults.php) but of course it wasn't imploded
yet.  I don't want to confuse this question or myself
(or anyone) , but maybe I should do the implodes on
search.php ?

Stuart

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




RE: [PHP] Question on query string

2004-11-16 Thread Stuart Felenstein

--- Chris W. Parker [EMAIL PROTECTED] wrote:

 Did you purposefully ignore my previous email???
 Someone else I think
 mentioned this in another email in this thread also.
 Why are you
 assigning anything to $HTTP_GET_VARS at all? It's
 meant to retrieve
 data.
 
 // (again) this is how you use urldecode()
 $Ind = urldecode($_GET['Ind']);
 
Chris I did not ignore your email  I tried using that
code.  A warning came back that urldecode was
expecting a string not an array.  This is why I posted
the followup wondering if I should impode the array
and then assign the urldecode.

Stuart

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



RE: [PHP] Question on query string

2004-11-16 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

  //Textfields / Dropdown
  $HTTP_GET_VARS['JTitle'];
  $HTTP_GET_VARS['City'];
  $HTTP_GET_VARS['Days']; 
 
 And thrice ditto.
 
They looked good, gone now :)

Stuart

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



Re: [PHP] Post Array elements to URL / was: Database Search .............

2004-11-15 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

 you need to build a string which looks like:
 
   Stat[1]=value1State[2]=value2...Stat[n]=valuen
 
 which you append to your URL like so:
 

searchresults.php?Stat[1]=value1Stat[2]=value2...Stat[n]=valuen
 
 This can be done using a foreach() on $_POST['Ind'],
 and implode(). Remember 
 to validate each item as you go along.


Not sure if this means I need to use both a foreach
and implode or one of them.

Right now I have this :

?php
$stats = $HTTP_POST_VARS['stats'];
if (is_array($stats))
foreach ($stats as $key=$val ) {
print $key = $valbr /;
}
?
 
I'm wondering how I change from printing it our to
getting into the URL.

Stuart

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



[PHP] Database search logic question

2004-11-15 Thread Stuart Felenstein
For those who recognize this topic from me and perhaps
are sick of it , my apologies :)

This is actually a different question more about logic
then syntax or functionality.

One of the uses of my search form is that users may
save their search parameters. Typical benefits, they
don't have to re-enter all the criteria.  Hitting one
link or receiving an email can get them the results
they need.  

The way I was approaching this was to grab the url,
the part after the ? , so not the referer.  Whatever
the second part is called. 
Only now that I've created a search and results page
via Post method, of course there is nothing going to
the URL. I'm wondering at this point if I should
create a way to let users save their search
parameters, by grabbing the variables and storing them
as an array in the database or go back to the URL
method.

Curious if anyone sees benefits or negatives with
either.

Stuart

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



RE: [PHP] Database search logic question

2004-11-15 Thread Stuart Felenstein
Please see inline:
--- Graham Cossey [EMAIL PROTECTED] wrote:

 A couple of possibilities are:
 
 Store search criteria (form entries) in MySQL
 Store query string in MySQL

So with my current form, the where statement is built
from conditions that are set (or not set) in the form.
Perhaps I grab that one array ?

 On one of my sites I allow users to either build a
 query via a step-by-step procedure or manually enter

 a query
 statement. It is the statement that I store in the 
 database together with a name they supply and their
 user 
 id. This allows the user to save multiple queries
 and 
 recall them at a later date by a name that they
 supplied.
 
I have something like that set up now.  The user must
be registered and logged in, the difference is I'm
saving the query string from URL. 

Stuart

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



RE: [PHP] Database search logic question

2004-11-15 Thread Stuart Felenstein
See inline:
--- Chris W. Parker [EMAIL PROTECTED] wrote:

 Stuart Felenstein mailto:[EMAIL PROTECTED]
 on Monday, November 15, 2004 1:10 AM said:
 
  The way I was approaching this was to grab the
 url,
  the part after the ? , so not the referer.
 
 This sounds like you're not familiar with the $_GET
 array. $_GET is
 everything after the ? in the url but as an array.

It sounds like you answered before you either read or
understood.  I was talking about 

$_SERVER[QUERY_STRING];


 This sounds like you're not familiar with the $_POST
 array. $_POST is
 everything that *would be* after the ? in the url
 but as an array.

In $_POST there is nothing in the URL , there is no ?.


  I'm wondering at this point if I should
  create a way to let users save their search
  parameters, by grabbing the variables and storing
 them
  as an array in the database or go back to the URL
  method.
 
 I don't see how these two things are similar.
 shrugs

They are not similar but will accomplish the same
goal.


 If you want to store your array in a db use
 serialize() and
 unserialize(). In any case I would just store the
 search criteria in a
 cookie and leave the db out of it.

A ccokie wouldn't help me one bit in this situation.  

Stuart
 

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



Re: [PHP] Database search logic question

2004-11-15 Thread Stuart Felenstein
See inline please:
--- David Bevan [EMAIL PROTECTED] wrote:

 Did you take the time to think about what you were
 going to do before starting 
 your application? 

Honestly , no I did not.  What I did start out with is
a belief that there wouldn't be a need to know php.  I
was using a RAD, that was sold as all encompassing. 
Fool me once.

 If you are looking to have the SQL query string sent
 as POST vars but don't know how to get those out of 
 the array, I would say you have some RTFMing to 
 do, the same would go for sending the users to your
 results page AND ( you can do both POST and GET vars
 for a single page)adding a querystring to the 
 url so that the user could bookmark the url and have
 a way to return to the same query they specified
 provided that the database query happens on/in the 
 results page.

Ok, I was not aware that both POST and GET can be used
at the same time.  
 
 If that answers any of your questions, great, if
 not, try planning ahead a 
 little instead of asking the list to write the
 functionality code for you.
 
Okay, so showing me how something works is now wrong ?
No one has shown you code or explained a better method
at some function ?

This particular post has went way passed its course. 
Thank you for your help.

Stuart

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



RE: [PHP] Database search logic question

2004-11-15 Thread Stuart Felenstein

--- Gryffyn, Trevor [EMAIL PROTECTED]
wrote:


 This is a PHP General mailing list, it should be for
 general, newbie,
 etc sort of questions.  But the expectation is that
 the questions being
 asked were researched some ahead of time as well. 
 Although that's not
 always an option and that needs to be understood as
 well.
 
 
 Good luck, Stuart.
 
 -TG
Thank you Trevor.  Your words will be well heeded. 
Your effort and response is greatly appreciated.  I'm
going to make a better effort going forward before
turning to the list for quick answers.

I've received  many great answers and explanations
here.  All have been appreciated , and I hope used for
the betterment of right now, at least my
understanding.

Stuart

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



[PHP] Database Search and seperate results page

2004-11-14 Thread Stuart Felenstein
After googling for quite some time I'm back asking
here.  I want to be able to seperate by search and
results into two pages.

My form is set up on Search.php
I have set actionsearchresults.php

Couple of questions:
I have my array of user selected options from my form
element - Ind[]

I gather the processing of the array needs to be done
first before posting.  
I tried this:
searchresults.php?Ind=?php
echo((isset($_POST[Ind[]]))?$_POST[Ind[]]:) ?
but all I saw in the searchresults.php url was ..?ind
= 
?

Does the searchresults page need to use the GET method
to gather up the variables?

Thanks
Stuart

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



[PHP] Re:[SOLVED] [PHP] Database Search and seperate results page

2004-11-14 Thread Stuart Felenstein

--- Stuart Felenstein [EMAIL PROTECTED] wrote:

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



Re: [PHP] Database Search and seperate results page

2004-11-14 Thread Stuart Felenstein
--- Jason Wong [EMAIL PROTECTED] wrote:

 Sadly, you're really not learning much from this
 list ...

I partially disagree.  I think it might be better for
me to take a more elementary approach to the language
before getting moving on to specific project issues. 



 ... print_r()/var_dump() $_POST[Ind[]], what do
 you see? Nothing I bet. Why? 
 See manual  PHP and HTML for details.
 

 
 There are 2 way you can do this:
 
 a) Pass the individual elements of $_POST['Ind']
 
 or
 
 b) serialize() $_POST['Ind'], pass it as a single
 element, then on the 
 receiving page unserialize() it
 

I posted a few hours prior to your response that this
was solved.  I am using the $_POST method. On the
results page I check to see if there are any elements
set and then move on to implode.  

It's working.  Though I have some other things to
figure out ;)

Stuart

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



Re: [PHP] Re: What am I doing wrong - PHP

2004-11-13 Thread Stuart Felenstein

--- M. Sokolewicz [EMAIL PROTECTED] wrote:
 I would suggest writing it like this:
[snip]

I'm getting the page now with the box but no values
inside.  Database conn is fine and all.  I can print
out the value , just can't get them to show up inside
form  element (Multiple select)

Here is what I have 
Again, StaIndTypes is made up of CareerIDs [int] and
CareerCategories [varchar]

?php
mysql_select_db($database_Pmmodel, $Pmmodel);
$inds = mysql_query(SELECT * FROM StaIndTypes,
$Pmmodel) or 
die(mysql_error());
?

body
form name=form1 id=form1 method=Post action=
  select name=Ind size=10 multiple=multiple
id=Ind
?php
//I tried MYSQL_ASSOC, NUM and BOTH, no diff
while($row = mysql_fetch_array($inds, MYSQL_BOTH)) {
echo 'option 
value='.$inds['CareerIDs'].''.$inds['CareerCategories'].'/option';
}
echo '/select/form';


Thanks 
Stuart

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



Re: [PHP] Re: What am I doing wrong - PHP

2004-11-13 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:


 $row is what contains the data you're grabbing from
 the DB and you're not 
 using it
 
 Jason Wong - Gremlins Associates -


Thank you Jason, its working now !


Stuart

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



RE: [PHP] Re: Help: Database Search

2004-11-13 Thread Stuart Felenstein
I think I'm almost there :)
Only right now I'm getting an error message:

Query failed: You have an error in your SQL syntax.
Check the manual that corresponds to your MySQL server
version for the right syntax to use near '' at line 3

?php
$where = array();
$Ind = ;
$Ind = $_POST['Ind'];
  if (count($Ind)  1)
  {
$IndStr = implode(',', $Ind);
$where[] = VendorJobs.Industry IN($IndStr);
  }else{
$where[] = VendorJobs.Industry = {$Ind[0]};
}
?
?php
$sql = 'SELECT PostStart, JobTitle, Industry,
LocationState, VendorID
FROM VendorJobs
WHERE ' . implode( ' AND ', $where );

$result = mysql_query($sql) or die (Query failed: 
.mysql_error());
while($row = mysql_fetch_assoc($result))

I can't find the problem.
Anyone see anything ?

Thank you.
Stuart

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



RE: [PHP] Re: Help: Database Search

2004-11-13 Thread Stuart Felenstein
Sorry, I fixed Ind , since the element is named Ind[].
Now I get a different error:

Query failed: You have an error in your SQL syntax.
Check the manual that corresponds to your MySQL server
version for the right syntax to use near
'','','Array)' at line 3
 
 ?php
 $where = array();
 $Ind[] = ;
 $Ind[] = $_POST['Ind'];
   if (count($Ind)  1)
   {
 $IndStr = implode(',', $Ind);
 $where[] = VendorJobs.Industry IN($IndStr);
   }else{
 $where[] = VendorJobs.Industry = {$Ind[0]};
 }
 ?
 ?php
 $sql = 'SELECT PostStart, JobTitle, Industry,
 LocationState, VendorID
 FROM VendorJobs
 WHERE ' . implode( ' AND ', $where );
 
 $result = mysql_query($sql) or die (Query failed: 
 .mysql_error());
 while($row = mysql_fetch_assoc($result))
 
 I can't find the problem.
 Anyone see anything ?
 
 Thank you.
 Stuart
 
 -- 
 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] Re: Help: Database Search

2004-11-13 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:
 
 Uhmm, you could try some debugging of your own
 instead of relying on the list. 
 Liberally douse your code with print_r() and
 var_dump() of all your important 
 variables. Do they contain what you expected? If not
 try and figure out why 
 not.
 
 -- 
 Jason Wong - Gremlins Associates -

Okay, took your advice, but it seems to be a sql error
as the message says.  

Stuart

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



Re: [PHP] Re: Help: Database Search

2004-11-13 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:
 Yes, that was apparent from your previous post. So
 did you print out your 
 query and examine it for any obvious mistakes? And
 if you couldn't spot any 
 obvious mistakes then the least you could have done
 was to copy and paste the 
 full query in your post so that we could see it in
 all its glory instead of 
 the truncated query that was posted as part of the
 mysql error message. 
 Please help us to help you.
 
 -- 
 Jason Wong - Gremlins Associates -

It was not apparent whatsoever.  Let me show the code
again , but I'll include the print_r returns inline
code.

?php
$where = array();
$Ind[] = ;
print_r($Ind);
//Array ( [0] = 1 [1] = 2 [2] = 3 [3] = 4 [4] = 5
[5] = 6 [6] = 7 [7] = 8 [8] = 9 [9] = 10 [10] =
11 [11] = 12 [12] = 13 [13] = 14 [14] = 15 [15] =
16 [16] = 17 [17] = 18 [18] = 19 [19] = 20 [20] =
21 [21] = 22 [22] = 23 [23] = 24 [24] = 25 [25] =
26 [26] = 27 [27] = 28 [28] = 35 [29] = [30] =
Array ( [0] = 1 [1] = 2 [2] = 3 [3] = 4 [4] = 5
[5] = 6 [6] = 7 [7] = 8 [8] = 9 [9] = 10 [10] =
11 [11] = 12 [12] = 13 [13] = 14 [14] = 15 [15] =
16 [16] = 17 [17] = 18 [18] = 19 [19] = 20 [20] =
21 [21] = 22 [22] = 23 [23] = 24 [24] = 25 [25] =
26 [26] = 27 [27] = 28 [28] = 35 ) )
So maybe this is weird, since it seems to print out
twice ?


  if (count($Ind)  0)
  {
$IndStr = implode(',', $Ind);
$where[] = VendorJobs.Industry IN($IndStr);
  }else{
$where[] = VendorJobs.Industry = {$Ind[0]};
}
?

?php
$sql = 'SELECT PostStart, JobTitle, Industry,
LocationState, VendorID
FROM VendorJobs
WHERE ' . implode( ' AND ', $where );
print_r($where);
//Array ( [0] = VendorJobs.Industry
IN(1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','35','','Array)
)

$result = mysql_query($sql) or die (Query failed: 
.mysql_error());
while($row = mysql_fetch_assoc($result))
?

Stuart

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



Re: [PHP] Re: Help: Database Search

2004-11-13 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:
 
 See the Array (also missing a single-quote),
 that's element [30] mentioned 
 above.
 
 Summary: the missing single-quotes are the
 show-stopper.
 
I see that , but I'm not sure how that is happening. 

Here is the sql:

$sql = 'SELECT PostStart, JobTitle, Industry,
LocationState, VendorID
FROM VendorJobs
WHERE ' . implode( ' AND ', $where );
// Is it the Where statement maybe ?

//print_r($where);

$result = mysql_query($sql) or die (Query failed: 
.mysql_error());
while($row = mysql_fetch_assoc($result))

Stuart

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



Re: [PHP] Re: Help: Database Search

2004-11-13 Thread Stuart Felenstein

--- James Kaufman [EMAIL PROTECTED]
wrote:


 Right here, print the contents of $sql. That is the
 most important thing to
 know right now.
 

SELECT PostStart, JobTitle, Industry, LocationState,
VendorID FROM VendorJobs WHERE VendorJobs.Industry
IN(1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','Array)Query
failed: You have an error in your SQL syntax. Check
the manual that corresponds to your MySQL server
version for the right syntax to use near
'','2','3','4','5','6','7','8','9','10','11','12','13','14','15'


Looks like the array is matching ?

Stuart

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



Re: [PHP] Help: Database Search

2004-11-13 Thread Stuart Felenstein
I've changed my logic around but still running into a
sql query error.
I've tried a number of things with no success.  Here
is the error that returns on POST:

SELECT PostStart, JobTitle, Industry, LocationState,
VendorID FROM VendorJobs WHERE (VendorJobs.Industry =
''1','2','3''Query failed: You have an error in your
SQL syntax. Check the manual that corresponds to your
MySQL server version for the right syntax to use near
'1','2','3''' at line 2 . 

Here is the relevant code:

$Ind = $HTTP_POST_VARS['Ind'];
if (count($Ind)  0 AND is_array($Ind)) {
$Ind = '.implode(',', $Ind).';
}
$sql = SELECT PostStart, JobTitle, Industry,
LocationState, VendorID
FROM VendorJobs;
//if ($Ind)
$sql .=  WHERE (VendorJobs.Industry = '$Ind';

I'm not trying to be a pain here.  Either I'm not
catching a syntax error or something else.

Stuart

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



[PHP] Re:[SOLVED] [PHP] Help: Database Search

2004-11-13 Thread Stuart Felenstein

--- Stuart Felenstein [EMAIL PROTECTED] wrote:

Okay, so what did I learn.  

1) That a comma delimited list (from the array) to be
used correctly in the sql statement had to use the IN
word.
$sql .=  WHERE VendorJobs.Industry IN ($s_Ind);

2) I need a space between the first quotation in the
first and second sql statements. 

3) Debug my code.  Perhaps I need to learn more about
that but i was printing out the sql statements and had
the mysql_error() set for the failure.

Stuart

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



RE: [PHP] Re: Help: Database Search

2004-11-13 Thread Stuart Felenstein
--- Graham Cossey [EMAIL PROTECTED] wrote:

 Hi Stuart
 
 Not sure what's happening with the $Ind variable,
 maybe check the $_POST
 array as you enter the script to ensure that the
 form is passing the data
 correctly. It is almost as if you are appending it
 to itself at some point.
 You don't have a line like this anywhere do you :
 $Ind[] = $Ind;  OR maybe 2
 of: $Ind[] = $_POST['Ind']; ??
 
 Part of the problem is with the implode statement.
 It is this that is not
 adding the initial and final ' to your IN statement,
 see below:
 
   if (count($Ind)  0)
   {
 
 $IndStr = implode(',', $Ind);
 $where[] = VendorJobs.Industry IN('$IndStr');
^---^
   }else{
 $where[] = VendorJobs.Industry = {$Ind[0]};
 }
 
 I would also remove this line:
 $Ind[] = ;
 
 HTH
 Graham
 
I think it's working , at least I get results now with
no error messages.  Still some work to go on the
script.  Here is the current initializatin and sql
code:

$Ind = $HTTP_POST_VARS['Ind'];
if (count($Ind)  0 AND is_array($Ind)) {
$s_Ind = '.implode(',', $Ind).';
}

I guess here I should put this in braces as it should
be conditional if $Ind is set, if not the subsequent
sql statement shouldn't go in.

if ($Ind) 
$sql .=  WHERE VendorJobs.Industry IN ($s_Ind);

Stuart

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



Re: [PHP] Re: Help: Database Search

2004-11-12 Thread Stuart Felenstein

--- Sebastian Mendel [EMAIL PROTECTED] wrote:
 
 $where = array();
 
 if ( isset($_POST['Ind']) ) {
  $where[] = 'vendorjobs.Industry = ' . (int)
 $_POST['Ind'];
 }
 if ( isset($_POST['Days']) ) {
  $where[] = 'Date_Sub(Curdate(), interval ' .
 (int) $_POST['Days'] . 
 ' day) = PostStart';
 }
 
 $sql = '
   SELECT ...
 FROM vendorjobs
WHERE ' . implode( ' AND ', $where );
 
 
Sebastian, I meant to thank you for this code the
other day.  
What I'm trying to figure out is some of my elements
are arrays themselves.  So for example I have this :

$Ind = ;
$Ind = $HTTP_POST_VARS['Ind'];
if (count($Ind)  0 AND is_array($Ind)) {
 $Ind = '.implode(',', $Ind).';
}

So how would this code , or array get into what you
stated as:

 $where = array();
 
 if ( isset($_POST['Ind']) ) {
  $where[] = 'vendorjobs.Industry = ' . (int)
 $_POST['Ind'];
 }

I guess that is putting an array into an array ?
Not quite sure how the loop would go.

Thank you,
Stuart

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



RE: [PHP] Re: Help: Database Search

2004-11-12 Thread Stuart Felenstein

--- Graham Cossey [EMAIL PROTECTED] wrote:

 This should result in:
 
 WHERE vendorjobs.Industry IN (2,3,5)
 
 OR
 
 WHERE vendorjobs.Industry = 2
 
 HTH
 Graham

Not sure what you mean by the above ?

Stuart

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



[PHP] What am I doing wrong - PHP

2004-11-12 Thread Stuart Felenstein
Ok, hopefully I can explain this clearly, even though
I think I might be an idiot since Ive been going on
about this for a few days.

I have a table that holds values and labels 
i.e. 1 = New York
 2 = Boston
 3 = Kansas City
 4 = Amsterdam

I want to put this table into a multiple selection
list, that a user can choose from in a form
My code is drawing a blank though:

//This is my call to the table staindtypes
?php
mysql_select_db($database_lokale, $lokale);
$indque1 = SELECT * FROM staindtypes;
$inds = mysql_query($indque1, $lokale) or
die(mysql_error());
$row_inds = mysql_fetch_assoc($inds);
$totalRows_inds = mysql_num_rows($inds);
$row = mysql_fetch_row;
?


//Here is the element and the php to loop it
form name=form1 id=form1 method=post action=
  select name=Ind size=5 multiple=multiple
id=Ind
  option value=Please Select/option
?php
do {  
?
option value=?php echo
$rows['CareerIDs']??php echo
$row_$result['CareerCategories']?/option
?php
} while ($rows = mysql_fetch_assoc($inds));
  $rows = mysql_num_rows($inds);
  if($rows  0) {
  mysql_data_seek($inds, 0);
  $rows = mysql_fetch_assoc($inds);
  }
 ?

When I load the page it is blank.

Any help would be appreciated.

Stuart

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



[PHP] Looking for pointers to mysql functions

2004-11-11 Thread Stuart Felenstein
I'm building a search function and I think most of the
search part is solid. 

Now I'm trying to figure out the results part.
Since my results would return about 7 fields per
record, I'm thinking mysql_fetch_row over mysql
results works better ?
But I don't want every field from the row returned,
only specific ones.
Also, I want to allow for all records that meet
criteria to be returned, and will set up a user
variable, so they can choose how many records per page
come back.

Can anyone share some ideas or pointers to
documentation that will allow me to set this up ?

Very much appreciated!
Stuart

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



Re: [PHP] Looking for pointers to mysql functions

2004-11-11 Thread Stuart Felenstein

--- [EMAIL PROTECTED] wrote:

 This would be handled in your query,  so get a SQL
 book or look into the mysql documentation...
 
 Look at the select statement, to request specific
 fields, as well as the Limit keyword to return a
 certain number of results per page.
 -B
 

So there is no php code I need to know to get returns
on my query statement ?

Stuart

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



RE: [PHP] Looking for pointers to mysql functions

2004-11-11 Thread Stuart Felenstein

--- Graham Cossey [EMAIL PROTECTED] wrote:


 Is this something like what you are after:
 
 ?php
 $sql = SELECT col1, col2, col3, col4 as colx, col5
 FROM my_table
 WHERE col2 LIKE '%$search%'
 ORDER BY col3
 LIMIT $from, $max_results;
 
 $result = mysql_query($sql) or die (Query failed: 
 . mysql_error());
 while($row = mysql_fetch_assoc($result))
 {
 ?
 tr
   td?php echo $row['col2'] ?/td
   td?php echo $row['colx'] ?/td
 /tr
 ?php
 }
 ?
 
 For details on how to do the x rows per page with
 previous and next see
 
 http://www.phpfreaks.com/tutorials/43/0.php
 or
 http://www.phpfreaks.com/tutorials/73/0.php
 
 HTH
 Graham
 
Yes, I think this is it.  I appreciate the link to the
rows per page thing!
Very helpful as always!

Stuart

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



[PHP] Help: Database Search

2004-11-10 Thread Stuart Felenstein
I am creating a database search form and results.
Running into a problem though.
I have two form elements, both that are fed by tables
that have int values (1, 2 , etc)

my sql statement is such:

SELECT vendorjobs.PostStart, vendorjobs.JobTitle,
vendorjobs.Industry, vendorjobs.VendorID,
vendorjobs.LocationCity, vendorjobs.TaxTerm FROM
vendorjobs WHERE vendorjobs.Industry = '$Ind' AND
Date_Sub(Curdate(), interval '$Days' day) = PostStart


But if the user decides to only use one of the
elements, then I don't want the query to return
nothing because of the And in the where clause so I
have these 2 statements that set a default value
(shown here as 0 in the event one of the two elements
aren't selected:  (Having no luck as the form still
only works correctly if I've set both elements)

$Ind = 0;
if (isset($_POST['Ind'])) {
  $Ind = (get_magic_quotes_gpc()) ? $_POST['Ind'] :
addslashes($_POST['Ind']);
}
$Days = 0;
if (isset($_POST['Days'])) {
  $Days = (get_magic_quotes_gpc()) ? $_POST['Days'] :
addslashes($_POST['Days']);

Thank you ,
Stuart

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



Re: [PHP] Help: Database Search

2004-11-10 Thread Stuart Felenstein

--- Jon Hill [EMAIL PROTECTED] wrote:

 You might want to try looking up the syntax for left
 join queries.
 I think this might be what you are after.
 
 http://dev.mysql.com/doc/mysql/en/JOIN.html
 
It has nothing to do with left joins.  It works fine
provided I do one of two things, make selections on
both form elements, or change the where statement to
or instead of and.

Stuart

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



Re: [PHP] Help: Database Search

2004-11-10 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

 Why not build your sql query according to whether or
 not whatever you want is 
 selected or not.  That way debugging is easier as
 you won't be looking at 
 queries that contain redundant ... AND 0 
 

Jason, How would I do that ? Care to share a short
exmaple ?

Thank you 
Stuart

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



[PHP] Question: Exiting a script

2004-11-08 Thread Stuart Felenstein
Say I have a script that processes input data.  How do
I get the script to work, where  after processing the
user is taken to another page ?  The script outputs
nothing to the screen and will end either in failure
or success.  
Seems header won't work for me.


Stuart

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



Re: [PHP] Question: Exiting a script

2004-11-08 Thread Stuart Felenstein

--- Richard Davey [EMAIL PROTECTED] wrote:

 some
 text or
white-space, aborting';
 }
 else
 {
 
 Richard Davey

I think white space is my problem.  What causes white
space ?

Stuart

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



Re: [PHP] Question: Exiting a script

2004-11-08 Thread Stuart Felenstein
Never mind , I found it!
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
Transitional//EN http://www.w3.org/

TR/xhtml1/DTD/xhtml1-transitional.dtd

One of these days I'll master the header function ;)


Stuart

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



[PHP] Variable for search results

2004-11-08 Thread Stuart Felenstein
I have a form element which allows a user to go back
x number of days in the records.


$sql.=sprintf(SELECT * FROM records WHERE
Date_Sub(Curdate(), interval  day) $%s =
PostStart) 

This formula works when I actually hardcode the number
of days in where this mess -- $%s is right now.

I'm not entirely sure how this should be coded.  Can I
put the variable right there? 

I'll take any suggestions, cause I'm stuck here.

Thank you,
Stuart

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



Re: [PHP] Re: Variable for search results

2004-11-08 Thread Stuart Felenstein

--- Ben Ramsey [EMAIL PROTECTED] wrote:

 I'm not exactly sure what the SQL statement you have
 above is supposed 
 to do, but you could just do something like this:
 
 $curdate = date('Y-m-d H:i:s');
 $sql = SELECT * FROM records WHERE '$curdate' =
 PostStart;;
 

I'm having some problems still.  I'm trying to work
here with a Dreamweaver extension and the code is not
clear.  Are there are good tutorials around , to learn
how to create a database search and results page.
Basically there would be about 6 form elements, some
list boxes, some text fields.  The more criteria that
is filled in on the form the more refined the search.
Not sure if this is beyond my skill level or not. 
Beginner. 

Thank you
Stuart

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



[PHP] Help:escape_string and stripslashes

2004-11-07 Thread Stuart Felenstein
I asked a question yesterday about this but I think my
question is now more fine tuned:

Right now I have about 50+ session variables that will
be inserted into my mysql database in a transaction. 
I need to do the mysql_real_escape_string and because
magic_quotes_gpc is turned on stripslashes as well.

I'm wondering if there is a way to use a function or
class within my connection script to take care of all
of this ? As oppposed to listing everyone out ?  I
know I can pass all the variables as an array but some
of the variabls are arrays themselves, so not sure how
that would work.

Any suggestions ?

Thank you
Stuart

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



Re: [PHP] Help:escape_string and stripslashes

2004-11-07 Thread Stuart Felenstein

--- Jordi Canals [EMAIL PROTECTED] wrote:

 In the manual

http://es2.php.net/manual/en/function.get-magic-quotes-gpc.php
 you have an example just for that. Take a look to
 the Example 2.
 
Ok, that makes sense.  Thank you .


Stuart

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



Re: [PHP] Help:escape_string and stripslashes

2004-11-07 Thread Stuart Felenstein

--- Stuart Felenstein [EMAIL PROTECTED] wrote:


On second thought, I have a question.  What is the
$value in the example ?  
Does that mean I put in my own values ?

Stuart

?php
if (get_magic_quotes_gpc()) {
   function stripslashes_deep($value)
   {
   $value = is_array($value) ? ---?
   array_map('stripslashes_deep',
$value) :
   stripslashes($value);

   return $value;
   }

   $_POST = array_map('stripslashes_deep', $_POST);
   $_GET = array_map('stripslashes_deep', $_GET);
   $_COOKIE = array_map('stripslashes_deep',
$_COOKIE);
}
? 

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



Re: [PHP] Help:escape_string and stripslashes

2004-11-07 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

 2) Lookup array_map() and understand what it does.
 
 3) stripslashes_deep() is a recursive function (ie.
 it calls itself).  You 
 should find a good tutorial on recursive functions
 to learn exactly what it 
 does.


Thank you Jason.
Another thing I'm wondering and not clear on .  
I have 5 pages of forms, a 6th page is where the
processing , transaction is taking place. 
Would it be sufficient to add stripslashes_deep() to
only the last page (6th page) ?
Each succeeding page, posts the previous page
varibles. 
I'm guessing the last (6th page) would be enough, but
would like to confirm.

Stuart

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



[PHP] Question: array_walk

2004-11-07 Thread Stuart Felenstein
This array_walk() looks like a good function

Would this be a legitimate call:

array_walk($myarray, 'mysql_real_escape_string');


?

Thank you,
Stuart

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



[PHP] Array_Walk error messages

2004-11-07 Thread Stuart Felenstein
Can anyone give me a clue what I have done wrong here.

//These would be passed as ints:
array_walk($l_industry, 'mysql_escape_string');
Warning: Wrong parameter count for
mysql_escape_string() in
/xxx//public_html/Test2.php on line 104

//These would be passed as ints:
array_walk($l_tterm, 'mysql_escape_string');
Warning: Wrong parameter count for
mysql_escape_string() in
/xxx//public_html/Test2.php on line 105

//These are strings
array_walk($skills, 'mysql_escape_string');
Warning: Wrong parameter count for
mysql_escape_string() in
/xxx/x/public_html/Test2.php on line 106

//These are ints:
array_walk($skys, 'mysql_real_escape_string');
Warning: mysql_real_escape_string() expects parameter
2 to be resource, integer given in
/xxx/x/public_html/Test2.php on line 107

//These are ints:
array_walk($slus, 'mysql_escape_string');
Warning: Wrong parameter count for
mysql_escape_string() in
/xxx//public_html/Test2.php on line 108


Thanks
Stuart

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



[PHP] Questions about mysql_real_escape_string and addslashes

2004-11-06 Thread Stuart Felenstein
First I'm a bit unsure , because in the manual it
states that you must use mysql_real_escape_string on
binary data.  So first question, what constitutues
binary data, a file or just an integer?

Second question - Since magic_quote_gpc is enabled on
my server (and I have no choice) - I gather I must use
addslashes()

3rd- Some of the user input translates to an int value
where I later do a join for the actual label.  I
believe those fields are protected naturally since the
database won't accept anything but an int.

4th - With both of these functions it looks like they
become part of the sql query.  I could use some help
in understanding how to set up variables using both
functions.  In otherwords, an example of how they get
coded.

Thank you ,
Stuart

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



Re: [PHP] Re: Questions about mysql_real_escape_string and addslashes

2004-11-06 Thread Stuart Felenstein

--- M. Sokolewicz [EMAIL PROTECTED] wrote:

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


I have my eye on example 3: The Quote_Smart function. 
Do I have to list all the variables out though or is
there a way to have it check everything passing
through ?
What would nice is if I didn't have to put the
Quote_smart function in every query statement but have
it test everything? 

Stuart
 
 

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



[PHP] Question: Passing error messages

2004-11-06 Thread Stuart Felenstein
I've started getting into the habit of passing error
messages through session variables, particularly on
redirects.
From some peoples reaction on this list I gather it's
not the best practice.

What is an alternative way ? I believe it's through a
URL. not sure how to go about that method


Stuart

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



Re: [PHP] Re: Question: Passing error messages

2004-11-06 Thread Stuart Felenstein

--- Daniel Schierbeck [EMAIL PROTECTED] wrote:
 
 I'm not quite getting what you're saying - are you
 sending the error 
 messages on to a new page?! The usual and simple way
 of doing this is 
 the good 'ol OR operator:
 

I'm saying, currently if there is an error and the
script needs to exit, I'm doing this :

if ..error {
$_SESSION['ErMsg'] = Submit Failure;
header (location: )
exit;
}

I want to know what alternatives there are to error
messages aside from using a session variable. 

Thank you ,
Stuart

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



Re: [PHP] Re: Question: Passing error messages

2004-11-06 Thread Stuart Felenstein

--- Daniel Schierbeck [EMAIL PROTECTED] wrote:

 Where are you redirecting the client to? An error
 page?

Either an error page or back out to a main page.

Stuart

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



[PHP] Initializing variables

2004-11-05 Thread Stuart Felenstein
I'm reading PHP security paper by Chris Shiflett. 
Trying to figure out what is meant by first
initializing a variable.  
Now, just for the record, I'm not completely dumb.
I know you can start with a 
$var = 2

What I want to know is if the variable assignment is
unknown, as in a user form.
Would I then just initialize the variables to 0 ?

Stuart

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



[PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein
I think I've tried just about everything that I found
googling.  Still no luck. I'm throwing this out again,
with the chance that something missed before maybe
noticed.

Page 1:
//Start the Session - begin Block
@session_start();
form method=POST name=form1 action=Page2.php
input name=ListingName type=text id=ListingName
/

Page 2:
//Start the Session - begin Block
@session_start();
//Set the session variable, input on Page 1
$_SESSION['f1a'] = $_POST['ListingName'];


Page 3:
//ON this page, I check that f1a still exist using an
echo - generally it does unless :

//Start the Session - begin Block
@session_start();
if (count($myarray)  5) {
$_SESSION['arrayerr'] = you have selected too many
industries;
header (Location: Page2.php);
exit;
}
If the validation above passes, no problem. But if it
doesn't, once it redirects, the session variable , f1a
is bye bye.

I've tried passing the session_id, session_name, i've
printed out both to make sure they remain the same. 
I' ve done relative and absolute paths.  

Searching for this problem , it seems I'm not the only
one who has suffered with this issue.  Some was prior
php 4.3 when session_write_close was needed.  I've
thrown that in as well.  

I just don't get it.

Stuart

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



Re: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Richard Davey [EMAIL PROTECTED] wrote:

 Unless I'm mistaken - you are redirecting back to
 Page 2 upon an
 error, right? Well according to the code posted, the
 second you hit
 Page 2 again, you are over-writing whatever is in
 the f1a session
 variable with the contents of the $_POST var, which
 naturally will not
 exist, hence you'll blank it out every single time.
 
Your not mistaken.  That is what's happening.  I just
don't know how to fix it .

Stuart

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



Re: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Richard Davey [EMAIL PROTECTED] wrote:

 Before setting the session value in Page 2, check
 for the existence of
 the $_POST value first.
 
 if (isset($_POST['var']))
 {
$_SESSION['var'] = $_POST['var'];
 }
 
 When you now redirect to Page 2 upon an error, it'll
 skip this block
 because the $_POST var won't exist.
 

I'm a bit confused, this fixes the problem ? 

Stuart

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



RE: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Reinhart Viane [EMAIL PROTECTED] wrote:

 Suppose Richard means:
 
 If (isset($_POST['ListingName'])) {
 $_SESSION['f1a'] = $_POST['ListingName'];
 }


Right, I've tried all three variations , none of
which, I'm sorry to report, have helped.

The variable is alive with any of the code including
the one I had originally.  It seems to do a reset
though when it's redirected.  I've even tried:

Page3:

if (count($LurkerIndustry)  5) {
$_SESSION['arrayerr'] = you have selected too many
industries;
$_SESSION['f1a'] = $_POST['ListingName'];
header (Location: TestMulti2.php);
exit;
}

Thinking that by sending the variable back to page 2
it would hold. The error variable takes.

Stuart

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



RE: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Reinhart Viane [EMAIL PROTECTED] wrote:

 So, if I understand correct, even with the isset
 code on the second page
 $_SESSION['f1a'] is set to empty?
 That's strange.
 Still I wonder why you are inputting the error
 messages and the redirect
 in a session variable.
 
Yes, the isset is not working.  It probably isn't
necessary anyone since I've got a validate / required
field set.

I'm not sending the redirect in a session variable. 
Only the error message.  That is the way I know how to
do it.  

Stuart

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



RE: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

  Page3:
  
  if (count($LurkerIndustry)  5) {
  $_SESSION['arrayerr'] = you have selected too
 many industries;
  $_SESSION['f1a'] = $_POST['ListingName'];
  header (Location: TestMulti2.php);
  exit;
  }
 
 Well, that's even worse -- because page3 can *never*
 be reached as the
 result of submitting a form, its $_POST[] will
 *always* be empty -- so this
 assignment is also bound to set $_SESSION['f1a'] to
 NULL.
 
Mike, I'll heed your advice, since you haven't let me
down before :).  But the variable lasts , I echo it on
every page, including page6 where it's transacted into
the database.  I'm not sure why you say that

Stuart

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



Re: Re[4]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Richard Davey [EMAIL PROTECTED] wrote:

 Try sticking this on Page 2 (ensure you have a
 session_start() at the
 top of the page and that you replace the 'var' text
 below with the
 correct ones.
 
 if (isset($_POST['var']))
 {
echo 'POST value found, setting the session var
 now';
$_SESSION['var'] = $_POST['var'];
 }
 else
 {
 echo 'No POST value found, dumping session
 contents';
 print_r($_SESSION);
 }
 
 Run it - make it error - what does it end up saying?
 

Before the redirect:

POST value found, setting the session var now


After the redirect: 

No POST value found, dumping session contentsArray (
[xx_user_xxx] = username [xx_id_xxx] = 47
[xx_level_xxx] = BasicUser [f1a] = [WAVT_TestMulti2]
= [f1b] = [f1c] = [f1d] = [f1e] = [f1g] =
[inder] = you have selected too many industries )

Stuart

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



  1   2   >