Re: [PHP-DB] retrieving field names in ascending order

2005-09-08 Thread Pablo M. Rivas
Hello Hope:

On 9/8/05, hope [EMAIL PROTECTED] wrote:
 how can i retrieve field names from a table(e.g products_attributes)
  in ascending order???
 i need to display each of the fieldnames alongwith its datatype and length
 on the page.
I suppose you use Mysql:

$result=mysql_query(SHOW COLUMNS FROM table,$db);
if (mysql_num_rows($result)  0) {
  while ($row = mysql_fetch_assoc($result)) {
$k[$row['Field']]=$row['Type'];
  }
  ksort($k);
  while (list($key,$value)=each($k)) echo $key $valuebr\n;
}

Pablo.
-- 
Pablo M. Rivas. http://www.pmrivas.com http://www.r3soft.com.ar
---

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



Re: [PHP-DB] Pagination problems

2005-09-02 Thread Pablo M. Rivas
 by error, please immediately notify the sender
 by replying to this mess
 age and deleting it from your system without keeping a copy. Thank you.
 Alimentos La Concordia, S.A. de C.V.
 
  
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
Pablo M. Rivas. http://www.pmrivas.com http://www.r3soft.com.ar
---

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



Re: [PHP-DB] Pagination problems

2005-09-02 Thread Pablo M. Rivas
upsss.. y forgot $counter++

$counter=0;
while ($row=mssql_fetch_row($rs)) {
  if (($counter=$start) and ($counter($start+ $Page_Size)) {
echo tr;
//There you go: Show all fields, one to each cell
echo td . implode(/tdtd,$row) . /td;
echo /tr\n;
 }
 $counter++;
}

-- 
Pablo M. Rivas. http://www.pmrivas.com http://www.r3soft.com.ar
---

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



Re: [PHP-DB]

2004-09-25 Thread Pablo M. Rivas
Hello balwantsingh:

STFW: javascript menu

Good Luck!

On Sat, 25 Sep 2004 15:38:14 +0530, balwantsingh
[EMAIL PROTECTED] wrote:
 excuse me pls., i am putting a question which is not related to this forum
 but i am sure somebody will help me
 
 i want to know whether in PHP submenu can be created under menu so that user
 put his mouse over the menu and submenu automatically displayed.
 
 with best wishes
 balwant
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 



-- 
Pablo M. Rivas. http://pmrivas.ipupdater.com http://www.r3soft.com.ar
---

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



Re: [PHP-DB] Newbie Question - mysql_select_db fails with access denied.

2004-09-24 Thread Pablo M. Rivas
You're right:
if you use mysql_connect(localhost, root,);
you''ll get acces denied for user [EMAIL PROTECTED]

if you use mysql_connect(localhost);
you'll get Access denied for user @localhost
I'll google for a while... but.. to solve YOUR problem, just use:
mysql_connect(localhost,user,);

Good luck!


On Fri, 24 Sep 2004 14:56:35 +0200, Christian Schlaefcke
[EMAIL PROTECTED] wrote:
 I have chosen an empty password. I know that this is a security problem.
 I´m using it for testing at the moment only. I use it because there also
 seems to be an issue with php connecting to mysql servers with verions 
 4.1.
 
 When trying to connect with password I get this:
 Connect failed : Client does not support authentication protocol
 requested by server; consider upgrading MySQL client.
 
 Because I want to track down issue after issue and not anything at once
 I decided to find out why mysql_select_db fails first.
 
 What really makes me wonder in my tiny example is that the error message
 does not say something like:
 
 SELECT_DB failed: Access denied for user 'myuser'@'localhost' to
 database 'mydb'
 
 instead it says:
 SELECT_DB failed: Access denied for user ''@'localhost' to database
 'mydb'
 
 So I think that the username is not interpreted at all. Why not?
 
 Regards,
 
 Chris
 
 Am Fr, den 24.09.2004 um 13:43 Uhr +0100 schrieb Peter Lovatt:
 
 
  Hi
 
  try $db = mysql_connect(localhost, myuser,mypassword) - without it  you are 
  not  submitting a password
 
  Peter
 
   -Original Message-
   From: Christian Schlaefcke [mailto:[EMAIL PROTECTED]
   Sent: 24 September 2004 13:31
   To: [EMAIL PROTECTED]
   Subject: [PHP-DB] Newbie Question - mysql_select_db fails with access
   denied.
  
  
   Hi Folks,
  
   I want to do something like the following:
   $db = mysql_connect(localhost, myuser) or die(Connect failed :  .
   mysql_error());
  
   mysql_select_db(mydb,$db) or die(SELECT_DB failed :  . mysql_error
   ());
  
   $result = mysql_query(SELECT * FROM mytable, $db) or die(Query
   failed :  . mysql_error());
  
   The script does not proceed beyond the mysql_select_db line. I get
   this error:
   SELECT_DB failed: Access denied for user ''@'localhost' to database
   'mydb'
  
   What happened to the user information. I have granted all neccessary
   rights to myuser. But it seems that it´s even not caring about the
   user.
  
   I have MySQL 4.1.4 and PHP 4.3.8-2.1 on a Fedore Core 2 System  running.
  
   Thanks  Regards,
  
   Chris
  
   --
   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
 
 



-- 
Pablo M. Rivas. http://pmrivas.ipupdater.com http://www.r3soft.com.ar
---

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



Re: [PHP-DB] Apache / PHP Page built from a MySQL Database Diplay Problems

2004-08-05 Thread Pablo M. Rivas
Hello Mitch,

1) Have you tried doing SHOW SOURCE in your browser?
2) Take a look at: http://www.php.net/manual/en/function.error-reporting.php

