Re: [PHP] [NEWBIE GUIDE] For the benefit of new members

2005-03-22 Thread Stan F
[snip]

I feel we should add this to the rules. Dunno about the others, but it
really drives mad to delete bunches of emails with equal contents posted
within 5 minute interval.

---
Please avoid sending duplicate letters to the list. If you feel your email
was not delivered properly or no-one noticed it, try sending again in a
couple of days. Reposting frequently will not help solving your problems; in
addition, members won't be much pleased if you flood 'em, so you decrease
your chances to get helpful answers.
If your mail server doesn't work properly, please pay attention to thousands
of decent free ones.
---
wbr
Stan F

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



Re: [PHP] Difficulty with SQL LIKE clause

2005-02-26 Thread Stan F

- Original Message -
From: David Freedman [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Friday, February 25, 2005 11:27 PM
Subject: [PHP] Difficulty with SQL LIKE clause


 When I use this query in PHP it works, and I get all things with the YEAR
of
 1977, as I expected.

 $query= SELECT * FROM my_table WHERE Year LIKE 1977 ;

 But, when I use this query it does not work.

 $query= SELECT * FROM my_table WHERE Year LIKE 197* ;

 I thought I should get the result of ALL things with the years in the
1970's
 (1970-1979).  But the asterisk in the LIKE clause does not seem to work.
 I have tried various syntax's to try to get the 197* recognized but
without
 any luck.

 Can the '*' be used? What am I doing wrong.


AFAIK you cannot. SQL wildcard symbols are % and _.



 David F.



 --
 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] http referer

2005-02-26 Thread Stan F

- Original Message -
From: Sebastian [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Saturday, February 26, 2005 8:31 PM
Subject: [PHP] http referer


 ok, so i made a file manager and i need to prevent people from linking
 directly to files that do not come from another part of the site.

 i know i can use http_referer, but i wonder how fool proof it is, i dont
 want to spit out errors to a legit user that actually came from a valid
page
 before trying to access the file url. some people have said http_referer
is
 not always accurate.

Never rely on it. It might be not set at all, it's easy to spoof. I would
think about sessions here.

btw this topic has been discussed much, so you probably should STFA.


 any examples, snips, would be helpful.

 --
 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] Preventing execution without inclusion

2005-01-14 Thread Stan F

- Original Message - 
From: Adam Hubscher [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Friday, January 14, 2005 1:25 AM
Subject: [PHP] Preventing execution without inclusion


 From within the application, I use one page to include 
 classes/variables and so on. Is there a way (I may have been missing it 
 in the documentation for PHP, however I didnt see anything related) to 
 prevent a user from directly accessing/executing *.php by the file 
 making sure taht it was only included by index.php?
 
 For example:
 
 config.php defines:
 
 function __autoload($class_name) {
 
 $class_name = strtolower($class_name);
 include_once('class.'.$class_name.'.php');
 }
 
 as per PHP5 example
 
 1 (the preferred way): user accesses 
 http://www.example.org/index.php?function=Join, this loads the class 
 NewUser and begins its implementation. Because of the __autoload, it 
 includes class.join.php, in order to utilize the class.
 
 2 (the wrong way): user accesses 
 http://www.example.org/includes/class.join.php without going through 
 index.php.
 
 I am trying to prevent 2 from even occuring, utilizing a piece of code 
 that would check if index.php had included it, or not. This code would 
 be in the beginning of all the class files, at the top, before any other 
   code was to be executed.

A common way to do it:

# in your index.php just before any inclusion 
define( '__INDEX__', true );

# in other files
if( !defined( '__INDEX__' ) ) die( 'You cannot execute this script' );

Sorry if I didn't get u the right way, I'm too tired..

WBR 
Stan F



 
 As of yet, it has eluded me...
 
 -- 
 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] Php error with MySql

2005-01-07 Thread Stan F

- Original Message -
From: Wil [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Thursday, January 06, 2005 9:35 PM
Subject: [PHP] Php error with MySql


 I get the following error

 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
 resource in /home/wilmail/public_html/elblog.php on line 7
 n=   //error ends here

 with the following bit of code

 $qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);


Try   echo mysql_error()  just after your query. It's rather common to
make typos or forget to select DB.

 $nRows = mysql_num_rows($qResult);
 $rString =n=.$nRows;

 If I am just naming a variable how is the argument not valid?

 Thanks,

 Wil

 --
 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] bargraph gd not working

2004-12-13 Thread Stan F

- Original Message -
From: jm [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, December 14, 2004 3:22 AM
Subject: [PHP] bargraph gd not working


 Hi guys:
 I'm using php5 on winxp with IIS. I'm trying to run a simple bar graph
demo
 found it on phpbuilder site. When I run it I get nothing but an x in the
top
 left corner of my web page(no errors nothing).
 GD is uncommented in my php.ini, ext dir set and I have verified that GD
is
 installed through php -m,phpinfo() , and gd_info(). Can anyone offer me
some
 advice on how to troubleshoot this problem.
 I searched google, and did see other posts like mine but no solutions. Any
 thoughts or suggestions would be appreciated


Do other php/gd scripts work as expected?
(ie display images)
Do you send the correct headers to browser?
Please show us the code cuz without it it's not so easy to help.

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



HTH
Stan F

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



Re: [PHP] Nested If...Else...

2004-07-24 Thread Stan F
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



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



Re: [PHP] Re: If...Or...Else

2004-07-24 Thread Stan F
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



Re: [PHP] Very weird issue....

2004-07-20 Thread Stan F

- Original Message -
From: Alex Shi [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 21, 2004 1:39 AM
Subject: [PHP] Very weird issue


 Hi all,

 Please take a look at following very simple script;

 #!/usr/bin/php -q
 ?
 echo Hello, world!\n;
 if (!$tty) {
 $tty = fopen('php://stdin', 'r');
 }
 print Hello: ;
 $ch = fgets($tty, 1024);
 print $ch\n;
 ?

 I tested it on many servers. Here is how it running (you can
 figure out yourself): Firstly it displays Hello, world!, then
 displays Hello:  at second line and waits for user input;
 You input a yes and it displays the yes; then end. So, on
 the screen you will see:

 Hello, world!
 Hello: yes
 yes

 However, on one of the servers, it doesn't run like above,
 but in a reversed way: Firstly, it displays nothing but waits
 for your input; you input a yes, then it displays the yes,
 then Hello, world!, then Hello: yes. So, on the screen it
 looks like this:

 yes
 Hello, world!
 Hello: yes

 Weird? To me IT IS! I really don't understand why all the
 echos/prints did not function until the script got data from
 tty, even they are before fgets..

 I found this issue during an unsuccessfull pear installation.
 The pear installer stopped and waited for my input without
 any prompt - there is prompt message but not displayed!

 Can anyone let me know how this can happen? Thanks
 in advance!

 Alex

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



I remember this used to happen in c++ because of buffering; there you had to
tie STDIN and STDOUT in some cases: cin.tie ( cout );
Input and output having strict order in program could follow each other not
the way you expected.
So I see it's caused by stream handling and buffering.

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