php-general Digest 24 Jul 2004 20:16:33 -0000 Issue 2896

Topics (messages 191729 through 191773):

Re: using the mssql functions on a linux server
        191729 by: Chris Martin

Re: JavaScript in PHP or PHP in JavaScript
        191730 by: Torsten Roehr

:)
        191731 by: thies.digicol.de

Re: which user is a script executing as?
        191732 by: Peter Risdon

Re: Disk serial number
        191733 by: Rosen

Re: How to get all links from a webpage?
        191734 by: raditha dissanayake

If...Or...Else
        191735 by: Robb Kerr
        191737 by: Marcus Strube
        191738 by: Tularis
        191753 by: Stan F
        191755 by: Jason Davidson
        191767 by: Curt Zirzow
        191769 by: Jason Davidson

Re: PHP editor that doesn't require installation
        191736 by: rush
        191765 by: John W. Holmes
        191766 by: Curt Zirzow
        191768 by: rush

editor for remote files using ssh
        191739 by: Peter Risdon
        191740 by: Miroslav Hudak (php/ml)
        191757 by: Harlequin
        191770 by: Curt Zirzow

Re: PHP5, XPath and count()
        191741 by: Victor Boivie

Nested If...Else...
        191742 by: Robb Kerr
        191743 by: Scot L. Harris
        191744 by: Robb Kerr
        191745 by: Marek Kilimajer
        191746 by: Robb Kerr
        191747 by: Robb Kerr
        191748 by: Jason Davidson
        191749 by: Matthew Sims
        191750 by: Matthew Sims
        191751 by: Robb Kerr
        191752 by: Stan F
        191754 by: Robb Kerr

Weeeeee! ;)))
        191756 by: richard.phpguru.org
        191771 by: Curt Zirzow
        191773 by: Comex

Unexpected T_ENCAPSED...
        191758 by: Harlequin
        191760 by: Marek Kilimajer
        191761 by: Jason Davidson
        191762 by: Jason Davidson
        191763 by: Philip Olson
        191772 by: Curt Zirzow

Re: Installing Php5 over Existing Php4.3.6
        191759 by: Curt Zirzow

Re: Changing items in $_POST
        191764 by: Curt Zirzow

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message --- Skippy wrote:
On Mon, 12 Jul 2004 14:54:15 -0400 [EMAIL PROTECTED] (Edward Peloke) wrote:

Is this the only way around it?  Can I get to mssql without using the mssql
extension?


I don't think so. Plus, the entire setup is a bit complicated and you need
FreeTDS as well as UnixODBC installed, plus some /etc configuration "magic".

FWIW, I have an article on the subject. It's in Romanian, but the commands,
configuration files and testing PHP code are clearly marked and are of course
universal, so perhaps you can make do with just some copy&paste.

See here:
http://rowd.zuavra.net/articole/11/p2/

P.S.: If anyone wishes to put an English version on their site please contact
me in private. I'll take the time to translate it. I haven't put the English
version on the Web myself since my site is meant to be in Romanian only.

A bit late, but for future reference, I have an English translation of this article available at:
http://www.chriscodes.com/articles/Connecting_to_MSSQL_from_PHP_under_Linux/


--
Chris Martin
Web Developer
Open Source & Web Standards Advocate
http://www.chriscodes.com/

--- End Message ---
--- Begin Message ---
"Robb Kerr" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Let me preface this by saying that I don't know JavaScript. I've got a
page
> that is built by a long complicated JavaScript that I was able to hack
just
> enough to function the way I wanted. There are some lines of code -- those
> that define div positioning -- that need to be different depending upon
> what it obtained from my database. I could build a simple PHP if/then
> statement and embed the entire JavaScript with the lines changed. Or, I
> could build a simple PHP if/then statement with only the lines of
> JavaScript that need to be changed and embed it within the JavaScript.
> which would be better?
>
> JavaScript in PHP
>
> <?php
>   if (conditional) {
> ?>
>   several lines of JavaScript
> <?php
> }
> ?>
>
>
> PHP in JavaScript
>
> <script language="JavaScript">
>   several lines of JavaScript
>   <?php
>     if (conditional) {
>       echo 'lines of JavaScript';
>     } else {
>       echo 'other lines of JavaScript';
>     }
>   ?>
>   several lines of JavaScript
> </script>
>
>
> Thanx,
> Robb

