Re: [PHP-DB] OR on multiple columns

2003-01-09 Thread Jason Wong
On Friday 10 January 2003 06:41, David Chamberlin wrote:
> > That may depend upon your particular circumstances, and hence running
> > your own tests on both methods would give you the best answer.
>
> OK, so what's the best way to go about profiling this? 

Short answer: microtime()
Long answer: check the archives, check the usual script sites 
(www.hotscripts.com, www.zend.com, www.phpclasses.org etc) for timing 
classes/functions/etc.


> Everything runs
> on my ISP's server.

That's not an issue.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
Fly me away to the bright side of the moon ...
*/


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




RE: [PHP-DB] Relationship or not.

2003-01-09 Thread Bruce Levick
I forgot to mention there will likely be more than the one "file" that
relates to a task.

-Original Message-
From: Bruce Levick 
Sent: Friday, January 10, 2003 2:40 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Relationship or not.


I have a bit of a challenge on and only being a newbie I will need to
call on some experienced PHP'ers.

I have two tables in a databse. "Tasks" and "Files". They relate to each
other via Tasks.ID and Files.FID. 

I have successfully created an uploading form which adds images to a
directory and records the files details into the "files" table. So I can
now display the results If I need to from the "files" table.

My challenge is this.
I have created a Result set which displays all the "Tasks". This
displays through a repeated row and so on. 

What I need to do is some sort of an if statement in each task display.

If (there are "files.fid" that relate to this "tasks.ID"){

Display results !!! //Calls on some HTML/PHP and attatchs "file" info to
a generic image to click on. }

Else {

Display Nothing !!!

}

So to put it simple. I need to display all the tasks (got that) and also
the file info that realtes to each task. I am unsure of how to code this
relational stuff. A bit out of my reach at the moment.

Cheers 
Bruce
 

-- 
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] Relationship or not.

2003-01-09 Thread Bruce Levick
I have a bit of a challenge on and only being a newbie I will need to
call on some experienced PHP'ers.

I have two tables in a databse. "Tasks" and "Files". They relate to each
other via Tasks.ID and Files.FID. 

I have successfully created an uploading form which adds images to a
directory and records the files details into the "files" table. So I can
now display the results If I need to from the "files" table.

My challenge is this.
I have created a Result set which displays all the "Tasks". This
displays through a repeated row and so on. 

What I need to do is some sort of an if statement in each task display.

If (there are "files.fid" that relate to this "tasks.ID"){

Display results !!! //Calls on some HTML/PHP and attatchs "file" info to
a generic image to click on.
}

Else {

Display Nothing !!!

}

So to put it simple. I need to display all the tasks (got that) and also
the file info that realtes to each task. I am unsure of how to code this
relational stuff. A bit out of my reach at the moment.

Cheers 
Bruce
 

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




Re: [PHP-DB] resetting $res from mysql_fetch_row()?

2003-01-09 Thread Donny Lee
John W. Holmes wrote:
>>any hint on resetting a $res from mysql_fetch_row()?
> www.php.net/mysql_data_seek

  Thanks, does help.

-- 
 // Donny


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




RE: [PHP-DB] Examine button

2003-01-09 Thread John W. Holmes
> Hello everybody!!! I'm writing to you to ask if somebody knows how
can
> I do to emulate the examine button to retrive a file's path to save
that
> string in the database. Specifically, it's a photo, that've got to
search
> in the directory's window. Thanks in advance!

Yeah, you probably got no response the first time you posted this
because no one knows what you're talking about. Well, at least I don't.
What does this have to do with PHP?

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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




[PHP-DB] Examine button

2003-01-09 Thread Sabina A. Schneider
Hello everybody!!! I'm writing to you to ask if somebody knows how can I do to 
emulate the examine button to retrive a file's path to save that string in the 
database. Specifically, it's a photo, that've got to search in the directory's window. 
Thanks in advance!

  Sabina Alejandra Schneider
[EMAIL PROTECTED]



RE: [PHP-DB] If select query doesn't net any results

2003-01-09 Thread Doug Thompson
You're absolutely right.
It must be the 1.5 hours of sleep last night that made my brain shrivel
up like that. 8(

Doug

On Thu, 9 Jan 2003 17:45:00 -0500, John W. Holmes wrote:

>> ...
>> if ($result) {
>>  while ($row...
>>  ...
>> }
>> 
>> $result will be 0 (false) if nothing satisfies the query.  Any other
>> comparison is just extra typing with no improvement in logic.
>
>No, it only returns false/0 if the query fails, meaning there was an
>error and the query couldn't be executed. The query can execute just
>fine, return no rows, and so the result would be true. 
>
>What you have is extra typing with no improvement in logic. ;)
>
>If you need to know the number of rows returned, then use the
>if(mysql_num_rows() method. If you don't, then you can do this:
>
>if($row = mysql_fetch_row($result))
>{
>   do{
>   //do whatever with $row data
>   }while($row = mysql_fetch_row($result));
>}
>else
>{ echo "no rows returned from query"; }
>
>If you simply do not want something done if no rows are returned, then
>the simple while($row = mysql_fetch_row($result)) method works fine, as
>the while() will only be true if rows were returned and skipped if no
>rows are returned.
>
>---John W. Holmes...
>
>PHP Architect - A monthly magazine for PHP Professionals. Get your copy
>today. http://www.phparch.com/
>
>



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




Re: [PHP-DB] Authenticating through a php script

2003-01-09 Thread Jeremy Peterson
Dave,

I am afraid I am not communicating what I am trying to do.

I have multiple databases that my library purchases.  FirstSearch, 
Ebscohost, etc.  These company's have there own authentication systems that 
I have no control over.  A lot of them give user names and passwords that 
can access their secure database; however I will not give out this 
information to students.  I want to design a system that will log the 
students on directly without them ever seeing the log in screen.

A)  Does this make sense in what I am trying to do?
B)  How can I do it?

Jeremy

At 12:38 PM 1/9/2003 -0700, David Smith wrote:
I haven't looked over all your code in detail, but the problem you
describe seems to be best solved using PHP Sessions. Sessions store data
between browser refreshes. You could store whether a user has been
authenticated via LDAP, and then on a subsequent page, you can reference
that information to determine how to proceed.

Here's the doc: http://www.php.net/manual/en/ref.session.php

--Dave

