473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Hello again

Help again

This works

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

This doesn't

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <=
$session->userleve)";

I seem to have missed something about concatenation

Len Bell
Jun 2 '08 #1
16 1019
lenbell wrote:
$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

This doesn't

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <=
$session->userleve)";
To use $session->userleve ?
".... <= {$session->userleve})";

Heiko

--
http://portal.richler.de/ Namensportal zu Richler
http://www.richler.de/ Heiko Richler: Computer - Know How!
http://www.richler.info/ private Homepage
Jun 2 '08 #2
lenbell wrote:
Help again

This works

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

This doesn't

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <=
$session->userleve)";

I seem to have missed something about concatenation

Len Bell
I would tend to write that as a JOIN rather than a correalted sub-query.

However, regardless of that, telling us that something "doesn't work" is
pointless. In precisely what way does it not work?
Jun 2 '08 #3
lenbell wrote:
Help again

This works

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

This doesn't

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <=
$session->userleve)";

I seem to have missed something about concatenation
Hint: When you have a query that doesn't work, put a print of the
query. You will then readily find what is wrong in building the query
(missing ' or something else), or when you try it using phpMyAdmin
directly, it will tell you where the error is.
Jun 2 '08 #4
lenbell wrote:
Help again

This works

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

This doesn't

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <=
$session->userleve)";

I seem to have missed something about concatenation

Len Bell

Maybe ask in a SQL newsgroup (or one for your database)? This isn't a
PHP question, after all.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 2 '08 #5
On May 23, 9:30*pm, "lenbell" <lsb...@charter.netwrote:
Help again

This works

* *$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenetsWHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

This doesn't

* * *$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <=
$session->userleve)";

I seem to have missed something about concatenation

Len Bell
$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <= '" .
$session->userleve . "')";

or

$q = "SELECT * FROM groupnames LEFT JOIN tenets ON groupnames.groupnum
= tenents.groupnum AND tenets.level <= '" .
$session->userleve . "')";
Jun 2 '08 #6
Jerry Stuckle wrote:
lenbell wrote:
>Help again

This works

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

This doesn't

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <=
$session->userleve)";

I seem to have missed something about concatenation

Len Bell

Maybe ask in a SQL newsgroup (or one for your database)? This isn't a
PHP question, after all.
Actually, Jerry, it is. He is having trouble building the query when he
uses a php variable rather than a constant. That kind of makes it a php
question.

For the OP, are you sure you meant userleve and not userlevel?

Jun 2 '08 #7
sheldonlg wrote:
Jerry Stuckle wrote:
>lenbell wrote:
>>Help again

This works

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

This doesn't

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM
tenets WHERE groupnames.groupnum = tenets.groupnum AND tenets.level
<= $session->userleve)";

I seem to have missed something about concatenation

Len Bell

Maybe ask in a SQL newsgroup (or one for your database)? This isn't a
PHP question, after all.

Actually, Jerry, it is. He is having trouble building the query when he
uses a php variable rather than a constant. That kind of makes it a php
question.

For the OP, are you sure you meant userleve and not userlevel?
Then why are all of the answers SQL statements?

He needs to simply echo $q and fix his problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 2 '08 #8
Heres how I have it NOW in the php file
----------------------------------------------------
function displayGroups(){
global $database;

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '" .
$session->userlevel . "')";

echo $q;

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

echo $q;

$result = $database->query($q);
__________________________________

Here's what I get when it runs (both echos run together - small but pisses
me off)

SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '')SELECT * FROM
groupnames WHERE EXISTS (select * FROM tenets WHERE groupnames.groupnum =
tenets.groupnum AND tenets.level <= '1')

Also why can't I get those 2 echos to play on separate lines?

Thanks for your support

Len Bell

"Roger" <le*********@natpro.comwrote in message
news:7f**********************************@d45g2000 hsc.googlegroups.com...
On May 23, 9:30 pm, "lenbell" <lsb...@charter.netwrote:
Help again

This works

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

This doesn't

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <=
$session->userleve)";

I seem to have missed something about concatenation

Len Bell
$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <= '" .
$session->userleve . "')";

or