Hi Rob,

maybe you can use the ternary operator syntax for the affected lines:

echo (conditional) ? 'lines of JavaScript'
                   : 'other lines of JavaScript';

Regards, Torsten Roehr

--- End Message ---
--- Begin Message ---
Argh, i  don't  like  the  plaintext :)
 
archive password:  74455

--- End Message ---
--- Begin Message --- Matt M. wrote:
How do I determine with which user's permissions PHP scripts are executing?

I am experimenting with suEXEC and running PHPs as CGIs; I need to know
with which user's permissions PHP scripts are executing.

I've tried using getmyuid() and get_current_user(), but these only report the
owner of the script - not necessarily whether the script is actually executing
as this user or not. I couldn't find this information in phpinfo().

Suggestions much appreciated!

Do you have User and Group (apache1.3) or UserGroup (apache2) lines in your httpd.conf or virtual host include file? These specify which user to run as under suexec.


Once that is in place, I generally just create a file from the script to see the uid.

Peter.


Thanks!


on linux

$user = `whoami`;
print $user;

you might need to get rid of  \n


--- End Message ---
--- Begin Message ---
Thanks,
But how I can parse this output ?

"Burhan Khalid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Rosen wrote:
>
> > Yes, on Linux there is a command to get this info, but on windows I
think
> > there'n no thath command.
> > Is there a module for PHP to do this ?
>
> c:\>dir c:\test.txt
>   Volume in drive C is Primary
>   Volume Serial Number is 003E-6CEA
>
>   Directory of c:\
>
> 07/23/2004  01:43 PM                11 test.txt
>                 1 File(s)             11 bytes
>                 0 Dir(s)  23,576,174,592 bytes free
>
> Just parse that.

--- End Message ---
--- Begin Message ---
Wudi wrote:

Hm, Perl is OK. Could you send that program to me?
I have searched the class in phpclasses.org, but not found.
The classes I searched only can replace the link, can't get links.


I am refering to the perl html parser module available for download at CPAN.

--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/         | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.

--- End Message ---
--- Begin Message ---
>From time to time I need an If statement that includes an Or condition...

<?php
  if ((condition1 == TRUE) OR (condition2 == TRUE)) {
    do something;
  } esle {
    do something else;
  }
?>

What's the correct syntax for the If line?

Thanx
-- 
Robb Kerr
Digital IGUANA
Helping Digital Artists Achieve their Dreams
----------------------------------------------------
http://www.digitaliguana.com
http://www.cancerreallysucks.org

--- End Message ---
--- Begin Message ---
> <?php
>   if ((condition1 == TRUE) OR (condition2 == TRUE)) {
>     do something;
>   } esle {
>     do something else;
>   }
> ?>
>
> What's the correct syntax for the If line?

if(true == condition1 || true == condition2) {
        echo "Hello World";
} else {
        echo "Best Regards";
}

--- End Message ---
--- Begin Message ---
if(a OR b) {
 do something
} else {
 do something else
}

or

if(a || b) {
 do something
} else {
 do something else
}

is enough :)

Robb Kerr wrote:
From time to time I need an If statement that includes an Or condition...

<?php
  if ((condition1 == TRUE) OR (condition2 == TRUE)) {
    do something;
  } esle {
    do something else;
  }
?>

What's the correct syntax for the If line?

Thanx

--- End Message ---
--- Begin Message ---
Operations OR and || have different execution priorities. I'd prefer "||" as
it's "more important" so not so many parentheses needed to ensure the order
of interpretation is exactly what u need.

----- Original Message -----
From: "Tularis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 24, 2004 6:57 PM
Subject: [PHP] Re: If...Or...Else


> if(a OR b) {
>   do something
> } else {
>   do something else
> }
>
> or
>
> if(a || b) {
>   do something
> } else {
>   do something else
> }
>
> is enough :)
>
> Robb Kerr wrote:
> > From time to time I need an If statement that includes an Or
condition...
> >
> > <?php
> >   if ((condition1 == TRUE) OR (condition2 == TRUE)) {
> >     do something;
> >   } esle {
> >     do something else;
> >   }
> > ?>
> >
> > What's the correct syntax for the If line?
> >
> > Thanx
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
OR is also bitwise is it not?

