[PHP-DB] Re: One to Many Select Statement

2004-09-13 Thread Arné Klopper


My suggestion is:

select u.username, g.group_name from usertable u inner join grouptable g on u.id=g.user_id;

ENJOY !!

Arn Klopper
System Developer
NetCB Solution(Pty) Ltd.
www.netcb.com


**
Looking for clarification...Say that I have a user table and group table -

-- user table --id username1 foo

-- group table --id user_id group_name1 1 group_12 1 group_2

Would this be the proper way to construct a select statement for this -select u.username, g.group_name from user u, group gwhere u.user.id = g.user_id and user.id = 1;

The results should look like this -username group_namefoo group 1foo group 2

What I would like to clarify, is if this is the proper (only) way to construct a one to many select statement?

I've always thought I was doing something illegal, since username is displayed more than once, and I would like to shake that thoughtoff my back.

Thanks for your input..


[PHP-DB] mysql_connect dies silently

2004-09-13 Thread Christian Schlaefcke
Hi Folks,

I have a problem getting a php script running. It seems that the script
just dies when calling the function mysql_connect(host, username,
passwd). I put two debugging echoes (one in front and one afterwards)
in the script but only the first one appears.

There are no errormessages. How can I debug this problem?

PHP Version 4.3.8
Option --with-mysql=shared,/usr is set.

Thanks  Regards,

Christian

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



Re: [PHP-DB] mysql_connect dies silently

2004-09-13 Thread Mark Boyle
If you have access to your php.ini file, take a look for the Error
Reporting settings. It may be set to none, to to log the errors to
syslogd or a file.

Mark


On Mon, 13 Sep 2004 12:48:33 +0200, Christian Schlaefcke
[EMAIL PROTECTED] wrote:
 Hi Folks,
 
 I have a problem getting a php script running. It seems that the script
 just dies when calling the function mysql_connect(host, username,
 passwd). I put two debugging echoes (one in front and one afterwards)
 in the script but only the first one appears.
 
 There are no errormessages. How can I debug this problem?
 
 PHP Version 4.3.8
 Option --with-mysql=shared,/usr is set.
 
 Thanks  Regards,
 
 Christian
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP-DB] mysql_connect dies silently

2004-09-13 Thread Christian Schlaefcke
This is what I have in my php.ini

error_reporting  =  E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = On
html_errors = On

Tried both:
error_log = /var/log/php_err.log
error_log = syslog

Nothing appears in /var/log/messages (Yes Im using Linux) nor in /var/
log/php_err.log

Even on the page still no errors get displayed.

Regards,

Chris

Am Mo, den 13.09.2004 um 13:29 Uhr +0100 schrieb Mark Boyle:
 If you have access to your php.ini file, take a look for the Error
 Reporting settings. It may be set to none, to to log the errors to
 syslogd or a file.
 
 Mark
 
 
 On Mon, 13 Sep 2004 12:48:33 +0200, Christian Schlaefcke
 [EMAIL PROTECTED] wrote:
  Hi Folks,
  
  I have a problem getting a php script running. It seems that the script
  just dies when calling the function mysql_connect(host, username,
  passwd). I put two debugging echoes (one in front and one afterwards)
  in the script but only the first one appears.
  
  There are no errormessages. How can I debug this problem?
  
  PHP Version 4.3.8
  Option --with-mysql=shared,/usr is set.
  
  Thanks  Regards,
  
  Christian
  
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 

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



Re: [PHP-DB] mysql_connect dies silently

2004-09-13 Thread John Holmes
From: Christian Schlaefcke [EMAIL PROTECTED]
This is what I have in my php.ini
error_reporting  =  E_ALL
display_errors = On
Have you looked at a phpinfo() page to ensure you're editing the correct 
php.ini?

?php phpinfo(); ?
In the first block, it tells you what php.ini file PHP is using. If it just 
lists a directory, then that's where PHP expects to find the php.ini file.

---John Holmes... 

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


Re: [PHP-DB] mysql_connect dies silently

2004-09-13 Thread Christian Schlaefcke
 Am Mo, den 13.09.2004 um 9:27 Uhr -0400 schrieb John Holmes: 
 From: Christian Schlaefcke [EMAIL PROTECTED]
 
  This is what I have in my php.ini
 
  error_reporting  =  E_ALL
  display_errors = On
 
 Have you looked at a phpinfo() page to ensure you're editing the correct 
 php.ini?
 
 ?php phpinfo(); ?
 
 In the first block, it tells you what php.ini file PHP is using. If it just 
 lists a directory, then that's where PHP expects to find the php.ini file.
 
 ---John Holmes... 

Yupp! And its 'is' the correct one.

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



Re: [PHP-DB] Insert Query PROBLEMS