Good luck!

M Here is the basic scenario:

M - Configuration data is gathered from Oracle servers then ftp'd to my
M apache / mysql server.

M - The apache / mysql server receives the datafile from the Oracle
M clients and loads the data into a MySQL database.

M - The webpages are coded using PHP, SQL, and some JavaScript.

M Now here is where it gets weird

M - When the data is displayed (pages are based upon the configuration
M of each Oracle server-name+database-instance-name, some times the
M data displays other times the page is simply blank?  It is only for a
M few out of the many that we have in the MySQL database.  It is always
M the same ones with the problem.  Re-loading the data for those problem
M server-name+database-instance-name does not fix it.

M Anyone see this before?   Could it be a special character that the web
M browser cannot handle?   I am at a loss on this one.

M Any advice on the problem and how to trouble shoot would be
M appreciated!   Mitch




-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Re: sendmail

2004-08-04 Thread Pablo M. Rivas
Hello Aaron,
AT Is there any tweaking with mail()?

AT I have it working, but it seems to not always send the email.  Mainly one
AT right after the other.  I filling a web form and then sending the data off
AT to my email.  But then I do a refresh to clear the form and do it again with
AT different data and it doesnt work.  Any ideals on this?

   mmmhhh...
   
   REFRESH... maybe you are not calling your script again, and
   using a cached version of the send page...
   try this:
   ?php
  $fp=fopen(mylog.log,a);
  fwrite($fp,sending  . date(YmdHis));
  fclose($fp);
  mail()
   ?
   and look your mylog.log

AT Thanks,

AT Aaron





-- 
Best regards,
 Pablo

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



Re: [PHP-DB] php-db@lists.php.net is currently protecting themselves from receiving junk mail using Spamcease Just this once, click the link below so I can receive your emails.

2004-08-04 Thread Pablo M. Rivas
Hello Josh,

JAM What is this?

JAM I received this E-Mail, and the link goes to something other than PHP.net

JAM [EMAIL PROTECTED] is currently protecting themselves from receiving junk
JAM mail using Spamcease Just this once, click the link below so I can receive
JAM your emails.
JAM You won't have to do this again.


 CLICK THE LINK SO HE CAN RECEIVE YOUR MAIL, and you won't have to
 do this again ;)

 

-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Joining Tables for Search

2004-07-26 Thread Pablo M. Rivas
Hello Harry,
you can use left join:
http://dev.mysql.com/doc/mysql/en/JOIN.html

 $query = 
  SELECT members.id, firstname, familyname, middlename, fathername,
  region3.region3, region4, members.country, country.countryname,
 MATCH(firstname, middlename, familyname, fathername) AGAINST ('$keywords' IN 
BOOLEAN MODE) AS score
FROM members left join country on members.country =  country.id
left join region3 on members.region3 = region3.id
   WHERE MATCH(firstname, middlename, familyname, fathername) AGAINST ('$keywords' 
IN BOOLEAN MODE)
ORDER BY score DESC;