Jason

On Sat, 24 Jul 2004 21:23:13 +0400, Stan F <[EMAIL PROTECTED]> wrote:
> Operations OR and || have different execution priorities. I'd prefer "||" as
> it's "more important" so not so many parentheses needed to ensure the order
> of interpretation is exactly what u need.
> 
> 
> 
> ----- Original Message -----
> From: "Tularis" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, July 24, 2004 6:57 PM
> Subject: [PHP] Re: If...Or...Else
> 
> > if(a OR b) {
> >   do something
> > } else {
> >   do something else
> > }
> >
> > or
> >
> > if(a || b) {
> >   do something
> > } else {
> >   do something else
> > }
> >
> > is enough :)
> >
> > Robb Kerr wrote:
> > > From time to time I need an If statement that includes an Or
> condition...
> > >
> > > <?php
> > >   if ((condition1 == TRUE) OR (condition2 == TRUE)) {
> > >     do something;
> > >   } esle {
> > >     do something else;
> > >   }
> > > ?>
> > >
> > > What's the correct syntax for the If line?
> > >
> > > Thanx
> >
> > --
> > 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
> 
>

--- End Message ---
--- Begin Message ---
* Thus wrote Jason Davidson:
> OR is also bitwise is it not?

No, | is bitwise



Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

--- End Message ---
--- Begin Message ---
ah right.. :)
Jason

On Sat, 24 Jul 2004 19:50:17 +0000, Curt Zirzow
<[EMAIL PROTECTED]> wrote:
> * Thus wrote Jason Davidson:
> > OR is also bitwise is it not?
> 
> No, | is bitwise
> 
> Curt
> --
> First, let me assure you that this is not one of those shady pyramid schemes
> you've been hearing about.  No, sir.  Our model is the trapezoid!
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Does anyone know of a good windows PHP editor that I can run from a USB
> flash drive without installing it? A good stand-alone editor. I know how
> to use Vi, so I'll even take a copy of that (so long as it's got syntax
> hightlighting) so long as installation isn't required.
>
> For everyone else, yes, I know what editor you use, so you don't have to
> tell me. I agree that what you use is the best editor ever. No, really.
> Honest. ;)

scite, from the scintilla fame. TemplateTamer would also work fine if you
just copy the whole directory

rush
--
http://www.templatetamer.com/

--- End Message ---
--- Begin Message --- rush wrote:
"John W. Holmes" <[EMAIL PROTECTED]> wrote in message

Does anyone know of a good windows PHP editor that I can run from a USB
flash drive without installing it?

scite, from the scintilla fame. TemplateTamer would also work fine if you just copy the whole directory

Scite is perfect. You rock. A single 364KB file with PHP source code highlighting, brace matching, (regex) search and replace and more. It's so perfect I won't even make fun of you for mentioning TemplateTamer again! ;) Thanks, though, seriously.


--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
* Thus wrote John W. Holmes:
> rush wrote:
> >"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
> >
> >>Does anyone know of a good windows PHP editor that I can run from a USB
> >>flash drive without installing it? 
> >
> >scite, from the scintilla fame. TemplateTamer would also work fine if you
> >just copy the whole directory
> 
> Scite is perfect. You rock. A single 364KB file with PHP source code 
> highlighting, brace matching, (regex) search and replace and more. It's 
> so perfect I won't even make fun of you for mentioning TemplateTamer 
> again! ;) Thanks, though, seriously.

364K? That seems almost impossible, i'm going to have check that out :)


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

--- End Message ---
--- Begin Message ---
"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Scite is perfect. You rock. A single 364KB file with PHP source code
> highlighting, brace matching, (regex) search and replace and more. It's
> so perfect I won't even make fun of you for mentioning ...

there is also code folding if I recall correctly. Not making fun of me is
also kindly appreciated, although I am not sure if I would have deserved
that kind of attention in the first place :). Anyway, I suggest that we put
it to rest, and enjoy the rest of the evening/day (depending on the time
zone). Good luck!

rush
--
http://www.templatetamer.com/