On Thu, 2003-01-09 at 11:29, Jeremy Peterson wrote:
> David,
>
> I have ldap working, my problem is the second half of my question.
>
> The problem script workflow:
> 1. Authenticate on LDAP (Resolved)
> 2. Connect to different authenticated site for the user  (Not sure 
where to
> go now.)
>
> My guess was to send the post information to where the form action points
> to.  Having done this, all I get is a blank page.  I guess if  PHP sends
> the post information then the client will be out of the authentication
> loop.  There must be a better way.  But I don't think I have enough
> information to know how to proceed.
>
> Somehow I have to get the browser to send the http post rather than
> PHP.  Is this possible.
>
> Jeremy
>
> P.S.
>
> The script I am using right now incorporates Chris Alsop's class:
>
> 
>
> 
>## Archive:c_http.class
>## Description:Basic http class functions (only post right now)
>## Author: Chris Alsop - [EMAIL PROTECTED] (rumblefiz)
>## Property Of:Everyone
>## Date Created:   07/01/2001
>## Mod History:07/01/2001   Chris Alsop - Initial Coding
>##
> ==
>   class c_http {
>  ## DECLARE CLASS VARIABLES 
> var $QUERY_STRING;
> var $TARGET_DOMAIN;
> var $TARGET_FILE;
> var $RESPONSE;
>  ## END CLASS VARIABLE DECLARATION -
>
>  ## FUNCTION: c_http()
>  ## ARGS: $psQueryString : String
>  ##   $psTargetDomain : String
>  ##   $psTargetFile : String
>  ## 
> function c_http($psQueryString,
>$psTargetDomain,$psTargetFile) {
>
>$this->QUERY_STRING  = $psQueryString;
>$this->TARGET_DOMAIN = $psTargetDomain;
>$this->TARGET_FILE   = $psTargetFile;
> }
>  ## END FUNCTION: c_http() *
>
>  ## FUNCTION: post()
>  ## ARGS: None
>  ## RETURNS:  Boolean
>  ## 
> function post() {
>$qs  = $this->QUERY_STRING;
>$domain  = $this->TARGET_DOMAIN;
>$thefile = $this->TARGET_FILE;
>if(!$fp = fsockopen($domain,80)) {
>   print "Socket not open";
>   return false;
>   exit();
>}
>$postData  = "POST http://$domain/$thefile HTTP/1.0\r\n";
>$postData .= "Content-type:
> application/x-www-form-urlencoded\r\n";
>$postData .= "Content-length: ".strlen($qs)."\r\n\r\n";
>$postData .= $qs;
>
>if(!fputs($fp,$postData)) {
>   return false;
>   exit();
>}
>
>$data = "";
>while(!feof($fp)) $data .= fgets($fp,32000);
>$pos = 0;
>for($i=0; $i<2000; $i++) {
>   if(strtoupper(substr($data,$i,4)) == "\r\n\r\n") {
>  $pos = $i+4; $i = 2000;
>   }
>}
>$data = substr($data,$pos);
>
>$base = "
>$base = $base . "=";
>$base = $base . " 'http://$domain/' ";
>$base = $base . ">";
>
>if (eregi("
>   $data = eregi_replace("
>} else {
>   $data = $base . $data;
>}
>$this->RESPONSE = $data;
>fclose($fp);
>return true;
> }
>  ## END FUNCTION: post() ***
>  }
> ?>
>
> 
> 
>
> 
>
>
>
> /*Form information I am trying to send to- example only
> 
> Please log into MyMBI
> ID 
> Password

[PHP-DB] Design suggestions - performance improvement

2003-01-09 Thread Matthew Nock
Hi all,

I am currently building a site for a cinema to display session times, film synopsis' 
etc...

I have built the database as follows:

TABLE:  film_detail
FilmID
FilmName
FilmRunTime
FilmRating
FilmSynopsis
etc...

TABLE  session_data
session_ID
session_filmID
session_StartTime
session_Date


The session_data table might contain a large number of records with the same film ID, 
and the same Start Date to cover a large number of sessions that we would have of the 
same film on the same day.

I want to know what is the best way to retrieve this joint info from the DB.

currently, I run a single select statement requesting the fields I want from both 
tables, where the session_Date equals a given date.  This returns x number of rows, 
depending on the number of sessions for all films for that given day.

However, this means that I am retrieving the Film Synopsis, cast, runtime etc multiple 
times...

The data will be returned to the user as below:

FILM TITLE (rating)
session_times<--- will list all sessions - such as 8.45am, 10.15am, 12.00pm, 
2.00pm etc etc
FILM RUNTIME
FILM CAST
FILM SYNOPSIS

is this an effective way to return to he data?  or should I be using individual 
queries?

Any comments or suggestions would be most appreciated..

Cheers,


M@



RE: [PHP-DB] If select query doesn't net any results

2003-01-09 Thread John W. Holmes
> ...
> if ($result) {
>   while ($row...
>   ...
> }
> 
> $result will be 0 (false) if nothing satisfies the query.  Any other
> comparison is just extra typing with no improvement in logic.

No, it only returns false/0 if the query fails, meaning there was an
error and the query couldn't be executed. The query can execute just
fine, return no rows, and so the result would be true. 

What you have is extra typing with no improvement in logic. ;)

If you need to know the number of rows returned, then use the
if(mysql_num_rows() method. If you don't, then you can do this:

if($row = mysql_fetch_row($result))
{
do{
//do whatever with $row data
}while($row = mysql_fetch_row($result));
}
else
{ echo "no rows returned from query"; }

If you simply do not want something done if no rows are returned, then
the simple while($row = mysql_fetch_row($result)) method works fine, as
the while() will only be true if rows were returned and skipped if no
rows are returned.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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




Re: [PHP-DB] OR on multiple columns

2003-01-09 Thread David Chamberlin


Jason Wong wrote:

On Thursday 09 January 2003 08:36, David Chamberlin wrote:


I was reading the mysql docs and noticed a section on searching on
multiple keys (stupid question - keys=columns?).  It says doing an OR on
multiple keys is inefficient, and you should use a temp table.  Here's
their example:

CREATE TEMPORARY TABLE tmp
SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1';
INSERT INTO tmp
SELECT field1_index, field2_index FROM test_table WHERE field2_index = '1';
SELECT * from tmp;
DROP TABLE tmp;

My question is, is there a point at which this temp table is less
efficient?  


That may depend upon your particular circumstances, and hence running your own 
tests on both methods would give you the best answer.

OK, so what's the best way to go about profiling this?  Everything runs 
on my ISP's server.

Thanks,
Dave


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



Re: [PHP-DB] which DBMS... MySQL or PostgreSQL

2003-01-09 Thread Chris Boget
> Hmm.. so it means that I should choose PG ???

That's not something we can answer as it very much depends
on your needs.  Look at the features that PG has v. the features
that MySQL has and decide based on that.  If you don't need the
functionality PG offers that MySQL doesn't, go with MySQL as 
it's faster and easier to learn.  Otherwise go with PG.

Chris


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




RE: [PHP-DB] which DBMS... MySQL or PostgreSQL

2003-01-09 Thread dufronte
Hmm.. so it means that I should choose PG ???

#Please join Open Community Forum... http://openity.tk  #We're free to
discuss anything
 
   ---DuFronte--- 
  http://kapsul.org
  No Fuckin' Shits !!

> -Original Message-
> From: Jason Wong [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 10, 2003 2:56 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] which DBMS... MySQL or PostgreSQL
> 
> On Friday 10 January 2003 03:48, dufronte wrote:
> > I want to start my Open-Source Project.. PHP-Based RPG Webgame in
the
> > next 2 months.. Till now, I still confuse in choosing 2 DBMS.
> > MySQL and PostgreSQL.  In your opinions, which DB should I use in
> > consider that my Game will content a very big database including
Player
> > data, player Stats, Story and Scenario Database , etc. which one
that
> > easy to access, fast, and could maintain the sql file in small
size..
> > and easy to backup 
> 
> This question has recently been asked and answered -- search the
archives
> (both php-db and php-general). Also google "MySQL vs PostgreSQL"
should be
> helpful.
> 
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development
*
> 
> 
> /*
> It is better to wear out than to rust out.
> */
> 
> 
> --
> 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] which DBMS... MySQL or PostgreSQL

2003-01-09 Thread dufronte
Oh yeah.. I see... thx for the info...


#Please join Open Community Forum... http://openity.tk  #We're free to
discuss anything
 
   ---DuFronte--- 
  http://kapsul.org
  No Fuckin' Shits !!

> -Original Message-
> From: Jason Wong [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 10, 2003 2:56 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] which DBMS... MySQL or PostgreSQL
> 
> On Friday 10 January 2003 03:48, dufronte wrote:
> > I want to start my Open-Source Project.. PHP-Based RPG Webgame in
the
> > next 2 months.. Till now, I still confuse in choosing 2 DBMS.
> > MySQL and PostgreSQL.  In your opinions, which DB should I use in
> > consider that my Game will content a very big database including
Player
> > data, player Stats, Story and Scenario Database , etc. which one
that
> > easy to access, fast, and could maintain the sql file in small
size..
> > and easy to backup 
> 
> This question has recently been asked and answered -- search the
archives
> (both php-db and php-general). Also google "MySQL vs PostgreSQL"
should be
> helpful.
> 
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development
*
> 
> 
> /*
> It is better to wear out than to rust out.
> */
> 
> 
> --
> 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] which DBMS... MySQL or PostgreSQL

2003-01-09 Thread Jason Wong
On Friday 10 January 2003 03:48, dufronte wrote:
> I want to start my Open-Source Project.. PHP-Based RPG Webgame in the
> next 2 months.. Till now, I still confuse in choosing 2 DBMS.
> MySQL and PostgreSQL.  In your opinions, which DB should I use in
> consider that my Game will content a very big database including Player
> data, player Stats, Story and Scenario Database , etc. which one that
> easy to access, fast, and could maintain the sql file in small size..
> and easy to backup 

This question has recently been asked and answered -- search the archives 
(both php-db and php-general). Also google "MySQL vs PostgreSQL" should be 
helpful.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
It is better to wear out than to rust out.
*/


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




[PHP-DB] which DBMS... MySQL or PostgreSQL

2003-01-09 Thread dufronte
I want to start my Open-Source Project.. PHP-Based RPG Webgame in the
next 2 months.. Till now, I still confuse in choosing 2 DBMS.
MySQL and PostgreSQL.  In your opinions, which DB should I use in
consider that my Game will content a very big database including Player
data, player Stats, Story and Scenario Database , etc. which one that
easy to access, fast, and could maintain the sql file in small size..
and easy to backup 
 
Thanks for your advise.
 
 
 
 
#Please join Open Community Forum... http://openity.tk  #We're free to
discuss anything, you're free to create your own topic in your own
language. :D
 
 
   ---DuFronte--- 
  http://kapsul.org
  No Fuckin' Shits !!
 



Re: [PHP-DB] Authenticating through a php script

2003-01-09 Thread David Smith
I haven't looked over all your code in detail, but the problem you
describe seems to be best solved using PHP Sessions. Sessions store data
between browser refreshes. You could store whether a user has been
authenticated via LDAP, and then on a subsequent page, you can reference
that information to determine how to proceed.

Here's the doc: http://www.php.net/manual/en/ref.session.php

--Dave