good luck.

HG Hi,

HG I want to run a query on a table while joining it with other tables.

HG Table 1- members
HG id - firstname - middlename - - country - region3

HG Fields country and region3 hold the integer codes for country and region3 is state

HG Table 2- country
HG id - countryname
HG Countryname is where the actual Country name is stored and id is the country code

HG Similarly Table 3 - region3
HG id - region3 where region3 is the state name and id is the region code.

HG I perform the following query to search the names in the database but the result 
only gives me the integer values for Country and Region3. That's because, the code is 
only stored in the database.
HG But I need to join the table 23 with 1 so I can extract names of country or 
region3 rather than integer values. 

HG How would I modify the query below?

HG $keywords are the search words.

HG $query =  
HGSELECT id, firstname, familyname, middlename, fathername, region3, region4, 
country,
HG   MATCH(firstname, middlename, familyname, fathername) AGAINST 
('$keywords' IN BOOLEAN MODE) AS score  
HG   FROM members 
HGWHERE MATCH(firstname, middlename, familyname, fathername) AGAINST 
('$keywords' IN BOOLEAN MODE) ORDER BY score DESC; 

HG Thanks
HG Harmeet




-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Empty query result

2004-07-26 Thread Pablo M. Rivas
Hello Philip,

pse.. can you paste the error information?
There is no known empty set problem.

-- 
Best regards,
 Pablo
PT Hi all.

PT I am querying a database of single information multiple times using a 
PT simple 'select' statement. However, whenever the data in the DB is 
PT empty or is 0 (zero), then it throws an error. However, I don't want it 
PT to throw an error, I just want it to move on to the next query.

PT This is being shown on a webpage I have. Note that I am using a 
PT function for this select statement because I just have to change the 
PT identifier that I am looking for - saves space. So I don't use 
PT mysql_error() to show my errors, I redirect to a global 'error' page.

PT Is there a way to get around this empty set problem? Yes, I know 
PT about using @ to suppress warnings, but it's more than this.

PT Thanks a bunch,
PT ~Philip

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



Re[2]: [PHP-DB] Wait Statement... ?

2004-07-20 Thread Pablo M. Rivas
Hello John,

   sleep() is the brute deffense of the brute force attack...
   You can make a script that opens simultaneous attacks

JWH I'm not saying using sleep is the solution to security problems, but
JWH it can be one layer of your defense.


-- 
Best regards,
 Pablo

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



Re[2]: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Pablo M. Rivas
Hello Aaron,

why are you using , instead of . ?

  $query = SELECT * FROM users WHERE email=',$_POST['username'],';
  is this a typo?...
  this sould be:
  $query = SELECT * FROM users WHERE email='.$_POST['username'].';
  or $query = SELECT * FROM users WHERE email='{$_POST['username']}';

  mhhh.. do you whant to know wy echo works and $query= not?
  read the manual... (string functions, echo) and (Language
  reference, String Operators)

  
  in echo case, you are giving more than 1 argument:
  echo blahblablah,$variable,blahblahblah;
  in $xx=blahblahblah,$variable,blahblahblah you are getting a
  parse error.

  
AT That makes great sence, however when I tried using $_POST in my SQL
AT statement it would not work.

AT This works fine:
AT $query = SELECT * FROM users WHERE email='.$username.';
AT But this one doesnt at all:
AT $query = SELECT * FROM users WHERE email=',$_POST['username'],';

AT It does however work for  all the echo commands and It is also correct when
AT I echo the statement:
AT echo SELECT * FROM users WHERE email=',$_POST['username'],';

AT Am I missing something?

AT Thanks again,

AT Aaron




-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Help. Mysql Query optimisation not very clever?

2004-07-17 Thread Pablo M. Rivas
Hello Ross,

why don't use: explain select .
and you'll see what mysql is thinking... ;)



-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Restrict account access to single user