2004-09-13 Thread Philip Thompson
Aaron,
I agree with what Mark said. But I just want to say what I noticed off  
hand...

On Sep 10, 2004, at 11:13 AM, Aaron Todd wrote:
I'm trying to run an INSERT query on my mysql database and it isnt  
working.

Here is the query:
$updatequery = UPDATE `users`
  SET
('company','fname','lname','address1','address2','city','state','zip',' 
phone','extension','fax','email')
When I do an UPDATE and refer to these columns, I do not include the  
single quotes (or tick marks) around my fields, and it works fine. But  
like Mark said, cleaning it up (1 per line) might also help - that's  
just personal preference.

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


Re: [PHP-DB] mysq query without subselects

2004-09-13 Thread Philip Thompson
Blackwater,
On Sep 10, 2004, at 12:39 PM, blackwater dev wrote:
Hello,
I need to grab the max value of all of the data in a table grabbing
the max total for each client.  Example.
T1
idtotal  clientid
1  100   111
2  200   111
3  100   112
4  150   112
I need a query that will grab the highest total per clientid (200, and
150) then average them.  My first inclination is to do a subselect
select avg(total) from t1 where t1.total=(select max(total) from t1 t2
where t2.clientid=t1.clientid)
But can't use subselects with mysqlhow do I do it??
Yes you can. Check this out and see if all your syntax is correct.
http://dev.mysql.com/doc/mysql/en/Subqueries.html
~Philip
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] mysql_connect dies silently

2004-09-13 Thread Mulo Emmanuel
Look at the phpinfo() page and see whether you find a section with 
information on MySQL.  If it isnt there, it is likely to do with the way 
you compiled AMP.

Christian Schlaefcke wrote:
Am Mo, den 13.09.2004 um 9:27 Uhr -0400 schrieb John Holmes: 
 

From: Christian Schlaefcke [EMAIL PROTECTED]
   

This is what I have in my php.ini
error_reporting  =  E_ALL
display_errors = On
 

Have you looked at a phpinfo() page to ensure you're editing the correct 
php.ini?

?php phpinfo(); ?
In the first block, it tells you what php.ini file PHP is using. If it just 
lists a directory, then that's where PHP expects to find the php.ini file.

---John Holmes... 
   

Yupp! And its 'is' the correct one.
 


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

Re: [PHP-DB] mysql_connect dies silently

2004-09-13 Thread Christian Schlaefcke
This looks like it is enabled. I recently upgraded mysql to version
4.1.4. Maybe this causes the problem. Do I have to reinstall PHP it is
still the version I got with the installation of my distro (Fedora Core
2).

I attached what phpinfo produced...

Am Mo, den 13.09.2004 um 17:20 Uhr +0300 schrieb Mulo Emmanuel:
 Look at the phpinfo() page and see whether you find a section with 
 information on MySQL.  If it isnt there, it is likely to do with the way 
 you compiled AMP.
 
 Christian Schlaefcke wrote:
 
  Am Mo, den 13.09.2004 um 9:27 Uhr -0400 schrieb John Holmes: 
   
 
 From: Christian Schlaefcke [EMAIL PROTECTED]
 
 
 
 This is what I have in my php.ini
 
 error_reporting  =  E_ALL
 display_errors = On
   
 
 Have you looked at a phpinfo() page to ensure you're editing the correct 
 php.ini?
 
 ?php phpinfo(); ?
 
 In the first block, it tells you what php.ini file PHP is using. If it just 
 lists a directory, then that's where PHP expects to find the php.ini file.
 
 ---John Holmes... 
 
 
 
 Yupp! And its 'is' the correct one.
 
   
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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

[PHP-DB] Help please, back to an error

2004-09-13 Thread Stuart Felenstein
Thanks to help here I was able to overcome some ivalid
query errors.

Now I'm back, (probably the same mistake)

It's coming off of this line:

$sql .=  And
PostStart = DATE_SUB(CurDate(), Interval
['search_fd1'] day ); 

The 'search_fd1' is one of the form fields where a
list of values is chosen from.  Perhaps I will try the
search_optfd1

?php
if ((!isset($_GET[search_fd1])) 
(!isset($_POST[search_fd1]))) {
$itemvalue = ;
} else {
$itemvalue = qsrequest(search_fd1);
}

$cellvalue = select
name=\search_optfd1\option value=\=\ .
qscheckselected(=,$arryopt[1],selected) . less
or equal/option/select
select name=\search_fd1\option value=\\ .
qscheckselected(,$arryitemvalue[1],selected) .
Please Select/option . qsmysqlgen_listbox( 
Select Distinct `DaysID`,`Days` From staDays
,search_fd1,DaysID,Days,$arryitemvalue[1]) .
/select . input type=\hidden\
name=\multisearch_fd1\ value=\\;
if ($cellvalue == ) {
$cellvalue = nbsp;;
}
print td class= . $css_class .  align=Default
 . $cellvalue . /td;