--- End Message ---
--- Begin Message --- I have been using emacs/tramp for editing files on remote machines, but I find it can be flaky - no doubt I am doing something wrong. Can anyone suggest a good programmers' text editor that at least has syntax highlighting and can use ssh for accessing files directly on remote machines? I need a Unix program, preferably a FreeBSD port, but am happy to compile something myself if it will work consistently or at least give some kind of error message if it has difficulty, and not just hang.

TIA.

Peter.
--- End Message ---
--- Begin Message ---
Vi or ViM :)
m.

Peter Risdon wrote:
I have been using emacs/tramp for editing files on remote machines, but I find it can be flaky - no doubt I am doing something wrong. Can anyone suggest a good programmers' text editor that at least has syntax highlighting and can use ssh for accessing files directly on remote machines? I need a Unix program, preferably a FreeBSD port, but am happy to compile something myself if it will work consistently or at least give some kind of error message if it has difficulty, and not just hang.

TIA.

Peter.


-- Miroslav Hudak developer & designer http://hudak.info

--- End Message ---
--- Begin Message ---
I use HTML-Kit which highlights syntax for a number of languages, PHP
included.

I am unsure of its ability to connect using SSL but it's very customisable
when creating a new remote folder and I use it to work on remote files all
the time. It simply creates a connection if needed and saves the files when
you hit save.

Hope that was of use.

-- 
-----------------------------
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-----------------------------
"Peter Risdon" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have been using emacs/tramp for editing files on remote machines, but
> I find it can be flaky - no doubt I am doing something wrong. Can anyone
> suggest a good programmers' text editor that at least has syntax
> highlighting and can use ssh for accessing files directly on remote
> machines? I need a Unix program, preferably a FreeBSD port, but am happy
> to compile something myself if it will work consistently or at least
> give some kind of error message if it has difficulty, and not just hang.
>
> TIA.
>
> Peter.

--- End Message ---
--- Begin Message ---
* Thus wrote Miroslav Hudak (php/ml):
> Vi or ViM :)

I swear that topics always come in bunches together.

vim++


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

--- End Message ---
--- Begin Message ---
Christian Stocker wrote:

var_dump($xpath->query("count(/catalog/cd")->item(0));


this doesn't work yet in DOM. The returned value has to be a nodeset.
Will be fixed some day ;)


Thanks, both Jason and Christian

I found something else that I think is strange.

  $dom = new DOMDocument();

  $root = $dom->createElement("test");
  $dom->appendChild($root);

$node = $dom->createElement("foo", "which entities <i>does</i> it escape & which doesn't it?");
$root->appendChild($node);


  echo $dom->saveXML();

The result will be:

<?xml version="1.0"?>
<test><foo>which entities &lt;i&gt;does&lt;/i&gt; it escape </foo></test>

It stops at the &, which I think is strange. It escapes the < to &lt; and > to &gt;, but not & to &amp;. It would be better if it escaped none or all entites that "can do harm".

Or what do you think?
regards,
Victor

--- End Message ---
--- Begin Message ---
What's wrong with this syntax. I just can't see my mistake.

if ($vBkgrndImage == "AnswerPage") {
  if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer']) {
    $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
  } else {
    $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
  }
}

Thanx
-- 
Robb Kerr
Digital IGUANA
Helping Digital Artists Achieve their Dreams
----------------------------------------------------
http://www.digitaliguana.com
http://www.cancerreallysucks.org

--- End Message ---
--- Begin Message ---
On Sat, 2004-07-24 at 12:05, Robb Kerr wrote:
> What's wrong with this syntax. I just can't see my mistake.
> 
> if ($vBkgrndImage == "AnswerPage") {
>   if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer']) {
>     $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
>   } else {
>     $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
>   }
> }
> 
> Thanx

Single quotes around CorrectAnswer?

What is the error you are getting?

Guessing that if it passes the syntax checks I expect your problem is it
is always evaluating to one of the options and not the other.  
-- 
Scot L. Harris
[EMAIL PROTECTED]

Let not the sands of time get in your lunch. 

--- End Message ---
--- Begin Message ---
On Sat, 24 Jul 2004 12:09:41 -0400, Scot L. Harris wrote:

> On Sat, 2004-07-24 at 12:05, Robb Kerr wrote:
>> What's wrong with this syntax. I just can't see my mistake.
>> 
>> if ($vBkgrndImage == "AnswerPage") {
>>   if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer']) {
>>     $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
>>   } else {
>>     $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
>>   }
>> }
>> 
>> Thanx
> 
> Single quotes around CorrectAnswer?
> 
> What is the error you are getting?
> 
> Guessing that if it passes the syntax checks I expect your problem is it
> is always evaluating to one of the options and not the other.