2004-07-15 Thread Pablo M. Rivas
Hello veditio,

You can use sessions: http://www.php.net/manual/en/ref.session.php
and pay attention to: http://www.php.net/manual/en/function.session-cache-expire.php
and session.use_cookies = 0
-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Column help needed (Table)

2004-07-13 Thread Pablo M. Rivas
Hello Chris,
   easy as this?

   ?php
$odd=1;
while ($row=mysql_fetch_row($Res)) {
  if ($odd) {
 echo \ntr;
 $odd=0;
  } else $odd=1;
  echo td . $row[0] . /td;
}

   ?


CP Hi there everyone,

 

CP I need my MySQL query to be displayed in a table, which is no problem, but I
CP only want 2 results per row to be displayed - so if I had 10 returned
CP results from my Database, it would display 2 per column on 5 rows.  How can
CP I do this dynamically?

 

CP Any help would be really appreciated.

 

CP Thanks

 

CP Chris

 




-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Multiple SELECT

2004-07-13 Thread Pablo M. Rivas
Hello Marcjon,

   do this:
   SELECT forumusers.*, forumuserprofiles.* from 
.$godlyness['database_database']..forumusers
   LEFT JOIN .$godlyness['database_database']..forumuserprofiles ON
   forumusers.username = forumusersprofiles.username where  order
   by

   so.. if you do: where forumusers.username like %doe%
   you will receive all users like %doe%, and null values if she/he
   has not profile.

   http://dev.mysql.com/doc/mysql/en/JOIN.html

   


M SELECT
M forumusers.email AS email,forumusers.username AS username,forumusers.level 
AS level,
M forumusers.lastlogon1 AS lastlogon1,forumusers.lastlogon2 AS 
lastlogon2,forumusers.settings1 AS settings1,forumusers.confirmationcode AS 
confirmationcode, 
M forumuserprofiles.sex AS sex, forumuserprofiles.birthdate AS birthdate,
M forumuserprofiles.address_msnm AS address_msnm, 
forumuserprofiles.address_aim AS address_aim, 
M forumuserprofiles.address_yahoo AS address_yahoo, 
forumuserprofiles.address_icq AS address_icq  
M FROM 
.$godlyness['database_database']..forumusers,.$godlyness['database_database']..forumuserprofiles
 .$filterbu.
M ORDER BY username 
M 




-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Storing Date in mysql

2004-07-08 Thread Pablo M. Rivas
Hello Michael,
token_date must be a DATE FIELD...

http://dev.mysql.com/doc/mysql/en/Column_types.html


MG Hello,

MG I need to store the date of record / entry in the mysql database, so I 
have the following table create statement:

MG CREATE TABLE `token_table` (
MG   `token_id` int(11) NOT NULL auto_increment,
MG   `token_utuser_id` int(11) NOT NULL default '0',
MG   `token_name` varchar(100) NOT NULL default '',
MG   `token_date` varchar(100) NOT NULL default '',
MG   `token_user_id` varchar(100) default '',
MG   `token_ticket_id` varchar(100) default '',
MG   `token_data` varchar(100) default '',
MG   PRIMARY KEY  (`token_id`),
MG   KEY `tokencheck` (`token_utuser_id`,`token_name`)
MG ) TYPE=MyISAM; 

MG So in the token_date field I am storing the date in the following format from PHP:

MG date(d/m/Y) which creates the following entry 05/07/2004 (example).

MG I would like to know fro the list is ... is this the best way to store the date ? 
Would this be easy to select against ?

MG Michael.




-- 
Best regards,
 Pablo

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



Re[2]: [PHP-DB] Re: MySQL query, using DISTINCT...

2004-07-06 Thread Pablo M. Rivas
Hello Tristan,
 Select count(id) as howmany, file_name, email from  `completed_downloads`
 where bu='reech' and date  BETWEEN '2004-06-01' AND '2004-06-30'
 group by file_name, email

 

  I have a system that tracks downloads, capturing loadsa info, but of
  interest here, is email and filename.
  Simply put, I wanna show all results where file name AND email are 