On Thu, 2003-01-09 at 11:29, Jeremy Peterson wrote:
> David,
> 
> I have ldap working, my problem is the second half of my question.
> 
> The problem script workflow:
> 1. Authenticate on LDAP (Resolved)
> 2. Connect to different authenticated site for the user  (Not sure where to 
> go now.)
> 
> My guess was to send the post information to where the form action points 
> to.  Having done this, all I get is a blank page.  I guess if  PHP sends 
> the post information then the client will be out of the authentication 
> loop.  There must be a better way.  But I don't think I have enough 
> information to know how to proceed.
> 
> Somehow I have to get the browser to send the http post rather than 
> PHP.  Is this possible.
> 
> Jeremy
> 
> P.S.
> 
> The script I am using right now incorporates Chris Alsop's class:
> 
> 
> 
> ## Archive:c_http.class
>## Description:Basic http class functions (only post right now)
>## Author: Chris Alsop - [EMAIL PROTECTED] (rumblefiz)
>## Property Of:Everyone
>## Date Created:   07/01/2001
>## Mod History:07/01/2001   Chris Alsop - Initial Coding
>## 
> ==
>   class c_http {
>  ## DECLARE CLASS VARIABLES 
> var $QUERY_STRING;
> var $TARGET_DOMAIN;
> var $TARGET_FILE;
> var $RESPONSE;
>  ## END CLASS VARIABLE DECLARATION -
> 
>  ## FUNCTION: c_http()
>  ## ARGS: $psQueryString : String
>  ##   $psTargetDomain : String
>  ##   $psTargetFile : String
>  ## 
> function c_http($psQueryString,
>$psTargetDomain,$psTargetFile) {
> 
>$this->QUERY_STRING  = $psQueryString;
>$this->TARGET_DOMAIN = $psTargetDomain;
>$this->TARGET_FILE   = $psTargetFile;
> }
>  ## END FUNCTION: c_http() *
> 
>  ## FUNCTION: post()
>  ## ARGS: None
>  ## RETURNS:  Boolean
>  ## 
> function post() {
>$qs  = $this->QUERY_STRING;
>$domain  = $this->TARGET_DOMAIN;
>$thefile = $this->TARGET_FILE;
>if(!$fp = fsockopen($domain,80)) {
>   print "Socket not open";
>   return false;
>   exit();
>}
>$postData  = "POST http://$domain/$thefile HTTP/1.0\r\n";
>$postData .= "Content-type: 
> application/x-www-form-urlencoded\r\n";
>$postData .= "Content-length: ".strlen($qs)."\r\n\r\n";
>$postData .= $qs;
> 
>if(!fputs($fp,$postData)) {
>   return false;
>   exit();
>}
> 
>$data = "";
>while(!feof($fp)) $data .= fgets($fp,32000);
>$pos = 0;
>for($i=0; $i<2000; $i++) {
>   if(strtoupper(substr($data,$i,4)) == "\r\n\r\n") {
>  $pos = $i+4; $i = 2000;
>   }
>}
>$data = substr($data,$pos);
> 
>$base = "$base = $base . "=";
>$base = $base . " 'http://$domain/' ";
>$base = $base . ">";
> 
>if (eregi("   $data = eregi_replace("} else {
>   $data = $base . $data;
>}
>$this->RESPONSE = $data;
>fclose($fp);
>return true;
> }
>  ## END FUNCTION: post() ***
>  }
> ?>
> 
> 
> 
> 
>  
> 
> 
> /*Form information I am trying to send to- example only
> 
> Please log into MyMBI
> ID 
> Password
> 
> 
> */
> //setting up the varibles
> 
> //   print "hi test 1";
> $post_info = "meuser=***&password=**";
> 
> $oHttp = new c_http($post_info,"my.mbinet.net","/login.php");
> if(!$oHttp->post()) {
>echo "error";
> }
> 
> echo $oHttp->RESPONSE;
> //   first arg is the query string you want to post. it must be urlencoded. 
> if you want the current querystring you can use $QUERY_STRING. the second 
> arg is the domain and the third is the file (or script) that is getting 
> posted to.
> ?>
> 
> 
> 
> 
> 
> 
> At 10:28 AM 1/9/2003 -0700, David Smith wrote:

Re: [PHP-DB] two inserts at once?

2003-01-09 Thread Michael Knauf/Niles

Well what do ya know, this works! Thanks for the pointer.

if ($tableid=="newfaq") {
  echo "adding FAQ";
  $newfaq_query =  "INSERT INTO `faq` (`faqid`, `question`, `answer`)
VALUES ('', '$question', '$answer')";
  $newfaqResult = mysql_query($newfaq_query);
  $newfaq_query2 = "INSERT into `faqRelatedToProduct` (`id`,
`fgNumber`, `faqid`) VALUES ('', '$fgNumber', last_insert_id() )";
  $newfaqResult2 = mysql_query($newfaq_query2);
  echo $newfaq_query."".$newfaq_query2;
}

Michael



   
  
  Jason Wong   
  
   cc: 
  
   Subject:  Re: [PHP-DB] two inserts at 
once?   
  01/09/03 01:08 PM
  
  Please respond to
  
  php-db   
  
   
  
   
  




On Friday 10 January 2003 01:04, Michael Knauf/Niles wrote:
> This Code Snippet works:
>
> $newfaq_query =  "INSERT INTO `faq` (`faqid`, `question`, `answer`)
VALUES
> ('', '$question', '$answer')";
> $newfeaturesResult = mysql_query($newfeatures_query);
>
> But I'd like to combine that query with this one:
>
> INSERT INTO `faqRelatedToProduct` (`id`, `fgNumber`, `faqId`) VALUES ('',
> '$fgNumber', '$faqid');
>
> So that both are executed at the same time.

The current php-mysql interface only allows single queries at a time.

> The variables $question, $answer, $fgNumber come from a form, the faqid
is
> a auto increment field, as is id... but it seems I need to know the value
> of faqid to relate it correctly to the fgNumber...

The retrieve faqid use mysql_insert_id().

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
The more you sweat in peace, the less you bleed in war.
*/


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

Niles Audio Corporation
This mail is confidential







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




Re: [PHP-DB] If select query doesn't net any results

2003-01-09 Thread Doug Thompson
...
if ($result) {
while ($row...
...
}

$result will be 0 (false) if nothing satisfies the query.  Any other
comparison is just extra typing with no improvement in logic.

Regards,
Doug


On Thu, 09 Jan 2003 13:06:51 -0500, Michael Cortes wrote:

>I am a programming novice and just created my first php application.  However I have 
>a situation I 
>don't know the answer to.
>
>
>My db queries (mysql) are written like this:
>
>   $qtrans= "select * from $table where (conditionals) order by some field";
>
>   $link=mysql_connect ($host, $user, $password);
>
>   $result=mysql_db_query($dbname, $qtrans, $link);
>
>   while ($row = mysql_fetch_array($result))   {
>
>   do stuff with the array here
>   
>   }
>
>
>
>I would like to created an if statement that only occurs if the query gets a result.  
>If there are 
>no records that meet the query conditionals and my array ends up with null, I do not 
>want my if 
>statement to take place.
>
>Is this easy enough to do?  Any help would be great.
>
>Thank you,
>
>
>
>
>Michael Cortes
>Fort LeBoeuf School District
>34 East 9th Street
>PO Box 810
>Waterford PA 16411-0810
>814.796.4795
>Fax1 814.796.3358
>Fax2 978-389-1258





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




RE: [PHP-DB] Stumped...

2003-01-09 Thread NIPP, SCOTT V (SBCSI)
Nevermind.  I just stumbled across the nature of my problem on
Deja.com.  Thanks anyway and sorry for bugging you guys about what really
was a simple problem.

-Original Message-
From: Hutchins, Richard [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 09, 2003 12:36 PM
To: NIPP, SCOTT V (SBCSI); '[EMAIL PROTECTED]'
Subject: RE: [PHP-DB] Stumped...


Post your SQL statement.

> -Original Message-
> From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 09, 2003 1:37 PM
> To: '[EMAIL PROTECTED]'
> Subject: [PHP-DB] Stumped...
> 
> 
>   I am getting an error that is proving very difficult to 
> isolate and
> was hoping for help.  The error is: Column count doesn't 
> match value count
> at row 1.  I would include the code, but it is about 350 
> lines, and I am not
> sure where to narrow it down at.  Any ideas?  Thanks.
> 
> Scott Nipp
> Phone:  (214) 858-1289
> E-mail:  [EMAIL PROTECTED]
> Web:  http:\\ldsa.sbcld.sbc.com
> 
> 
> 
> -- 
> 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] Stumped...

2003-01-09 Thread Jim
it sounds like you are doing an INSERT and the table has fewer columns then
the VALUES clause has. Check your code for an INSERT statement then match
your values up with the table structure, check for hidden commas in your
value information.

Jim
 
---Original Message---
 
From: NIPP, SCOTT V (SBCSI)
Date: Thursday, January 09, 2003 10:41:21 AM
To: '[EMAIL PROTECTED]'
Subject: [PHP-DB] Stumped...
 
I am getting an error that is proving very difficult to isolate and
was hoping for help. The error is: Column count doesn't match value count
at row 1. I would include the code, but it is about 350 lines, and I am not
sure where to narrow it down at. Any ideas? Thanks.

Scott Nipp
Phone: (214) 858-1289
E-mail: [EMAIL PROTECTED]
Web: http:\\ldsa.sbcld.sbc.com



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

. 


RE: [PHP-DB] Stumped...

2003-01-09 Thread Hutchins, Richard
Post your SQL statement.

> -Original Message-
> From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 09, 2003 1:37 PM
> To: '[EMAIL PROTECTED]'
> Subject: [PHP-DB] Stumped...
> 
> 
>   I am getting an error that is proving very difficult to 
> isolate and
> was hoping for help.  The error is: Column count doesn't 
> match value count
> at row 1.  I would include the code, but it is about 350 
> lines, and I am not
> sure where to narrow it down at.  Any ideas?  Thanks.
> 
> Scott Nipp
> Phone:  (214) 858-1289
> E-mail:  [EMAIL PROTECTED]
> Web:  http:\\ldsa.sbcld.sbc.com
> 
> 
> 
> -- 
> 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] Stumped...