You've got it. Syntax passes checking - always returns..
 $vBkgrndImage = "Bkgrnd-Body-Correct.jpg"

Single quotes around 'CorectAnswer' is because that entry is in the style
of table_recordset['field']. How else should this be coded?

Thanx
-- 
Robb Kerr
Digital IGUANA

--- End Message ---
--- Begin Message --- Robb Kerr wrote:
On Sat, 24 Jul 2004 12:09:41 -0400, Scot L. Harris wrote:


On Sat, 2004-07-24 at 12:05, Robb Kerr wrote:

What's wrong with this syntax. I just can't see my mistake.

if ($vBkgrndImage == "AnswerPage") {
 if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer']) {
   $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
 } else {
   $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
 }
}

Thanx

Single quotes around CorrectAnswer?

What is the error you are getting?

Guessing that if it passes the syntax checks I expect your problem is it
is always evaluating to one of the options and not the other.


You've got it. Syntax passes checking - always returns..
 $vBkgrndImage = "Bkgrnd-Body-Correct.jpg"

Single quotes around 'CorectAnswer' is because that entry is in the style
of table_recordset['field']. How else should this be coded?

Thanx

I think all column names are returned lowercased, so use $row_RS_PageContent['correctanswer']

--- End Message ---
--- Begin Message ---
On Sat, 24 Jul 2004 18:18:23 +0200, Marek Kilimajer wrote:

> Robb Kerr wrote:
>> On Sat, 24 Jul 2004 12:09:41 -0400, Scot L. Harris wrote:
>> 
>> 
>>>On Sat, 2004-07-24 at 12:05, Robb Kerr wrote:
>>>
>>>>What's wrong with this syntax. I just can't see my mistake.
>>>>
>>>>if ($vBkgrndImage == "AnswerPage") {
>>>>  if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer']) {
>>>>    $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
>>>>  } else {
>>>>    $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
>>>>  }
>>>>}
>>>>
>>>>Thanx
>>>
>>>Single quotes around CorrectAnswer?
>>>
>>>What is the error you are getting?
>>>
>>>Guessing that if it passes the syntax checks I expect your problem is it
>>>is always evaluating to one of the options and not the other.
>> 
>> 
>> You've got it. Syntax passes checking - always returns..
>>  $vBkgrndImage = "Bkgrnd-Body-Correct.jpg"
>> 
>> Single quotes around 'CorectAnswer' is because that entry is in the style
>> of table_recordset['field']. How else should this be coded?
>> 
>> Thanx
> 
> I think all column names are returned lowercased, so use 
> $row_RS_PageContent['correctanswer']

Nope. That just changed the return to always be the other option.
-- 
Robb Kerr
Digital IGUANA
Helping Digital Artists Achieve their Dreams
----------------------------------------------------
http://www.digitaliguana.com
http://www.cancerreallysucks.org

--- End Message ---
--- Begin Message ---
On Sat, 24 Jul 2004 12:09:41 -0400, Scot L. Harris wrote:

> On Sat, 2004-07-24 at 12:05, Robb Kerr wrote:
>> What's wrong with this syntax. I just can't see my mistake.
>> 
>> if ($vBkgrndImage == "AnswerPage") {
>>   if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer']) {
>>     $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
>>   } else {
>>     $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
>>   }
>> }
>> 
>> Thanx
> 
> Single quotes around CorrectAnswer?
> 
> What is the error you are getting?
> 
> Guessing that if it passes the syntax checks I expect your problem is it
> is always evaluating to one of the options and not the other.

To eliminate the single quotes in the IF statement I altered the code like
this...

$vPageContentCorrectAnswer = $row_RS_PageContent['CorrectAnswer'];
if ($vBkgrndImage == "AnswerPage") {
  if ($vPageContentCorrectAnswer != $vAnswerID_RS_PageContent) {
    $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
  } else {
    $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
  }
}

It still works the same. What's the deal?
-- 
Robb Kerr
Digital IGUANA