TPrsc unique.
  (so if email '[EMAIL PROTECTED]' has filename 'word.doc' 5 times in a 
TPrsc table,
  I want to only see it once.)
 
  What am I doing wrong...?
 
  SELECT DISTINCT(file_name, email) FROM `completed_downloads` WHERE 
TPrsc `bu`  =
   'reech' AND date BETWEEN '2004-06-01' AND '2004-06-30'
 
  Tris...



-- 
Best regards,
 Pablo

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



Re[2]: [PHP-DB] Dates and Count

2004-07-05 Thread Pablo M. Rivas
Hello Shannon,


mmhh.. i think this is simple as:
   Select * from mytable where nextcontact='$today' and
   nextcontact='$week' and (custid=3 or custid=5) and (languaje='de'
   or languaje='en')

   I'm not sure if it helps, but you can ask again or provide an
   example... ;)
   
SD Second I need the same scenario, however I want to search from a variety of
SD different fields, show those that are between the dates and are equal to one
SD other criteria.

SD Any help on these two?

SD Cheers,

SD Shannon






-- 
Best regards,
 Pablo

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



Re[2]: [PHP-DB] MySQL: Random select with specific count of a column

2004-07-05 Thread Pablo M. Rivas
Hello Torsten,


TR thanks for your help. Unfortunately it's always returning the same row for
TR each category (maybe because of the group by) and only one row for each
TR category. I need to select 2 random rows for each category. Any more ideas?

I'ts returning 2 rows each RECORD, but the fields have
the same name, so if you do a mysql_fetch_array, you'll find only
one...

Change your sql to:
   select a.category  as categorya, a.name as namea, b.name as
   nameb from tablename as a left join tablename as b on
 a.category = b.category and a.nameb.name and
 a.language=b.language where a.language='de' and b.name is not
 null group by a.category

and you'll do:
echo trthlanguajetdcategorytdname\n;
while ($data=mysql_fetch_array($result)) {
   echo trtddetd . $data[categorya] . td . $data[namea];
   echo trtddetd . $data[categorya] . td . $data[nameb];
}
ok?...
EACH ROW CONTAINS 2 RECORDS...but.. we need something more, 'cause
you're needing RANDOM rows...

If you need RANDOM, i think mysql will not help you, and you must
change your query to:
select a.category  as categorya, a.name as namea, b.name as
   nameb from tablename as a left join tablename as b on
 a.category = b.category and a.nameb.name and
 a.language=b.language where a.language='de' and b.name is not
 null order by a.category

and then do something in php like store everything in an array, and take some
randomly...

srand(time());
$lastcat=0;
echo trthlanguajetdcategorytdname\n;
while ($data=mysql_fetch_array($result)) {
  if (($lastcat) and ($lastcat$data[categorya])) {
  echo trtddetd . $lastcat . td . 
$myarray[$lastcat][rand()%count($myarray[$lastcat])];
  echo trtddetd . $lastcat . td . 
$myarray[$lastcat][rand()%count($myarray[$lastcat])];
  }
  $myarray[$data[categorya]][]=$data[namea];
  $myarray[$data[categorya]][]=$data[nameb];
  $lastcat=$data[categorya];
}
echo trtddetd . $lastcat . td . 
$myarray[$lastcat][rand()%count($myarray[$lastcat])];
echo trtddetd . $lastcat . td . 
$myarray[$lastcat][rand()%count($myarray[$lastcat])];

mhhh... i don't like... but i think this will work and you can make it
better!!

-- 
Best regards,
 Pablo

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



Re: [PHP-DB] More problems with searching

2004-07-01 Thread Pablo M. Rivas
Hello Shiloh,

Ideas?... forget the  1 

$query = Select * from keyword where ;
$words = explode(' ',$_GET['search_text']);
foreach($words as $word)
  { $query .=  keyword = '$word' and ; }
$query=substr($query,-4);

or...

$query = Select * from keyword where ;
$words = explode(' ',$_GET['search_text']);
$andconde=0;
foreach($words as $word)
  { $query .= ($andcode++) ?  and keyword = '$word' :  keyword = '$word'; }

or...

$words = explode(' ',$_GET['search_text']);
$query = Select * from keyword where keyword = ' . array_shift($words) . ';
foreach($words as $word)
  { $query .=  and keyword = '$word'; }