2003-01-09 Thread NIPP, SCOTT V (SBCSI)
I am getting an error that is proving very difficult to isolate and
was hoping for help.  The error is: Column count doesn't match value count
at row 1.  I would include the code, but it is about 350 lines, and I am not
sure where to narrow it down at.  Any ideas?  Thanks.

Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com



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




Re: [PHP-DB] Authenticating through a php script

2003-01-09 Thread Jeremy Peterson
David,

I have ldap working, my problem is the second half of my question.

The problem script workflow:
1. Authenticate on LDAP (Resolved)
2. Connect to different authenticated site for the user  (Not sure where to 
go now.)

My guess was to send the post information to where the form action points 
to.  Having done this, all I get is a blank page.  I guess if  PHP sends 
the post information then the client will be out of the authentication 
loop.  There must be a better way.  But I don't think I have enough 
information to know how to proceed.

Somehow I have to get the browser to send the http post rather than 
PHP.  Is this possible.

Jeremy

P.S.

The script I am using right now incorporates Chris Alsop's class:




  ## Archive:c_http.class
  ## Description:Basic http class functions (only post right now)
  ## Author: Chris Alsop - [EMAIL PROTECTED] (rumblefiz)
  ## Property Of:Everyone
  ## Date Created:   07/01/2001
  ## Mod History:07/01/2001   Chris Alsop - Initial Coding
  ## 