?

I hope my question makes sense. I didn't write this
code AND I have little knowledge of PHP.  

Thank you,
Stuart

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



[PHP-DB] MySQL: Problem optimizing multi-table row deletion ... errors out :(

2004-09-13 Thread -{ Rene Brehmer }-
hi gang
I'm working on optimizing the SQL for my forum system, but have run into a 
problem trying to optimize the function for deleting a thread with 
accompanying stats data and posts from the database using 1 query.

The current function, that works, looks like this:
// delete all traces of a thread
function delThread($threadID) {
  $result = mysql_query(DELETE FROM hf_threads WHERE 
`threadID`='$threadID');
  $result = mysql_query(DELETE FROM hf_thread_stats WHERE 
`threadID`='$threadID');
  $result = mysql_query(DELETE FROM hf_posts WHERE `threadID`='$threadID');
}

I went through the MySQL manual, to try and find a way to optimize this, 
and came up with this variant:

// delete all traces of a thread
function delThread($threadID) {
  $result = mysql_query(DELETE FROM hf_threads,hf_thread_stats,hf_posts 
WHERE `threadID`='$threadID') or die('Unable to delete 
threadbr'.mysql_error());
}

only it doesn't work at all ... the error output says this:
Unable to delete thread
You have an error in your SQL syntax near 'hf_thread_stats,hf_posts WHERE 
`threadID`='85'' at line 1

(Obviously I attempted to delete the thread with ID 85 here)
I'm dealing with MySQL 3.23.56-log and PHP 4.3.0 ...
Any ideas for optimizing this will be greatly appreciated, esp since I'm 
not all that great with the more complex SQL syntax...

TIA
Rene
--
Rene Brehmer
aka Metalbunny
If your life was a dream, would you wake up from a nightmare, dripping of 
sweat, hoping it was over? Or would you wake up happy and pleased, ready to 
take on the day with a smile?

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums at http://forums.metalbunny.net/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] MySQL: Problem optimizing multi-table row deletion ... errors out :(

2004-09-13 Thread randy
If the threadID column is an int, you don't need to wrap the $threadID
variable in quotes.

HTH ~randy

On Tue, 14 Sep 2004 00:05:56 +0200, -{ Rene Brehmer }-
[EMAIL PROTECTED] wrote:
 hi gang
 
 I'm working on optimizing the SQL for my forum system, but have run into a
 problem trying to optimize the function for deleting a thread with
 accompanying stats data and posts from the database using 1 query.
 
 The current function, that works, looks like this:
 
 // delete all traces of a thread
 function delThread($threadID) {
$result = mysql_query(DELETE FROM hf_threads WHERE
 `threadID`='$threadID');
$result = mysql_query(DELETE FROM hf_thread_stats WHERE
 `threadID`='$threadID');
$result = mysql_query(DELETE FROM hf_posts WHERE `threadID`='$threadID');
 }
 
 I went through the MySQL manual, to try and find a way to optimize this,
 and came up with this variant:
 
 // delete all traces of a thread
 function delThread($threadID) {
$result = mysql_query(DELETE FROM hf_threads,hf_thread_stats,hf_posts
 WHERE `threadID`='$threadID') or die('Unable to delete
 threadbr'.mysql_error());
 }
 
 only it doesn't work at all ... the error output says this:
 
 Unable to delete thread
 You have an error in your SQL syntax near 'hf_thread_stats,hf_posts WHERE
 `threadID`='85'' at line 1
 
 (Obviously I attempted to delete the thread with ID 85 here)
 
 I'm dealing with MySQL 3.23.56-log and PHP 4.3.0 ...
 
 Any ideas for optimizing this will be greatly appreciated, esp since I'm
 not all that great with the more complex SQL syntax...
 
 TIA
 
 Rene
 --
 Rene Brehmer
 aka Metalbunny
 
 If your life was a dream, would you wake up from a nightmare, dripping of
 sweat, hoping it was over? Or would you wake up happy and pleased, ready to
 take on the day with a smile?
 
 http://metalbunny.net/
 References, tools, and other useful stuff...
 Check out the new Metalbunny forums at http://forums.metalbunny.net/
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 



-- 
randy [EMAIL PROTECTED]

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



[PHP-DB] select command denied to user

2004-09-13 Thread balwantsingh
pls. help.

i have grant all to one of my tables made in mysql.  now when i want to
retrieve the data through PHP, following error is coming
=
select command denied to user: '[EMAIL PROTECTED]' for table
'timeframe'
=
pls. advise what went wrong.

with best wishes
balwant

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