SM After the very kind help i was given last night I have the query being built
SM right, however the query does not work. Just to refresh, the gentlemen who
SM had helped me suggested creation of a query that looks like:

SM SELECT * FROM table1 where 1 or cat or dog...and so forth. Now, this query
SM is building fine, but the where 1 is causing it to return rows even if it
SM has none of the search terms. When i run it in sql without the where 1 it
SM works as it should, but with that, i get all rows returned. Is there a way i
SM can reword this query or am I doing something wrong?

SM this was Mr Holmes's solution (in part):
SM $query = SELECT * FROM keyword WHERE 1 
SM $words = explode(' ',$_GET['search_text']);
SM foreach($words as $word)
SM { $query .=  AND keyword = '$word' ; }

SM Ideas?

SM Shiloh




-- 
Best regards,
 Pablo

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



Re: [PHP-DB] MySQL: Random select with specific count of a column

2004-06-29 Thread Pablo M. Rivas
Hello Torsten,

 This is one, but I think you can find another one:
 Supose your table is called tablename
 
 select * from tablename as a left join tablename as b on
 a.category = b.category and a.nameb.name and
 a.language=b.language where a.language='de' and b.name is not
 null group by a.category


TR I would like to select 6 random rows where the language is 'de' AND make
TR sure that I will always have 2 rows of EACH category in my result set:

-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Dates and Count

2004-06-28 Thread Pablo M. Rivas
Hello Shannon,


SD First, I have two dates stored in a MySQL DB that I want to do a compare on
SD and then only display via a web page those records that have a 5 or greater
SD day difference in them. What would be the best way to achieve this.
Depends on your mysql version...
select * from mytable where date1 + INTERVAL 5 DAY=date2 or date2 + INTERVAL 5 
DAY =date1;

select * from mytable where to_days(date1)-todays(date2)5 or 
to_days(date2)-todays(date1)5
from the mysql manual: For other dates before 1582, results from this function 
are undefined

if your mysql  4.1.1:
select * from mytable where DATEDIFF(date1,date2)5 or DATEDIFF(date1,date2)-5

but take a look to optimization.. the first script took 0.0234
secs to return 256 row of 3096 rows
the second took 0.0413 secs to return the same
couldn't test the third (I have a mysql  4.0.18-standard-log)

SD Second, I want to be able to return a list of 'clients' from the MySQL DB
SD that have a specific number of a particular type of entry associated with
SD them. I am assuming that the 'count' would be used, but how would I first
SD display this count, and second only return those that have the number of
SD entries that I am looking for.

Select count(operation_id) as howmany, client_id, client_name from
clients left join operations on operations.client_id =
clients.client_id group by clients.client_id having howmany=5

Then... mysql_num_rows will give you how many clients have 5
operations, and each row will tell you:
howmany (always = 5), id of the client, and name of the client.

¿is this what you where looking for?...

-- 
Best regards,
 Pablo

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



Re: [PHP-DB] help with consecutive numbers in db

2004-06-24 Thread Pablo M. Rivas
Hello redhat,

  Hey... look at this:

CREATE TABLE `testip` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `theip` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `theip` (`theip`)
) TYPE=MyISAM AUTO_INCREMENT=7 ;
  

SELECT theip, SUBSTRING_INDEX( theip, ., 1 ) *1 AS one,
substring_index( SUBSTRING_INDEX( theip, ., 2 ) , ., -1 ) *1 AS two,
substring_index( SUBSTRING_INDEX( theip, ., 3 ) , ., -1 ) *1 AS three,
SUBSTRING_INDEX( theip, ., -1 ) *1 AS four
FROM `testip` 
ORDER BY one, two, three, four

And you have all ip's ordered by number...
so you can do:
?php
   $Result=mysql_query(Select theip, SUBSTRING., $db);
   $lastgroup=0.0.0;
   $key=255;
   while(list($theIP,$one,$two,$three,$four)=mysql_fetch_row($Result)) {
  if ($lastgroup$one.$two.$three) {
 while ($key80) echo $lastgroup. . ($key++) .  is freebr\n;
 $key=1;
  }
  while ($key($four*1)) echo $one.$two.$three. . ($key++) .  is freebr\n;
  echo $one.$two.$three.$four IS NOT FREEbr\n;
  $lastgroup=$one.$two.$three;
  $key++;
   }
   while ($key80) echo $lastgroup. . ($key++) .  is freebr\n;