==
 class c_http {
## DECLARE CLASS VARIABLES 
   var $QUERY_STRING;
   var $TARGET_DOMAIN;
   var $TARGET_FILE;
   var $RESPONSE;
## END CLASS VARIABLE DECLARATION -

## FUNCTION: c_http()
## ARGS: $psQueryString : String
##   $psTargetDomain : String
##   $psTargetFile : String
## 
   function c_http($psQueryString,
  $psTargetDomain,$psTargetFile) {

  $this->QUERY_STRING  = $psQueryString;
  $this->TARGET_DOMAIN = $psTargetDomain;
  $this->TARGET_FILE   = $psTargetFile;
   }
## END FUNCTION: c_http() *

## FUNCTION: post()
## ARGS: None
## RETURNS:  Boolean
## 
   function post() {
  $qs  = $this->QUERY_STRING;
  $domain  = $this->TARGET_DOMAIN;
  $thefile = $this->TARGET_FILE;
  if(!$fp = fsockopen($domain,80)) {
 print "Socket not open";
 return false;
 exit();
  }
  $postData  = "POST http://$domain/$thefile HTTP/1.0\r\n";
  $postData .= "Content-type: 
application/x-www-form-urlencoded\r\n";
  $postData .= "Content-length: ".strlen($qs)."\r\n\r\n";
  $postData .= $qs;

  if(!fputs($fp,$postData)) {
 return false;
 exit();
  }

  $data = "";
  while(!feof($fp)) $data .= fgets($fp,32000);
  $pos = 0;
  for($i=0; $i<2000; $i++) {
 if(strtoupper(substr($data,$i,4)) == "\r\n\r\n") {
$pos = $i+4; $i = 2000;
 }
  }
  $data = substr($data,$pos);

  $base = "
  $base = $base . "=";
  $base = $base . " 'http://$domain/' ";
  $base = $base . ">";

  if (eregi("
 $data = eregi_replace("
  } else {
 $data = $base . $data;
  }
  $this->RESPONSE = $data;
  fclose($fp);
  return true;
   }
## END FUNCTION: post() ***
}
?>








/*Form information I am trying to send to- example only

Please log into MyMBI
ID 
Password


*/
//setting up the varibles

//   print "hi test 1";
$post_info = "meuser=***&password=**";

   $oHttp = new c_http($post_info,"my.mbinet.net","/login.php");
   if(!$oHttp->post()) {
  echo "error";
   }

   echo $oHttp->RESPONSE;
//   first arg is the query string you want to post. it must be urlencoded. 
if you want the current querystring you can use $QUERY_STRING. the second 
arg is the domain and the third is the file (or script) that is getting 
posted to.
?>






At 10:28 AM 1/9/2003 -0700, David Smith wrote:
Jeremy,

LDAP authentication happens in two stages: connect and bind. The connect
stage is just establishing a connection with the LDAP server
(ldap_connect()). No username or password is necesary in this stage.
Once your connection is established, you attempt a bind (ldap_bind())to
verify a username/password on the LDAP server. Here's some PHP code that
will do it or you:



$ldap_server = "example.com"; // change to your LDAP server host name
$ldap_port = 389; // might be different for your server
$pw = "yourpassword"; // change to your password
$dn = "cn=dave,ou=people,dc=example,dc=com"; // change to the dn you want 
to authenticate

$connect_result = ldap_connect( $ldap_server, $ldap_port );

// Did we connect?
if( ! $connect_result )
{
echo "Could not connect to '$server_name' on port

Re: [PHP-DB] LEFT JOIN not working

2003-01-09 Thread Ignatius Reilly
Oops! I missed again.

If you specify conditions pertaining to the right-hand table, such as:
ads_clickrate.date = '2001',

Then you will lose all result rows for which the right-hand data is NULL.
Not the expected result.

So your restricting WHERE clauses must apply to the left-hand table only.

Therefore:
WHERE YEAR(ads_displayrate.date) = '2003' AND MONTH(ads_displayrate.date) =
'01'
(if your table ads_displayrate has such date fields).

HTH
Ignatius

- Original Message -
From: "Lisi" <[EMAIL PROTECTED]>
To: "Ignatius Reilly" <[EMAIL PROTECTED]>
Sent: Thursday, January 09, 2003 6:54 PM
Subject: Re: [PHP-DB] LEFT JOIN not working


> Cool! It's mostly working now, the only problem is it's ignoring the other
> clauses in the ON clause that select the desired date. Perhaps it's not
> supposed to be connected this way? How would I select specific dates?
>
> Thanks again,
>
> -Lisi
>
> At 01:20 PM 1/9/03 +0100, you wrote:
> >Oops! Sorry, I missed it the first time.
> >
> >Your query should start as:
> >SELECT ads_displayrate.name
> >instead of
> >SELECT ads_clickrate.name
> >
> >then you will always have a non-NULL name (coming from the table on the
left
> >of the LEFT JOIN).
> >
> >HTH
> >Ignatius, from Brussels
> >
> >"Where the fuck is Belgium?"
> >D. Ivester, CEO, Coca Cola
> >
> >
> >- Original Message -
> >From: "Lisi" <[EMAIL PROTECTED]>
> >To: "Ignatius Reilly" <[EMAIL PROTECTED]>; "PHP-DB"
> ><[EMAIL PROTECTED]>
> >Sent: Thursday, January 09, 2003 1:11 PM
> >Subject: Re: [PHP-DB] LEFT JOIN not working
> >
> >
> > > Exactly my question - why does it not have a name? How would I modify
my
> > > query to get a row with a name but null value for date? I thought the
join
> > > would take care of this, but I'm obviously not doing it right.
> > >
> > > You mention a unique identifier, there is a separate table with a row
for
> > > each ad, containing name, URL, and a unique ID number (autoincrement).
> > > Should this table be included somehow in the query? How would this
help?
> > >
> > > Thanks,
> > >
> > > -Lisi
> > >
> > > At 12:45 PM 1/9/03 +0100, Ignatius Reilly wrote:
> > > >Your 4th row ought to have an identifier of some sort. From your
SELECT
> > > >statement, this seems to be the name. Why does it not have a name?
> >Probably
> > > >what you want is a row with a name but a NULL value for
> >ads_clickrate.date.
> > > >
> > > >(by the way it is EXTREMELY advisable to use an abstract identifier,
such
> >as
> > > >an id, unique and required, instead of "name")
> > > >
> > > >Ignatius
> > > >
> > > >- Original Message -
> > > >From: "Lisi" <[EMAIL PROTECTED]>
> > > >To: "Ignatius Reilly" <[EMAIL PROTECTED]>; "PHP-DB"
> > > ><[EMAIL PROTECTED]>
> > > >Sent: Thursday, January 09, 2003 12:18 PM
> > > >Subject: Re: [PHP-DB] LEFT JOIN not working
> > > >
> > > >
> > > > > OK, this helped a bit.  Now I have, in addition to the three rows
of
> >ads
> > > > > that have ben clicked on, a fourth row with no ad name, 0
> >clickthroughs,
> > > > > and 24 displays. That plus the other three account for all the
> >displayed
> > > >ads.
> > > > >
> > > > > However, since it is returning a null value for any ad name that
has
> >not
> > > > > been clicked on, and then it's grouped by ad name, it lumps all
> > > >non-clicked
> > > > > ads into one row. What I need is to see each ad on a separate row,
> >which
> > > >is
> > > > > what I thought a LEFT JOIN was supposed to do.
> > > > >
> > > > > Any suggestions?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > -Lisi
> > > > >
> > > > >
> > > > > At 11:07 AM 1/9/03 +0100, Ignatius Reilly wrote:
> > > > > >problem 1:
> > > > > >move the WHERE clauses to the ON clauses
> > > > > >
> > > > > >problem 2:
> > > > > >Obviously your intent with " COUNT(ads_clickrate.date) " is to
count
> >the
> > > > > >number of non-null occurences of click. But COUNT() is not the
> > > >appropriate
> > > > > >function to do this (it will simply give you the number of rows
> >inside a
> > > > > >group).
> > > > > >
> > > > > >Try replacing COUNT(ads_clickrate.date) by SUM( IF(
> >ads_clickrate.date IS
> > > > > >NULL, 0, 1 ) )
> > > > > >
> > > > > >HTH
> > > > > >Ignatius
> > > > > >
> > > > > >- Original Message -
> > > > > >From: "Lisi" <[EMAIL PROTECTED]>
> > > > > >To: "PHP-DB" <[EMAIL PROTECTED]>
> > > > > >Sent: Thursday, January 09, 2003 10:44 AM
> > > > > >Subject: [PHP-DB] LEFT JOIN not working
> > > > > >
> > > > > >
> > > > > > > I have a page with many ads that stores both the number of
times
> >an ad
> > > >is
> > > > > > > displayed and how many times it gets clicked.  These are
stored in
> >two
> > > > > > > different tables (since different information is stored for
each)
> >but
> > > >both
> > > > > > > have identical name columns. I am trying to display both #
times
> >

Re: [PHP-DB] two inserts at once?

2003-01-09 Thread Jason Wong
On Friday 10 January 2003 01:04, Michael Knauf/Niles wrote:
> This Code Snippet works:
>
> $newfaq_query =  "INSERT INTO `faq` (`faqid`, `question`, `answer`) VALUES
> ('', '$question', '$answer')";
> $newfeaturesResult = mysql_query($newfeatures_query);
>
> But I'd like to combine that query with this one:
>
> INSERT INTO `faqRelatedToProduct` (`id`, `fgNumber`, `faqId`) VALUES ('',
> '$fgNumber', '$faqid');
>
> So that both are executed at the same time.

The current php-mysql interface only allows single queries at a time.

> The variables $question, $answer, $fgNumber come from a form, the faqid is
> a auto increment field, as is id... but it seems I need to know the value
> of faqid to relate it correctly to the fgNumber...

The retrieve faqid use mysql_insert_id().

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
The more you sweat in peace, the less you bleed in war.
*/


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




Re: [PHP-DB] If select query doesn't net any results

2003-01-09 Thread Chris Boget
> I would like to created an if statement that only occurs if the query gets a result. 
> If there are 
> no records that meet the query conditionals and my array ends up with null, I do not 
>want my if 
> statement to take place.
> Is this easy enough to do?  Any help would be great.

if( mysql_num_rows( $result ) > 0 ) {
  // Records were returned
  // Do something here
  // 

}

Chris


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




RE: [PHP-DB] If select query doesn't net any results

2003-01-09 Thread Ryan Jameson (USA)
if (mysql_num_rows($result) < 1) {
  //do stuff
}

This is only this easy with mySQL... :-)

<>< Ryan

-Original Message-
From: Michael Cortes [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 09, 2003 11:07 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] If select query doesn't net any results


I am a programming novice and just created my first php application.  However I have a 
situation I 
don't know the answer to.


My db queries (mysql) are written like this:

$qtrans= "select * from $table where (conditionals) order by some field";

$link=mysql_connect ($host, $user, $password);

$result=mysql_db_query($dbname, $qtrans, $link);

while ($row = mysql_fetch_array($result))   {

do stuff with the array here

}



I would like to created an if statement that only occurs if the query gets a result.  
If there are 
no records that meet the query conditionals and my array ends up with null, I do not 
want my if 
statement to take place.

Is this easy enough to do?  Any help would be great.

Thank you,




Michael Cortes
Fort LeBoeuf School District
34 East 9th Street
PO Box 810
Waterford PA 16411-0810
814.796.4795
Fax1 814.796.3358
Fax2 978-389-1258


-- 
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] If select query doesn't net any results

2003-01-09 Thread Michael Cortes
I am a programming novice and just created my first php application.  However I have a 
situation I 
don't know the answer to.


My db queries (mysql) are written like this:

$qtrans= "select * from $table where (conditionals) order by some field";

$link=mysql_connect ($host, $user, $password);

$result=mysql_db_query($dbname, $qtrans, $link);

while ($row = mysql_fetch_array($result))   {

do stuff with the array here

}



I would like to created an if statement that only occurs if the query gets a result.  
If there are 
no records that meet the query conditionals and my array ends up with null, I do not 
want my if 
statement to take place.

Is this easy enough to do?  Any help would be great.

Thank you,




Michael Cortes
Fort LeBoeuf School District
34 East 9th Street
PO Box 810
Waterford PA 16411-0810
814.796.4795
Fax1 814.796.3358
Fax2 978-389-1258


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




Re: [PHP-DB] Authenticating through a php script

2003-01-09 Thread David Smith
Jeremy,

LDAP authentication happens in two stages: connect and bind. The connect
stage is just establishing a connection with the LDAP server
(ldap_connect()). No username or password is necesary in this stage.
Once your connection is established, you attempt a bind (ldap_bind())to
verify a username/password on the LDAP server. Here's some PHP code that
will do it or you:



Here's some good documentation on the topic:
http://www.php.net/manual/en/ref.ldap.php

Let us know how it goes.

--Dave



On Thu, 2003-01-09 at 10:01, Jeremy Peterson wrote:
> I am working on a script that will authenticate on a central system my
> company has devised for us to use (LDAP) and then authenticate them to
> other sites that I want them to access (Online Databases and other
> electronic resources I do not control but pay lots of money for all
> students to access).
> 
> I have seen this done on a product produced by Epixtech called RPA
> (Remote Patron Authentication).  This is an authentication system that
> avoids using a proxy server. It basically handles the authentication
> (LDAP) and sends the appropriate information to the other secure
> source (Online Database, Electronic Resources, or my online catalog's
> patron information.)  Typically there are multiple ways it will
> authenticate for the user to other resources.  URL referer, ip
> authentication, fill in an user/password form for the user.  I just
> can't get the user/password portion to work on a protected site.  My tests 
> of sending post information to another one of my scripts works fine.  But 
> it doesn't work as of yet.
> 
> I have worked a bit with scripts that send post information through
> sendToHost function (fsockopen and fputs).  But nothing is really
> working here.  Does anyone know how I should go about this?  All
> suggestions will be great!
> 
> 
> Thanks a bunch,
> 
> Jeremy



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




Re: [PHP-DB] preventing page from resubmitting when refreshing page

2003-01-09 Thread Chris Boget
> Is there something i can do on browser refresh to prevent this or prevent my
> mysql database from duplicating the records?

Instead of using INSERT in your query use REPLACE INTO.
Alternately, after you are done processing the form, do this:

header( "location: $PHP_SELF?$QUERY_STRING" );
exit()

So the page will redirect to itself and it'll be like you went to it
the first time.

These are just two of I'm sure the many other options what will
come through.

Chris


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




RE: [PHP-DB] preventing page from resubmitting when refreshing page

2003-01-09 Thread Hutchins, Richard
I use logic like this to avoid this problem:

Submit data from form to a separate PHP script that handles the database
submission then forwards to a results page which queries the database for
the information from an ID passed along with the page forward.

If you do this, when you refresh the results page, the only thing that gets
performed is the SELECT since the INSERT/UPDATE logic is in a separate
script.

There may be other ways, but that's what I do. Hope this helps.

Rich

> -Original Message-
> From: mike karthauser [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 09, 2003 12:24 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] preventing page from resubmitting when 
> refreshing page
> 
> 
> I have a page that has a form on the first part that posts to 
> itself and
> dumps the contents of the form into a database.
> 
> All this is well and good - I'm using
> 
> if ($_POST['submit']) {
> 
> 
> }
> 
> to detect the submission and everything is doing as it should.
> 
> Thing is if you refresh the page that displays the results it 
> then posts to
> the database again. I've tried some error trapping but in the 
> same way the
> page hold the post variables it just redoes what it has done 
> rather than re
> running the script.
> 
> Is there something i can do on browser refresh to prevent 
> this or prevent my
> mysql database from duplicating the records?
> 
> any help would be appreciated.
> 
> cheers
> mikek
> -- 
> Mike Karthauser 
> Managing Director - Brightstorm Ltd
> 
> Email   >> [EMAIL PROTECTED]
> Web >> http://www.brightstorm.co.uk
> Tel >> 0117 9426653 (office)
>07939 252144 (mobile)
> 
> Snailmail   >> Unit 8, 14 King Square,
>Bristol BS2 8JJ
> 
> 
> -- 
> 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 - php] Newline to BR problem

2003-01-09 Thread Aaron Wolski
You want to look at nl2br() function.

It takes newlines from a text like:

Hello

My name is

Aaron

Which when outputted normally would look like:

Hello my name is aaron

Using echo nl2br($dbquery); would produce:

Hello
My name is
Aaron

In your HTML code which then would output in a browse like the above.

Aaron

-Original Message-
From: Ro Stonemountain [mailto:[EMAIL PROTECTED]] 
Sent: January 9, 2003 10:53 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] [mysql - php] Newline to BR problem