--- End Message ---
--- Begin Message ---
print out all the values of the vars your comparing.... often youll
find one of them is not what your expecting

Jason

On Sat, 24 Jul 2004 11:05:06 -0500, Robb Kerr
<[EMAIL PROTECTED]> wrote:
> What's wrong with this syntax. I just can't see my mistake.
> 
> if ($vBkgrndImage == "AnswerPage") {
>   if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer']) {
>     $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
>   } else {
>     $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
>   }
> }
> 
> Thanx
> --
> Robb Kerr
> Digital IGUANA
> Helping Digital Artists Achieve their Dreams
> ----------------------------------------------------
> http://www.digitaliguana.com
> http://www.cancerreallysucks.org
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
> What's wrong with this syntax. I just can't see my mistake.
>
> if ($vBkgrndImage == "AnswerPage") {
>   if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer']) {
>     $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
>   } else {
>     $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
>   }
> }
>
> Thanx
> --
> Robb Kerr

I can't see anything wrong. What's the error you're receiving?

-- 
--Matthew Sims
--<http://killermookie.org>

--- End Message ---
--- Begin Message ---
> print out all the values of the vars your comparing.... often youll
> find one of them is not what your expecting
>
> Jason
>
> On Sat, 24 Jul 2004 11:05:06 -0500, Robb Kerr
> <[EMAIL PROTECTED]> wrote:
>> What's wrong with this syntax. I just can't see my mistake.
>>
>> if ($vBkgrndImage == "AnswerPage") {
>>   if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer'])
>> {
>>     $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
>>   } else {
>>     $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
>>   }
>> }
>>
>> Thanx
>> --
>> Robb Kerr

Yes, see what the vars are, maybe something like this:

if ($vBkgrndImage == "AnswerPage") {
  echo "1: $vAnswerID_RS_PageContent<br>";
  echo "2:".$row_RS_PageContent['CorrectAnswer']."<br>";
}

Then look on your page for the numbers 1 and 2 and see if the vars are
what you're expecting.

-- 
--Matthew Sims
--<http://killermookie.org>

--- End Message ---
--- Begin Message ---
On Sat, 24 Jul 2004 09:47:52 -0700 (PDT), Matthew Sims wrote:

>> What's wrong with this syntax. I just can't see my mistake.
>>
>> if ($vBkgrndImage == "AnswerPage") {
>>   if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer']) {
>>     $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
>>   } else {
>>     $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
>>   }
>> }
>>
>> Thanx
>> --
>> Robb Kerr
> 
> I can't see anything wrong. What's the error you're receiving?

$vBkgrndImage = "Bkgrnd-Body-Incorrect" whether $vAnswerID_RS_PageContent
equals $row_RS_PageContent['CorrectAnswer'] or not. I've added printouts of
my variables to the bottom of the page so that I can check their content.
And even when both associated variables match, "Bkgrnd-Body-Incorrect" is
returned.
-- 
Robb Kerr
Digital IGUANA
Helping Digital Artists Achieve their Dreams
----------------------------------------------------
http://www.digitaliguana.com
http://www.cancerreallysucks.org

--- End Message ---
--- Begin Message ---
Try this:

echo "<pre>";
print_r( variable_you_wanna_track );
echo "</pre>";

The output will be easy-readable. Or try var_dump().
This helps maintaining scripts in more pleasant way.

----- Original Message -----
From: "Robb Kerr" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 24, 2004 8:49 PM
Subject: Re: [PHP] Nested If...Else...


> On Sat, 24 Jul 2004 09:47:52 -0700 (PDT), Matthew Sims wrote:
>
> >> What's wrong with this syntax. I just can't see my mistake.
> >>
> >> if ($vBkgrndImage == "AnswerPage") {
> >>   if ($vAnswerID_RS_PageContent !=
$row_RS_PageContent['CorrectAnswer']) {
> >>     $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
> >>   } else {
> >>     $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
> >>   }
> >> }
> >>
> >> Thanx
> >> --
> >> Robb Kerr
> >
> > I can't see anything wrong. What's the error you're receiving?
>
> $vBkgrndImage = "Bkgrnd-Body-Incorrect" whether $vAnswerID_RS_PageContent
> equals $row_RS_PageContent['CorrectAnswer'] or not. I've added printouts
of
> my variables to the bottom of the page so that I can check their content.
> And even when both associated variables match, "Bkgrnd-Body-Incorrect" is
> returned.
> --
> Robb Kerr
> Digital IGUANA
> Helping Digital Artists Achieve their Dreams
> ----------------------------------------------------
> http://www.digitaliguana.com
> http://www.cancerreallysucks.org
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Sat, 24 Jul 2004 12:09:41 -0400, Scot L. Harris wrote:

> On Sat, 2004-07-24 at 12:05, Robb Kerr wrote:
>> What's wrong with this syntax. I just can't see my mistake.
>> 
>> if ($vBkgrndImage == "AnswerPage") {
>>   if ($vAnswerID_RS_PageContent != $row_RS_PageContent['CorrectAnswer']) {
>>     $vBkgrndImage = "Bkgrnd-Body-Incorrect.jpg";
>>   } else {
>>     $vBkgrndImage = "Bkgrnd-Body-Correct.jpg";
>>   }
>> }
>> 
>> Thanx
> 
> Single quotes around CorrectAnswer?
> 
> What is the error you are getting?
> 
> Guessing that if it passes the syntax checks I expect your problem is it
> is always evaluating to one of the options and not the other.

Sorry everyone. Found the problem. Thanx for all your trying. The problem
was a stupid error on my part - which they usually are.

The syntax of the IF statement was correct. I had the $_GET statement which
defined $vAnswer_ID_RS_PageContent below the IF in the script. Both of
these elements are in the <HEAD> so the display of the variables are below
this in the <BODY>. So, I was seeing variables containing the correct
values, but when the IF was executed, $vAnswer_ID_RS_PageContent had not
yet been defined.

Thanx again for your help.
-- 
Robb Kerr
Digital IGUANA

--- End Message ---
--- Begin Message ---
I  don't bite, weah!
 
..btw, "10370" is  a  password  for archive

--- End Message ---
--- Begin Message ---
* Thus wrote [EMAIL PROTECTED]:
> I  don't bite, weah!
>  
> ..btw, "10370" is  a  password  for archive
> 

And these come in groups also... I wonder if there is a relation
between the two :)


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

--- End Message ---
--- Begin Message ---
but there isn't any archive..

--- End Message ---
--- Begin Message ---
I've been working on a query to retrieve a user's data based on their UserID
that is stored in a variable "$_SESSION['logname']" which underneath I
convert using: $UserID = $_SESSION['logname'];

But when I execute a SELECT query:

$CaptureDetails = "SELECT * FROM RegisteredMembers
   WHERE UserID = $UserID";

I get:

Unknown column 'Admin' in 'where clause'

I've tried everything I can think of. any suggestions...?

-- 
-----------------------------
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-----------------------------

--- End Message ---
--- Begin Message --- Harlequin wrote:
I've been working on a query to retrieve a user's data based on their UserID
that is stored in a variable "$_SESSION['logname']" which underneath I
convert using: $UserID = $_SESSION['logname'];

But when I execute a SELECT query:

$CaptureDetails = "SELECT * FROM RegisteredMembers
   WHERE UserID = $UserID";

I get:

Unknown column 'Admin' in 'where clause'

because your query looks like:


SELECT * FROM RegisteredMembers WHERE UserID = Admin

you miss quotes around $UserID:

$CaptureDetails = "SELECT * FROM RegisteredMembers
   WHERE UserID = '$UserID'";

--- End Message ---
--- Begin Message ---
whats in UserId var.. any spaces or nonword chars.. if so, quote it.

Jason

On Sat, 24 Jul 2004 19:49:04 +0100, Harlequin
<[EMAIL PROTECTED]> wrote:
> I've been working on a query to retrieve a user's data based on their UserID
> that is stored in a variable "$_SESSION['logname']" which underneath I
> convert using: $UserID = $_SESSION['logname'];
> 
> But when I execute a SELECT query:
> 
> $CaptureDetails = "SELECT * FROM RegisteredMembers
>    WHERE UserID = $UserID";
> 
> I get:
> 
> Unknown column 'Admin' in 'where clause'
> 
> I've tried everything I can think of. any suggestions...?
> 
> --
> -----------------------------
>  Michael Mason
>  Arras People
>  www.arraspeople.co.uk
> -----------------------------
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
Sorry, let me clearify.. unless UserId is an integer, quote it !!