$q = "SELECT * FROM groupnames LEFT JOIN tenets ON groupnames.groupnum
= tenents.groupnum AND tenets.level <= '" .
$session->userleve . "')";
Jun 2 '08 #9
Jerry Stuckle wrote:
sheldonlg wrote:
>Jerry Stuckle wrote:
>>lenbell wrote:
Help again

This works

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

This doesn't

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM
tenets WHERE groupnames.groupnum = tenets.groupnum AND tenets.level
<= $session->userleve)";

I seem to have missed something about concatenation

Len Bell
Maybe ask in a SQL newsgroup (or one for your database)? This isn't
a PHP question, after all.

Actually, Jerry, it is. He is having trouble building the query when
he uses a php variable rather than a constant. That kind of makes it
a php question.

For the OP, are you sure you meant userleve and not userlevel?

Then why are all of the answers SQL statements?

He needs to simply echo $q and fix his problem.
That's what I told him a few replies ago.
Jun 2 '08 #10
lenbell wrote:
Heres how I have it NOW in the php file
----------------------------------------------------
function displayGroups(){
global $database;

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '" .
$session->userlevel . "')";

echo $q;

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

echo $q;

$result = $database->query($q);
__________________________________

Here's what I get when it runs (both echos run together - small but pisses
me off)

SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '')SELECT * FROM
groupnames WHERE EXISTS (select * FROM tenets WHERE groupnames.groupnum =
tenets.groupnum AND tenets.level <= '1')

Also why can't I get those 2 echos to play on separate lines?
Well, your problem is now obvious. You have nothing in
$session->userlevel. It is yielding ''. Fix that error and you are all
set.

As for the two echos, add <brto the first string and it will display
the next one on a new line.
Jun 2 '08 #11
sheldonlg
thanks for your help

Tried - echo $q;<br>
Tried - echo $q<br>;

both gave

Parse error: syntax error, unexpected '<' in
/home/host020/public_html/tenets/TenetGroupList.php on line 23

23 is the line above

There must be a scope problem with $session->userlevel and I'm looking

<sheldonlgwrote in message
news:_I******************************@giganews.com ...
lenbell wrote:
>Heres how I have it NOW in the php file
----------------------------------------------------
function displayGroups(){
global $database;

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '" .
$session->userlevel . "')";

echo $q;

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

echo $q;

$result = $database->query($q);
__________________________________

Here's what I get when it runs (both echos run together - small but
pisses me off)

SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '')SELECT *
FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')

Also why can't I get those 2 echos to play on separate lines?

Well, your problem is now obvious. You have nothing in
$session->userlevel. It is yielding ''. Fix that error and you are all
set.

As for the two echos, add <brto the first string and it will display the
next one on a new line.

Jun 2 '08 #12
Found it - Thanks sheldonlg

It was a scope problem and now it's gone <smile>

Len

<sheldonlgwrote in message
news:_I******************************@giganews.com ...
lenbell wrote:
>Heres how I have it NOW in the php file
----------------------------------------------------
function displayGroups(){
global $database;

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '" .
$session->userlevel . "')";

echo $q;

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

echo $q;

$result = $database->query($q);
__________________________________

Here's what I get when it runs (both echos run together - small but
pisses me off)

SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '')SELECT *
FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')

Also why can't I get those 2 echos to play on separate lines?

Well, your problem is now obvious. You have nothing in
$session->userlevel. It is yielding ''. Fix that error and you are all
set.

As for the two echos, add <brto the first string and it will display the
next one on a new line.

Jun 2 '08 #13
What a cleverly selected Subject:!
Jun 2 '08 #14
lenbell wrote:
sheldonlg
thanks for your help

Tried - echo $q;<br>
Tried - echo $q<br>;

both gave

Parse error: syntax error, unexpected '<' in
/home/host020/public_html/tenets/TenetGroupList.php on line 23

23 is the line above

There must be a scope problem with $session->userlevel and I'm looking

<sheldonlgwrote in message
news:_I******************************@giganews.com ...
>lenbell wrote:
>>Heres how I have it NOW in the php file
----------------------------------------------------
function displayGroups(){
global $database;

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '" .
$session->userlevel . "')";

echo $q;

$q = "SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets
WHERE groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')";

echo $q;

$result = $database->query($q);
__________________________________

Here's what I get when it runs (both echos run together - small but
pisses me off)