I'm trying to place a text from a textfield into a database and
displaying
it on another page. All works fine and well but my problem is:

If i place newline characters (press enter) in the forms textfield they
don't show up on my display page. This is logical because newlines are
not
 codes. So i must replace the newline thingies with  code.
Should
this be done BEFORE i put the text in the database or AFTER i put the
text
in the database and what functions can i use

Maybe it's a newbie question but it's on my mind for a few days now and
i
haven't found an answer yet, thanx!



-- 
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] preventing page from resubmitting when refreshing page

2003-01-09 Thread mike karthauser
I have a page that has a form on the first part that posts to itself and
dumps the contents of the form into a database.

All this is well and good - I'm using

if ($_POST['submit']) {


}

to detect the submission and everything is doing as it should.

Thing is if you refresh the page that displays the results it then posts to
the database again. I've tried some error trapping but in the same way the
page hold the post variables it just redoes what it has done rather than re
running the script.

Is there something i can do on browser refresh to prevent this or prevent my
mysql database from duplicating the records?

any help would be appreciated.

cheers
mikek
-- 
Mike Karthauser 
Managing Director - Brightstorm Ltd

Email   >> [EMAIL PROTECTED]
Web >> http://www.brightstorm.co.uk
Tel >> 0117 9426653 (office)
   07939 252144 (mobile)

Snailmail   >> Unit 8, 14 King Square,
   Bristol BS2 8JJ


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




Re: [PHP-DB] two inserts at once?

2003-01-09 Thread Ignatius Reilly
If you are using MySQL, you can't.

(none of my business, but why not simplifying your table names: "faqProduct"
instead of "faqRelatedToProduct" ?)

Ignatius

- Original Message -
From: "Michael Knauf/Niles" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 09, 2003 6:04 PM
Subject: [PHP-DB] two inserts at once?


> This Code Snippet works:
>
> $newfaq_query =  "INSERT INTO `faq` (`faqid`, `question`, `answer`) VALUES
> ('', '$question', '$answer')";
> $newfeaturesResult = mysql_query($newfeatures_query);
>
> But I'd like to combine that query with this one:
>
> INSERT INTO `faqRelatedToProduct` (`id`, `fgNumber`, `faqId`) VALUES ('',
> '$fgNumber', '$faqid');
>
> So that both are executed at the same time.
>
> The variables $question, $answer, $fgNumber come from a form, the faqid is
> a auto increment field, as is id... but it seems I need to know the value
> of faqid to relate it correctly to the fgNumber...
>
> Is there a way to combine the two queries?
>
> Michael
>
>
>
> --
> 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] [mysql - php] Newline to BR problem

2003-01-09 Thread Ro Stonemountain
I'm trying to place a text from a textfield into a database and displaying
it on another page. All works fine and well but my problem is:

If i place newline characters (press enter) in the forms textfield they
don't show up on my display page. This is logical because newlines are not
 codes. So i must replace the newline thingies with  code. Should
this be done BEFORE i put the text in the database or AFTER i put the text
in the database and what functions can i use

Maybe it's a newbie question but it's on my mind for a few days now and i
haven't found an answer yet, thanx!



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




[PHP-DB] two inserts at once?

2003-01-09 Thread Michael Knauf/Niles
This Code Snippet works:

$newfaq_query =  "INSERT INTO `faq` (`faqid`, `question`, `answer`) VALUES
('', '$question', '$answer')";
$newfeaturesResult = mysql_query($newfeatures_query);

But I'd like to combine that query with this one:

INSERT INTO `faqRelatedToProduct` (`id`, `fgNumber`, `faqId`) VALUES ('',
'$fgNumber', '$faqid');

So that both are executed at the same time.

The variables $question, $answer, $fgNumber come from a form, the faqid is
a auto increment field, as is id... but it seems I need to know the value
of faqid to relate it correctly to the fgNumber...

Is there a way to combine the two queries?

Michael



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




[PHP-DB] Authenticating through a php script

2003-01-09 Thread Jeremy Peterson
I am working on a script that will authenticate on a central system my
company has devised for us to use (LDAP) and then authenticate them to
other sites that I want them to access (Online Databases and other
electronic resources I do not control but pay lots of money for all
students to access).

I have seen this done on a product produced by Epixtech called RPA
(Remote Patron Authentication).  This is an authentication system that
avoids using a proxy server. It basically handles the authentication
(LDAP) and sends the appropriate information to the other secure
source (Online Database, Electronic Resources, or my online catalog's
patron information.)  Typically there are multiple ways it will
authenticate for the user to other resources.  URL referer, ip
authentication, fill in an user/password form for the user.  I just
can't get the user/password portion to work on a protected site.  My tests 
of sending post information to another one of my scripts works fine.  But 
it doesn't work as of yet.

I have worked a bit with scripts that send post information through
sendToHost function (fsockopen and fputs).  But nothing is really
working here.  Does anyone know how I should go about this?  All
suggestions will be great!


Thanks a bunch,

Jeremy


[PHP-DB] Database Limitations

2003-01-09 Thread Brian Taylor
When I used to use perl to code, I ran into an issue where I would get an
error from the DBI module when i tried to insert more than 8000 characters
at one time.

I know php has it's own postgres functions, we use postgres, and I was
wondering if there where any limitations like that in php?

I know my limitation in perl was not perl or postgres, it was the DBI module
that we were using.

Thanks!

Brian Taylor
Web Developer

Verve Internet Solutions
   > for higher education
228 Krams Ave., Suite 300
Philadelphia, PA 19127
p: 215.508.4920
f: 215.508.4590
toll free: 1 866-672-2666
http://www.verveinternet.com 
>Verve is a division of MRB Communications, Inc
< http://www.mrbcomm.com  >





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




RE: [PHP-DB] denying access to folders/files

2003-01-09 Thread John W. Holmes
Not sure what's the question or the answer below... but anyway. To
protect your files, store them outside of the webroot or in the database
and use a PHP file to serve them up. The PHP file will check the
authentication or whatever of the user and if it's valid, serve up the
file to them with a proper header() call and sending the data of the
file. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 09, 2003 9:56 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] denying access to folders/files
> 
> 
> 
> Gary Every
> Sr. UNIX Administrator
> Ingram Entertainment
> (615) 287-4876
> "Pay It Forward"
> mailto:[EMAIL PROTECTED]
> http://accessingram.com
> 
> 
> This is fine and dandy, but how do I prevent that person from taking
the
> direct link to the file and giving it to someone else?
> 
> I'm sure there is a much better and simpler way. Idea's?
> 
> Answer: Use auto_prepend.php to authenticate the user.
> 
> 
> Thanks in advance.
> 
> --
> Darren Bentley <[EMAIL PROTECTED]>
> 
> 
> --
> 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] denying access to folders/files

2003-01-09 Thread Gary . Every


Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
"Pay It Forward"
mailto:[EMAIL PROTECTED]
http://accessingram.com


This is fine and dandy, but how do I prevent that person from taking the
direct link to the file and giving it to someone else?

I'm sure there is a much better and simpler way. Idea's?

Answer: Use auto_prepend.php to authenticate the user.


Thanks in advance.

-- 
Darren Bentley <[EMAIL PROTECTED]>


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



RE: [PHP-DB] mysql wildcard

2003-01-09 Thread Edward Peloke
Thanks!

select * from offtime where type='%' didn't work but when I change = to
'like' it works great!

Thanks,
Eddie

-Original Message-
From: Marco Tabini [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 4:57 PM
To: Edward Peloke
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] mysql wildcard


You probably want something like:

select * from offtime where type like '{$type}%'

As a side note, are you making sure that $type does not contain any
malicious code?

Cheers,


Marco
--

php|architect - The Monthly Magazine for PHP Professionals
Come check us out on the web at http://www.phparch.com!


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




Re: [PHP-DB] LEFT JOIN not working

2003-01-09 Thread Ignatius Reilly
Oops! Sorry, I missed it the first time.

Your query should start as:
SELECT ads_displayrate.name
instead of
SELECT ads_clickrate.name

then you will always have a non-NULL name (coming from the table on the left
of the LEFT JOIN).

HTH
Ignatius, from Brussels

"Where the fuck is Belgium?"
D. Ivester, CEO, Coca Cola


- Original Message -
From: "Lisi" <[EMAIL PROTECTED]>
To: "Ignatius Reilly" <[EMAIL PROTECTED]>; "PHP-DB"
<[EMAIL PROTECTED]>
Sent: Thursday, January 09, 2003 1:11 PM
Subject: Re: [PHP-DB] LEFT JOIN not working