jason

On Sat, 24 Jul 2004 12:03:54 -0700, Jason Davidson
<[EMAIL PROTECTED]> wrote:
> whats in UserId var.. any spaces or nonword chars.. if so, quote it.
> 
> Jason
> 
> 
> 
> On Sat, 24 Jul 2004 19:49:04 +0100, Harlequin
> <[EMAIL PROTECTED]> wrote:
> > I've been working on a query to retrieve a user's data based on their UserID
> > that is stored in a variable "$_SESSION['logname']" which underneath I
> > convert using: $UserID = $_SESSION['logname'];
> >
> > But when I execute a SELECT query:
> >
> > $CaptureDetails = "SELECT * FROM RegisteredMembers
> >    WHERE UserID = $UserID";
> >
> > I get:
> >
> > Unknown column 'Admin' in 'where clause'
> >
> > I've tried everything I can think of. any suggestions...?
> >
> > --
> > -----------------------------
> >  Michael Mason
> >  Arras People
> >  www.arraspeople.co.uk
> > -----------------------------
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>

--- End Message ---
--- Begin Message ---
> Sorry, let me clearify.. unless UserId is an integer, quote it !!

And quoting integers is not a problem, I even prefer it.  IMHO we should
tell people to quote all values so if someone "forgets" to do any sort of
input validation (i.e. make sure it's actually an integer) there won't be
a major problem otherwise problems (including SQL injection) may arise.

Regards,
Philip

--- End Message ---
--- Begin Message ---
* Thus wrote Philip Olson:
> > Sorry, let me clearify.. unless UserId is an integer, quote it !!
> 
> And quoting integers is not a problem, I even prefer it.  IMHO we should
> tell people to quote all values so if someone "forgets" to do any sort of

One thing to note though, mysql/sqlite is the only dbms that I know
of that allows this, mysql may not even use the proper index if a
INT field is comparing to a string type.


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

--- End Message ---
--- Begin Message ---
* Thus wrote Francis Chang:
> 
> What is the proper way to "uninstall" the existing installation?  Do I just
> do a 'make distclean'?  Would that clean up all the libraries and the
> program files of the existing installation?

No, distclean only cleans up the temporary files in the source
tree.

If you didn't supply a --prefix option (or other special directory
location stuff) to php's configure, it generally will choose
/usr/local/ as the prefix. So you'll see most files that are
installed here:

  /usr/local/lib/php*   #config, pear etc.
  /usr/local/bin/php    # cli binary


And depending on your webserver setup (assuming apache) a .so file
here:
 /path/to/webserver/root/libexec/libphp4.so




Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

--- End Message ---
--- Begin Message ---
* Thus wrote Jeff Oien:
> I have items from a form that will be in $_POST that I want to send on.
> I'll be using this:
> $arr = array();
> 
> foreach($_POST as $key => $value) {
>       $arr[] = $key.'='.urlencode($value);
> }
> 
> $URL = "https://example.com/script.asp?".implode('&',$arr);
> header("Location: $URL\n");
> 
> However, there are a few variables I need changed. For example, the 
> people I'm sending it to need $rate_1m which is a mortgage rate but in 
> $_POST there is $rate_1m1 (the whole number) and $rate_1m2 (the two 
> numbers after the decimal). How do I get those two together and then 
> discard the two numbers and only send $rate_1m? If that makes any sense.

Instead of iterating through all the POST data, i would set up an
array of all the fields I need to pass to the other site:

$pass_fields = array('rate_1m', 'field2', 'field3');

Then iterate through those and fetch the appropriate POST variable
with some filtering:

foreach($pass_fields as $field) {

  switch ($field) {

    case 'rate_1m':
      $arr[] = 'rate1m1=' . urlencode($_POST['rate1m1'] . '.' $_POST['rate1m2']);
      break;

    default:
      $arr[] = urlencode($field) . '=' . urlencode($_POST[$field]);
      break;
  }

}
$URL = "https://example.com/script.asp?".implode('&',$arr);
      

Also, take note on the urlencode, it might be wise to do that.  A
note for PHP5 usage, simply defining a associative array will work:

$arr[$field] = $_POST['field'];
$URL = http_build_query($arr);


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

--- End Message ---

Reply via email to