SELECT * FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '')SELECT *
FROM groupnames WHERE EXISTS (select * FROM tenets WHERE
groupnames.groupnum = tenets.groupnum AND tenets.level <= '1')

Also why can't I get those 2 echos to play on separate lines?
Well, your problem is now obvious. You have nothing in
$session->userlevel. It is yielding ''. Fix that error and you are all
set.

As for the two echos, add <brto the first string and it will display the
next one on a new line.

He meant:
echo "$q<br>";

It's HTML markup, not PHP.

--
Curtis
Jun 2 '08 #15
lenbell wrote:
Found it - Thanks sheldonlg

It was a scope problem and now it's gone <smile>

Len
Glad to be of help. In the future, try to think of debugging as "what
is this line seeing?". In this case it was, "what is the sql engine
seeing?". To find out do a print or an echo and then you see exactly
what it sees. Very often that will tell it to you right away (as was
here). Other times, not. For example, the sql query may have looked
correct but not run correctly. Taking the output to phpMyAdmin and
running it interactively will tell you what line is in error.

Anyway, backtracking is one of the best ways of debugging. Since we
can't set breakpoints and examine values, printing is the next best thing.
Jun 2 '08 #16
Yes and I sure do miss my break points

Thanks for the work around

<sheldonlgwrote in message
news:ta******************************@giganews.com ...
lenbell wrote:
>Found it - Thanks sheldonlg

It was a scope problem and now it's gone <smile>

Len

Glad to be of help. In the future, try to think of debugging as "what is
this line seeing?". In this case it was, "what is the sql engine
seeing?". To find out do a print or an echo and then you see exactly what
it sees. Very often that will tell it to you right away (as was here).
Other times, not. For example, the sql query may have looked correct but
not run correctly. Taking the output to phpMyAdmin and running it
interactively will tell you what line is in error.

Anyway, backtracking is one of the best ways of debugging. Since we can't
set breakpoints and examine values, printing is the next best thing.

Jun 2 '08 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Niklas Borson | last post by:
Hi gurus! I'm a C++ newbie and I've heard that a good first program is one that prints "Hello World!" I tried typing in a program I found in a book, but for some reason it wouldn't compile. So I...
4
by: Roy Yao | last post by:
Why the following code let my compiler complain an overloaded function Init()? // code begin template<class T> class BicircularList { template<class T> class Iterator; template<class T> class...
26
by: Santanu Chatterjee | last post by:
Hello all, I would like to know how an OS makes a computer boot up. For that, as a start I would like to see an e_ample (read the underscore as the letter before y, as the keyboard here is...
7
by: Calvin KD | last post by:
Hi everyone, Has someone out there experienced the same problem? What i wanted to do is to display a popup window (modal) upon the loading of a webpage. Here is my code sample (in html view):...
1
by: John Thompson | last post by:
Hello, I recently developed the hello world web service in Visual Studio 2005. If I right-click on the Service.asmx file that is created, everything works fine in Visual Studio. After...
10
by: fei.liu | last post by:
Consider the following sample code char * ptr = "hello"; char carray = "hello"; int main(void){ } What does the standard have to say about the storage requirement about ptr and carray? Is...
3
by: salvadorvp | last post by:
Hi, here I have a very simple 'hello world' example that makes use of Yahoo! User Interface Library. I have a problem with my response string coming back as ''. I managed to check that everything...
2
by: hkhellhkhell | last post by:
hello again.. i want to design a program which takes in a string and replaces all 's' characters with 'sh'. how do i do it? thanks a lot!
14
by: Vasu | last post by:
Hi ! Out there, anybody could help tell me what could be the reason that my php scripting is not giving output in IE6. Which I'm trying from my webserver itself, having IIS 5 on W2k Advanced...
10
by: lvl 1 monk | last post by:
Hi all, I don't really have the money for the formal route so I went to the library and picked up an older c++ book and it seems I run into "antiquated headers" over and over again. The problem...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.