> Exactly my question - why does it not have a name? How would I modify my
> query to get a row with a name but null value for date? I thought the join
> would take care of this, but I'm obviously not doing it right.
>
> You mention a unique identifier, there is a separate table with a row for
> each ad, containing name, URL, and a unique ID number (autoincrement).
> Should this table be included somehow in the query? How would this help?
>
> Thanks,
>
> -Lisi
>
> At 12:45 PM 1/9/03 +0100, Ignatius Reilly wrote:
> >Your 4th row ought to have an identifier of some sort. From your SELECT
> >statement, this seems to be the name. Why does it not have a name?
Probably
> >what you want is a row with a name but a NULL value for
ads_clickrate.date.
> >
> >(by the way it is EXTREMELY advisable to use an abstract identifier, such
as
> >an id, unique and required, instead of "name")
> >
> >Ignatius
> >
> >- Original Message -
> >From: "Lisi" <[EMAIL PROTECTED]>
> >To: "Ignatius Reilly" <[EMAIL PROTECTED]>; "PHP-DB"
> ><[EMAIL PROTECTED]>
> >Sent: Thursday, January 09, 2003 12:18 PM
> >Subject: Re: [PHP-DB] LEFT JOIN not working
> >
> >
> > > OK, this helped a bit.  Now I have, in addition to the three rows of
ads
> > > that have ben clicked on, a fourth row with no ad name, 0
clickthroughs,
> > > and 24 displays. That plus the other three account for all the
displayed
> >ads.
> > >
> > > However, since it is returning a null value for any ad name that has
not
> > > been clicked on, and then it's grouped by ad name, it lumps all
> >non-clicked
> > > ads into one row. What I need is to see each ad on a separate row,
which
> >is
> > > what I thought a LEFT JOIN was supposed to do.
> > >
> > > Any suggestions?
> > >
> > > Thanks,
> > >
> > > -Lisi
> > >
> > >
> > > At 11:07 AM 1/9/03 +0100, Ignatius Reilly wrote:
> > > >problem 1:
> > > >move the WHERE clauses to the ON clauses
> > > >
> > > >problem 2:
> > > >Obviously your intent with " COUNT(ads_clickrate.date) " is to count
the
> > > >number of non-null occurences of click. But COUNT() is not the
> >appropriate
> > > >function to do this (it will simply give you the number of rows
inside a
> > > >group).
> > > >
> > > >Try replacing COUNT(ads_clickrate.date) by SUM( IF(
ads_clickrate.date IS
> > > >NULL, 0, 1 ) )
> > > >
> > > >HTH
> > > >Ignatius
> > > >
> > > >- Original Message -
> > > >From: "Lisi" <[EMAIL PROTECTED]>
> > > >To: "PHP-DB" <[EMAIL PROTECTED]>
> > > >Sent: Thursday, January 09, 2003 10:44 AM
> > > >Subject: [PHP-DB] LEFT JOIN not working
> > > >
> > > >
> > > > > I have a page with many ads that stores both the number of times
an ad
> >is
> > > > > displayed and how many times it gets clicked.  These are stored in
two
> > > > > different tables (since different information is stored for each)
but
> >both
> > > > > have identical name columns. I am trying to display both # times
> >displayed
> > > > > and # times clicked in the same table in an admin page.
> > > > >
> > > > > Here is my query:
> > > > >
> > > > > SELECT ads_clickrate.name, ads_clickrate.link,
> >SUM(ads_displayrate.count)
> > > > > as display, COUNT(ads_clickrate.date) as click FROM
ads_displayrate
> >LEFT
> > > > > JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name
WHERE
> > > > > YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) =
'01'
> > > > > GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name
> > > > >
> > > > > I want to display for each ad the number of times displayed, and
then
> > > > > number of times clicked if applicable, if not 0.
> > > > >
> > > > > The query is only returning rows for ads that have been clicked
on. Is
> >the
> > > > > problem because I have a COUNT column for one table, with a group
by?
> >Is
> > > > > this causing the display to be grouped also?
> > > > >
> > > > > If you need more information how the table is set up let me know,
I'm
> > > > > really stumped here.
> > > > >
> > > > > Thanks,
> > > > >
> > > > > -Lisi
> > > > >
> > > > >
> > > > > --
> > > > > 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 D

Re: [PHP-DB] LEFT JOIN not working

2003-01-09 Thread Lisi
Exactly my question - why does it not have a name? How would I modify my 
query to get a row with a name but null value for date? I thought the join 
would take care of this, but I'm obviously not doing it right.

You mention a unique identifier, there is a separate table with a row for 
each ad, containing name, URL, and a unique ID number (autoincrement). 
Should this table be included somehow in the query? How would this help?

Thanks,

-Lisi

At 12:45 PM 1/9/03 +0100, Ignatius Reilly wrote:
Your 4th row ought to have an identifier of some sort. From your SELECT
statement, this seems to be the name. Why does it not have a name? Probably
what you want is a row with a name but a NULL value for ads_clickrate.date.

(by the way it is EXTREMELY advisable to use an abstract identifier, such as
an id, unique and required, instead of "name")

Ignatius

- Original Message -
From: "Lisi" <[EMAIL PROTECTED]>
To: "Ignatius Reilly" <[EMAIL PROTECTED]>; "PHP-DB"
<[EMAIL PROTECTED]>
Sent: Thursday, January 09, 2003 12:18 PM
Subject: Re: [PHP-DB] LEFT JOIN not working


> OK, this helped a bit.  Now I have, in addition to the three rows of ads
> that have ben clicked on, a fourth row with no ad name, 0 clickthroughs,
> and 24 displays. That plus the other three account for all the displayed
ads.
>
> However, since it is returning a null value for any ad name that has not
> been clicked on, and then it's grouped by ad name, it lumps all
non-clicked
> ads into one row. What I need is to see each ad on a separate row, which
is
> what I thought a LEFT JOIN was supposed to do.
>
> Any suggestions?
>
> Thanks,
>
> -Lisi
>
>
> At 11:07 AM 1/9/03 +0100, Ignatius Reilly wrote:
> >problem 1:
> >move the WHERE clauses to the ON clauses
> >
> >problem 2:
> >Obviously your intent with " COUNT(ads_clickrate.date) " is to count the
> >number of non-null occurences of click. But COUNT() is not the
appropriate
> >function to do this (it will simply give you the number of rows inside a
> >group).
> >
> >Try replacing COUNT(ads_clickrate.date) by SUM( IF( ads_clickrate.date IS
> >NULL, 0, 1 ) )
> >
> >HTH
> >Ignatius
> >
> >- Original Message -
> >From: "Lisi" <[EMAIL PROTECTED]>
> >To: "PHP-DB" <[EMAIL PROTECTED]>
> >Sent: Thursday, January 09, 2003 10:44 AM
> >Subject: [PHP-DB] LEFT JOIN not working
> >
> >
> > > I have a page with many ads that stores both the number of times an ad
is
> > > displayed and how many times it gets clicked.  These are stored in two
> > > different tables (since different information is stored for each) but
both
> > > have identical name columns. I am trying to display both # times
displayed
> > > and # times clicked in the same table in an admin page.
> > >
> > > Here is my query:
> > >
> > > SELECT ads_clickrate.name, ads_clickrate.link,
SUM(ads_displayrate.count)
> > > as display, COUNT(ads_clickrate.date) as click FROM ads_displayrate
LEFT
> > > JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name WHERE
> > > YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) = '01'
> > > GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name
> > >
> > > I want to display for each ad the number of times displayed, and then
> > > number of times clicked if applicable, if not 0.
> > >
> > > The query is only returning rows for ads that have been clicked on. Is
the
> > > problem because I have a COUNT column for one table, with a group by?
Is
> > > this causing the display to be grouped also?
> > >
> > > If you need more information how the table is set up let me know, I'm
> > > really stumped here.
> > >
> > > Thanks,
> > >
> > > -Lisi
> > >
> > >
> > > --
> > > 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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] LEFT JOIN not working

2003-01-09 Thread Ignatius Reilly
Your 4th row ought to have an identifier of some sort. From your SELECT
statement, this seems to be the name. Why does it not have a name? Probably
what you want is a row with a name but a NULL value for ads_clickrate.date.

(by the way it is EXTREMELY advisable to use an abstract identifier, such as
an id, unique and required, instead of "name")

Ignatius

- Original Message -
From: "Lisi" <[EMAIL PROTECTED]>
To: "Ignatius Reilly" <[EMAIL PROTECTED]>; "PHP-DB"
<[EMAIL PROTECTED]>
Sent: Thursday, January 09, 2003 12:18 PM
Subject: Re: [PHP-DB] LEFT JOIN not working