?

P.S. I DONT KNOW IF THIS IS TOO SLOW.. you might test..

-- 
Best regards,
 Pablo

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



Re[2]: [PHP-DB] help with consecutive numbers in db

2004-06-24 Thread Pablo M. Rivas
Hello Pablo,

  I made a Typo:
  change this: while ($key80) echo $lastgroup. . ($key++) .  is freebr\n;
  for this: while ($key255) echo $lastgroup. . ($key++) .  is freebr\n;

  ;)

-- 
Best regards,
 Pablo

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



Re: [PHP-DB] Fetch two mysql resource in while loop

2004-06-17 Thread Pablo M. Rivas
Hello sam,

  Did you try:
 while($row1=mysql_fetch_row($result1) AND $row2=mysql_fetch_row($result2))  ?

 or this:
 while(($row1=mysql_fetch_row($result1))  ($row2=mysql_fetch_row($result2))) 
 ?
 
 good luck!

   P.S. These two actually work... i'm trying to figure out why this
   is so... Perhaps operator precedence?... don't know for sure.

-- 
Best regards,
 Pablomailto:[EMAIL PROTECTED]
Thursday, June 17, 2004, 12:26:29 AM, you wrote:

s Hi all:
s   i worte a piece of code like this
s   $result1 = mysql_query(query1);
s$result2 = mysql_query(query2);
swhile($row1=mysql_fetch_row($result1)  
s $row2=mysql_fetch_row($result2)){
s .}
s only $row2 is initazlied. row1 is always empty.
s if i change it like this
s while($row1=mysql_fetch_row($result1)){
s $row2=mysql_fetch_row($result2)
s }
s there will be no problem and both $row1 and $row2 contain values.
s can anyone tell me why? is it i worte something wrong?
s  sam

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



Re[2]: [PHP-DB] Beta Testers Needed

2004-06-15 Thread Pablo M. Rivas
Hello Kenny,

   Hans is right, but i'll take the challenge, send me the code
   and I will look it for a while and tell you...

-- 
Best regards,
 Pablomailto:[EMAIL PROTECTED]
Tuesday, June 15, 2004, 12:17:48 PM, you wrote:

HL Yeah, this is a joke, right?

HL You want people to intall your software on their webservers which will 
HL send information about their servers accross the network to your server?

HL Can we just cut to the chase  I'll send you the root password on my severs?

HL Anyone interested in being alerted when their servers are down can use 
HL one of the many, many existing open-source solutions (which do a heck of 
HL a lot more than monitor uptime  apache).

HL Hans

HL Kenny wrote:

 Sorry all
 
 The e-mail address is [EMAIL PROTECTED]
 
 
 -Original Message-
 From: Kenny [mailto:[EMAIL PROTECTED] 
 Sent: 15 June 2004 11:44
 To: DBList
 Subject: [PHP-DB] Beta Testers Needed
 
 Hi All,
  
 I am currently looking for beta testers to test my server monitoring
 software,
  
 Brief synopsis of what it entails,
  
 Install a small (2.92 k) file on your web server
 Add either a new db or use and existing db this will only be 1 table
 with minimal information just basically holding your Key
  
 What I will monitor
  
 Server Load averages
 Server Uptime
 HTTP
 PHP
 MySQL
  
 If any of these services go down then I will automatically send you an
 alert to your e-mail address, (For the testing phases we will not be
 sending SMS alerts)
  
 I will generate graphs indicating load averages and server outages
 I will send daily reports telling you how the web server is performing.
  
 The testing phase will last approx 1 month but you can terminate at any
 time if you wish to
 There is no payment involved either from my side or yours.
  
 We are initially looking for 50 testers but this could increase in the
 future,
  
 Please only *nix servers for now running Apache / MySQL / PHP 
  
 Please send your interest off the list to [EMAIL PROTECTED] and I will send
 you full instructions on how we would like to proceed and when the
 testing will start
  
 Thanks
  
 Kenny
  
  

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