php-windows Digest 25 Jul 2005 09:12:18 -0000 Issue 2737

Topics (messages 26227 through 26229):

My Short Variable is not working
        26227 by: disguised.jedi.gmail.com

Strange mysql/pear db  self join help needed.
        26228 by: Jim MacDiarmid
        26229 by: Mark Rees

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 ---
Please remember to post to the list by clicking the "Reply to All" button.

I don't know about those books, but perhaps someone on the list can help you!

---------- Forwarded message ----------
From: Afolabi Richard <[EMAIL PROTECTED]>
Date: Jul 23, 2005 1:41 PM
Subject: Re: [PHP-WIN] My Short Variable is not working
To: [EMAIL PROTECTED]


Thankx disguised.jedi, 
  
I have turned the register_globals = Off. And my stuff is working fine
now when I restarted my Apache Server. Thankx for ur help.
  
Meanwhile could U pls help by giving recommendations on these books
before I buy them, I don't want to throw away money as I did recently
on some books.
Thankx 
  
PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
by Larry Ullman 
  
Dreamweaver MX: PHP Web Development 

Professional PHP4 Multimedia Programming  

Sams Teach Yourself PHP, MySQL and Apache in 24 Hours
by Julie C. Meloni 


[EMAIL PROTECTED] wrote:
 
On 7/22/05, Afolabi Richard wrote:
> Hi all,
> 
> I am a PHP newbie using WAMP5 version 1.1
> 
> I have tried coding PHP and I see it as very interesting and fascinating. 
> however, I have a > challenge: My short variables e.g "$names", "$email" are 
> not working when I use "echo" > command with it, except I use "echo 
> $_POST[fieldname]". meanwhile, I set the
> "global_registers = On" in my php.ini file but the story is the same.
It's register_globals, and it shouldn't be turned on. It allows
ANYONE to define ANY VARIABLE in your script. Not a good idea. 
Search your php.ini file for the phrase "register_globals" and set it
to on, and the sample you attached will work (even though it's
insecure).

Also, you should do $_POST["fieldname"] instead of $_POST[fieldname]. 
They'll both work (I believe) but the first is the correct way to do
it, you are accessing a named key with the name of that string.

> 
> Is there something else I have not done, pls help I am getting to LOVE PHP 
> and MYSQL.

Good, I agree...It can be really fun once you get to know it!


-- 
PHP rocks!
"Knowledge is Power. Power Corrupts. Go to school, become evil"

Disclaimer: Any disclaimer attached to this message may be ignored. 
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.

This message is Certified Virus Free

-- 
PHP rocks!
"Knowledge is Power.  Power Corrupts.  Go to school, become evil"

Disclaimer: Any disclaimer attached to this message may be ignored. 
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.

This message is Certified Virus Free

--- End Message ---
--- Begin Message ---
Can someone answer a MySQL question for me?  I'm trying to do a self join on
my category table and I'm only coming up with 2 fields in my recordset when
I know I should have 5 fields. Here is the code I'm using. 

>SELECT Cats3.CatId, Cats.Cat, Cats1.Cat, Cats2.Cat, Cats3.Cat 
>FROM (((Cats As Cats3 left JOIN Cats As Cats2 ON Cats3.ParentId =
Cats2.CatId)
>LEFT JOIN Cats As Cats1 ON Cats2.ParentId = Cats1.CatId) 
>LEFT JOIN Cats As Cats ON Cats1.ParentId = Cats.CatId) 
>WHERE Cats3.CatTypeId = 2 AND Cats.ParentId is NULL 
>ORDER BY (Cats.Cat + Cats1.Cat + Cats2.Cat + Cats3.Cat)


When I execute this query in something like Navcat 2005 or SQLyog it works
fine.  By the way, I'm also using the PEAR DB class.

Any ideas?

Thanks  :)

Jim MacDiarmid

--- End Message ---
--- Begin Message ---
> Can someone answer a MySQL question for me?  I'm trying to do a self join
on
> my category table and I'm only coming up with 2 fields in my recordset
when
> I know I should have 5 fields. Here is the code I'm using.
>
> >SELECT Cats3.CatId, Cats.Cat, Cats1.Cat, Cats2.Cat, Cats3.Cat
> >FROM (((Cats As Cats3 left JOIN Cats As Cats2 ON Cats3.ParentId =
> Cats2.CatId)
> >LEFT JOIN Cats As Cats1 ON Cats2.ParentId = Cats1.CatId)
> >LEFT JOIN Cats As Cats ON Cats1.ParentId = Cats.CatId)
> >WHERE Cats3.CatTypeId = 2 AND Cats.ParentId is NULL
> >ORDER BY (Cats.Cat + Cats1.Cat + Cats2.Cat + Cats3.Cat)
>
>
> When I execute this query in something like Navcat 2005 or SQLyog it works
> fine.  By the way, I'm also using the PEAR DB class.
>
> Any ideas?
>
> Thanks  :)
>
> Jim MacDiarmid

As a total guess, bearing in mind I have never used PEAR, could it be
because you only have two different field names  (Cat and CatId)? If you try
aliasing them like this, does it work?

SELECT Cats3.CatId AS Cats3ID,
Cats.Cat AS CatsCat,
Cats1.Cat AS Cats1Cat,
Cats2.Cat AS Cats2Cat,
Cats3.Cat  AS Cats3Cat

It's hard to say without some example of how you are accessing it in PHP.
If, as you say, it works OK directly in mySQL, the problem may well be with
the PHP code.

--- End Message ---

Reply via email to