> OK, this helped a bit.  Now I have, in addition to the three rows of ads
> that have ben clicked on, a fourth row with no ad name, 0 clickthroughs,
> and 24 displays. That plus the other three account for all the displayed
ads.
>
> However, since it is returning a null value for any ad name that has not
> been clicked on, and then it's grouped by ad name, it lumps all
non-clicked
> ads into one row. What I need is to see each ad on a separate row, which
is
> what I thought a LEFT JOIN was supposed to do.
>
> Any suggestions?
>
> Thanks,
>
> -Lisi
>
>
> At 11:07 AM 1/9/03 +0100, Ignatius Reilly wrote:
> >problem 1:
> >move the WHERE clauses to the ON clauses
> >
> >problem 2:
> >Obviously your intent with " COUNT(ads_clickrate.date) " is to count the
> >number of non-null occurences of click. But COUNT() is not the
appropriate
> >function to do this (it will simply give you the number of rows inside a
> >group).
> >
> >Try replacing COUNT(ads_clickrate.date) by SUM( IF( ads_clickrate.date IS
> >NULL, 0, 1 ) )
> >
> >HTH
> >Ignatius
> >
> >- Original Message -
> >From: "Lisi" <[EMAIL PROTECTED]>
> >To: "PHP-DB" <[EMAIL PROTECTED]>
> >Sent: Thursday, January 09, 2003 10:44 AM
> >Subject: [PHP-DB] LEFT JOIN not working
> >
> >
> > > I have a page with many ads that stores both the number of times an ad
is
> > > displayed and how many times it gets clicked.  These are stored in two
> > > different tables (since different information is stored for each) but
both
> > > have identical name columns. I am trying to display both # times
displayed
> > > and # times clicked in the same table in an admin page.
> > >
> > > Here is my query:
> > >
> > > SELECT ads_clickrate.name, ads_clickrate.link,
SUM(ads_displayrate.count)
> > > as display, COUNT(ads_clickrate.date) as click FROM ads_displayrate
LEFT
> > > JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name WHERE
> > > YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) = '01'
> > > GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name
> > >
> > > I want to display for each ad the number of times displayed, and then
> > > number of times clicked if applicable, if not 0.
> > >
> > > The query is only returning rows for ads that have been clicked on. Is
the
> > > problem because I have a COUNT column for one table, with a group by?
Is
> > > this causing the display to be grouped also?
> > >
> > > If you need more information how the table is set up let me know, I'm
> > > really stumped here.
> > >
> > > Thanks,
> > >
> > > -Lisi
> > >
> > >
> > > --
> > > 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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] LEFT JOIN not working

2003-01-09 Thread Lisi
OK, this helped a bit.  Now I have, in addition to the three rows of ads 
that have ben clicked on, a fourth row with no ad name, 0 clickthroughs, 
and 24 displays. That plus the other three account for all the displayed ads.

However, since it is returning a null value for any ad name that has not 
been clicked on, and then it's grouped by ad name, it lumps all non-clicked 
ads into one row. What I need is to see each ad on a separate row, which is 
what I thought a LEFT JOIN was supposed to do.

Any suggestions?

Thanks,

-Lisi


At 11:07 AM 1/9/03 +0100, Ignatius Reilly wrote:
problem 1:
move the WHERE clauses to the ON clauses

problem 2:
Obviously your intent with " COUNT(ads_clickrate.date) " is to count the
number of non-null occurences of click. But COUNT() is not the appropriate
function to do this (it will simply give you the number of rows inside a
group).

Try replacing COUNT(ads_clickrate.date) by SUM( IF( ads_clickrate.date IS
NULL, 0, 1 ) )

HTH
Ignatius

- Original Message -
From: "Lisi" <[EMAIL PROTECTED]>
To: "PHP-DB" <[EMAIL PROTECTED]>
Sent: Thursday, January 09, 2003 10:44 AM
Subject: [PHP-DB] LEFT JOIN not working


> I have a page with many ads that stores both the number of times an ad is
> displayed and how many times it gets clicked.  These are stored in two
> different tables (since different information is stored for each) but both
> have identical name columns. I am trying to display both # times displayed
> and # times clicked in the same table in an admin page.
>
> Here is my query:
>
> SELECT ads_clickrate.name, ads_clickrate.link, SUM(ads_displayrate.count)
> as display, COUNT(ads_clickrate.date) as click FROM ads_displayrate LEFT
> JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name WHERE
> YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) = '01'
> GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name
>
> I want to display for each ad the number of times displayed, and then
> number of times clicked if applicable, if not 0.
>
> The query is only returning rows for ads that have been clicked on. Is the
> problem because I have a COUNT column for one table, with a group by? Is
> this causing the display to be grouped also?
>
> If you need more information how the table is set up let me know, I'm
> really stumped here.
>
> Thanks,
>
> -Lisi
>
>
> --
> 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] LEFT JOIN not working

2003-01-09 Thread Ignatius Reilly
problem 1:
move the WHERE clauses to the ON clauses

problem 2:
Obviously your intent with " COUNT(ads_clickrate.date) " is to count the
number of non-null occurences of click. But COUNT() is not the appropriate
function to do this (it will simply give you the number of rows inside a
group).

Try replacing COUNT(ads_clickrate.date) by SUM( IF( ads_clickrate.date IS
NULL, 0, 1 ) )

HTH
Ignatius

- Original Message -
From: "Lisi" <[EMAIL PROTECTED]>
To: "PHP-DB" <[EMAIL PROTECTED]>
Sent: Thursday, January 09, 2003 10:44 AM
Subject: [PHP-DB] LEFT JOIN not working


> I have a page with many ads that stores both the number of times an ad is
> displayed and how many times it gets clicked.  These are stored in two
> different tables (since different information is stored for each) but both
> have identical name columns. I am trying to display both # times displayed
> and # times clicked in the same table in an admin page.
>
> Here is my query:
>
> SELECT ads_clickrate.name, ads_clickrate.link, SUM(ads_displayrate.count)
> as display, COUNT(ads_clickrate.date) as click FROM ads_displayrate LEFT
> JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name WHERE
> YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) = '01'
> GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name
>
> I want to display for each ad the number of times displayed, and then
> number of times clicked if applicable, if not 0.
>
> The query is only returning rows for ads that have been clicked on. Is the
> problem because I have a COUNT column for one table, with a group by? Is
> this causing the display to be grouped also?
>
> If you need more information how the table is set up let me know, I'm
> really stumped here.
>
> Thanks,
>
> -Lisi
>
>
> --
> 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] LEFT JOIN not working

2003-01-09 Thread Lisi
I have a page with many ads that stores both the number of times an ad is 
displayed and how many times it gets clicked.  These are stored in two 
different tables (since different information is stored for each) but both 
have identical name columns. I am trying to display both # times displayed 
and # times clicked in the same table in an admin page.

Here is my query:

SELECT ads_clickrate.name, ads_clickrate.link, SUM(ads_displayrate.count) 
as display, COUNT(ads_clickrate.date) as click FROM ads_displayrate LEFT 
JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name WHERE 
YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) = '01' 
GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name

I want to display for each ad the number of times displayed, and then 
number of times clicked if applicable, if not 0.

The query is only returning rows for ads that have been clicked on. Is the 
problem because I have a COUNT column for one table, with a group by? Is 
this causing the display to be grouped also?

If you need more information how the table is set up let me know, I'm 
really stumped here.

Thanks,

-Lisi


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



RE: [PHP-DB] how use random in php

2003-01-09 Thread Snijders, Mark
check

www.php.net and search for array... then you will get a list of all the
array functions

try to find it out yourself first please

-mark-

-Original Message-
From: khac duy [mailto:[EMAIL PROTECTED]]
Sent: vrijdag 10 januari 2003 1:15
To: [EMAIL PROTECTED]
Subject: [PHP-DB] how use random in php


  in php only support shuffe(); function,i want random a array,how 


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




[PHP-DB] how use random in php

2003-01-09 Thread khac duy
  in php only support shuffe(); function,i want random a array,how 



RE: [PHP-DB] help me

2003-01-09 Thread Snijders, Mark

when using start_session

the code tries to write a file to the tmp dir...

think you are working under windows

so make in c: a \tmp dir !!!

then it should work



-Original Message-
From: khac duy [mailto:[EMAIL PROTECTED]]
Sent: vrijdag 10 januari 2003 1:08
To: [EMAIL PROTECTED]
Subject: [PHP-DB] help me


  i can't use start_secsion(); in php4, it say:
 error : can't ofen(\tmp/4363jghsfjkhshga.. like this...



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




Re: [PHP-DB] help me

2003-01-09 Thread rblack

Are you running on windows or Linux???

This looks like a Windows problem - you have to set your
"SESSION_SAVE_PATH" in php.ini AND make sure the folder you specify exists
and is accessible to PHP.

HTH,

Richy

==
Richard Black
Senior Developer, DataVisibility Ltd - http://www.datavisibility.com
Tel: 0141 951 3481
Email: [EMAIL PROTECTED]


   

"khac duy" 



netnam.vn>   cc:   

 Subject: [PHP-DB] help me 

10/01/2003 

00:07  

   

   





  i can't use start_secsion(); in php4, it say:
 error : can't ofen(\tmp/4363jghsfjkhshga.. like this...




This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com





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




Re: [PHP-DB] help me

2003-01-09 Thread Martin Hudec
Hello khac,

hmm what platform are you running on? what are PHP settings for
writing sessions? Check out permissions for /tmp directory, check out
free space on disk.

-- 
Best regards,
 Martin  mail   [EMAIL PROTECTED]
 mobile +421.907.303.393
 icq34358414
 wwwhttp://www.corwin.sk

PGP key fingerprint  21365ca05ecfd8aeb1cf19c838fff033

"In those days spirits were brave, the stakes were high, 
 men were real men, women were real women and small furry 
 creatures from Alpha Centauri were real small furry creatures 
 from Alpha Centauri."

by Douglas Adams

Friday, January 10, 2003, 1:07:54 AM, you wrote:

kd>   i can't use start_secsion(); in php4, it say:
kd>  error : can't ofen(\tmp/4363jghsfjkhshga.. like this...


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




[PHP-DB] help me

2003-01-09 Thread khac duy
  i can't use start_secsion(); in php4, it say:
 error : can't ofen(\tmp/4363jghsfjkhshga.. like this...