[PHP-DB] update mysql table using php

2001-08-13 Thread Yahoo Email

The following is a portion of the code I have in my php script.

elseif ($submit==Update categories)
{
if (is_array($Cat_ID))
{
while (list($key,$value) = each($Cat_ID))
{
print liUpdated entry #$value\n;
$query = update $table2 set CatName = '$CatName', CatDescribe =
'$CatDescribe' where Cat_ID = $value;
mysql_query($query) or die(The submitted category could not be
added.);
print brbr;
print a href= . '' . display.php . '' . Return to the
Categories index./a;
}
}
}

I know there are no problems connecting to the database; I know it is able
to establish a connection.  Also, I know that CatName and CatDescribe are
valid Column Names in my table.

Any ideas as to what the problem is?

Thank you.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: NEXT - PREVIOUS coding

2001-08-13 Thread Tom

Hi,
what about other possibilities to do this ?

Tom

U¿ytkownik Manuel Lemos [EMAIL PROTECTED] napisa³ w wiadomo¶ci
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello Pranot,

 On 16-Jul-01 06:09:33, you wrote:


 hi.. friends

 i have a database (mysql) in which their r many records. Through PHP i
want
 them to display on the page.

 Main requirement is that there should be a NEXT - PREVIOUS facility. So
if
 there r 20 records and suppose only 10 should show up on scren at a time,
 then a NEXT link should be visible which could show the remaining 10
records.

 Their can be n no. of records.

 Maybe you would like to try this PHP class that does exactly what you are
 asking.

 http://phpclasses.UpperDesign.com/browse.html/package/130


 Regards,
 Manuel Lemos

 Web Programming Components using PHP Classes.
 Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
 --
 E-mail: [EMAIL PROTECTED]
 URL: http://www.mlemos.e-na.net/
 PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
 --




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Show abbreviated article

2001-08-13 Thread Cilfa

Hi,

On my website I want to display some articles, in Slashdot style. The
main page should only display the first 20 words of the article, and
users should be able to click on a link to view the entire article.
The articles are stored in a MySQL database, the body of the article in a
blob-field.

My question is this: how can I select only those first 20 words in the
PHP code?

I hope somebody can help me with this.

Cilfa


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Member authentication with PHP and MySQL

2001-08-13 Thread Cato Larsen

Hi!

I'm trying to authenticate members by using php and MySQL.

This is what I've come to so far:

?php

$auth = false; // Assume user is not authenticated

if (isset( $email )  isset($password)) {

// Connect to MySQL

mysql_connect( 'localhost', 'Xephiroth', 'lordoftherings' )
or die ( 'Unable to connect to server.' );

// Select database on MySQL server

mysql_select_db( 'members' )
or die ( 'Unable to select database.' );

// Formulate the query

$sql = SELECT * FROM memberinfo WHERE
email = '$email' AND
password = '$password';

// Execute the query and put results in $result

$result = mysql_query( $sql )
or die ( 'Unable to execute query.' );

// Get number of rows in $result.

$num = mysql_numrows( $result );

if ( $num != 0 ) {

// A matching row was found - the user is authenticated.

$auth = true;

}

}

if ( ! $auth ) {

header( 'WWW-Authenticate: Basic realm=Members only' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required to enter the member area';
exit;

} else {

echo '

-SITE CONTENT-


'; } ?


How do I make the authentication to go to site:
members.php?charnick=$charnick

Where $charnick is brung from the DB line who was authenticated?

So that Peter won't end up at John 's membersite?

Thanks for your time and expertese!

Best regards Cato



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: VERY strange erro

2001-08-13 Thread Steve Brett


Piotr Dubla [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 I have a script which accessed a database (MySQL) and reads and wrties
 things to it. The first time I run the script everything runs 100% but
 then if I re-run it it gives me

 Fatal error: Unsupported operand types in
 /usr/local/apache/htdocs/debit.php on line 51

 Now at line 51 there is a statement which says $day1 = $day1 - 1;

try $day1--;

Steve


 What is going on? Anybody have any ideas

 Piotr Dubla
 -= Networld =-





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: Portability concerns

2001-08-13 Thread Michael

Manuel Lemos wrote:
 
 Hello André,
 
 On 03-Aug-01 10:31:30, you wrote:
 
 But what other issues are there? Should there not be a part of the PHP
 documentation dedicated to describing all the things you should worry about
 if you want to write portable code? Shouldn't there be a portability
 standard for PHP, or is there allready one? I'm sure there must be other
 things to consider than the three features/settings I have mentioned, and
 getting a good overview/reference for these would be a boon to everyone
 trying to write portable code.
 
 This also cover coding practices, like using relative paths and urls rather
 than static ones, maybe even using abstraction layers on top of the DB (if
 using one).
 
 A lot of people uses database abstraction layers, but many of the existing
 database abstraction packages are not really concerned with application
 portability but rather just using the same set of API functions:  for
 instance PEAR-DB almost just tries to be a look a like Perl DBI but none of
 these really do much to help you to develop database independent
 applications.
 

This is not necessarily a bad thing

 Of all I know, only ADODB and Metabase really try to abstract data types so
 you don't have to handle the different data type representation that vary
 between databases.  For instance, almost all SQL databases support date and
 time types, but you can't assure that all of them use the same date format.
 The packages above do that for you if not for all, at least for most data
 types.

'
 
 Metabase even goes further.  Besides the application runtime API, Metabase
 provides a database independent way to install and maintain database
 schemas:  tables, fields, indexes and sequences.
 
 It lets you describe your schemas in a database independent XML format. Then
 it creates the database structures for you without the need for the user to
 do any SQL programming.  Besides that, if you change you database schema
 description, Metabase is able to alter your schema without disturbing any
 data added to the database after you have installed.
 

I think you can over do abstraction - in my opinion if you are going to
use a different database learn about that database properly and not rely
on a php class to do the work for you, learn the datatypes, the
differences in features (eg no LIMIT in Sybase, Interbase, Sapdb - and
others), different ways indexing work etc etc, the list of differences
is very long. 
Sure you can have an abstraction layer handle these differences but in
some cases your performance will take a big hit. (there is no good php
work around for LIMIT).
Just because you can use an abstraction layer to everything doesn't mean
you should. Reliance on it might give you portability but performance
and good design will suffer

I'd pick one of the lighter weight database classes that are only doing
the basic stuff and stick to that.
Rewriting queries for each database (if neccessary) and  writing stored
procuderes and triggers for them may take extra time - but at least I
know I will get maximum performance from my database.


 Anyway, at least regarding database application, there seems to be no
 agreement to what portability features should be present in an abstraction
 package or else we wouldn't many of such packages, unlike Java, Perl,
 Python, etc..
 

why is that such a bad thing ?
I

 It seems to be a waste of opportunities, but sometimes developers are more
 concerned with pleasing their egos and do their own abstraction package
 and be famous (or not) with it, rather than reaching to a consensus.
 

Maybe its because have developers have different needs from a class.
Just because yours is right for you and probably many others doesn't
mean it's the class to use. Im sure Metabase is very good but people
should look around because there is no one size fits all class.



 Regards,
 Manuel Lemos

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: Show abbreviated article

2001-08-13 Thread Johannes Janson

hi,

[...]
 My question is this: how can I select only those first 20 words in the
 PHP code?

SELECT LEFT(YourBlobFiekd, 20) FROM YourTable;

hope it helps
Johannes



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: update mysql table using php

2001-08-13 Thread Johannes Janson

Hi,

 Any ideas as to what the problem is?

What error do you get? Is the query not working?
Put a mysql_error() into your or die(The category...) to get
the exact error message. And try putting quotes around CAtID = '$value'.

  print a href= . '' . display.php . '' . Return to the
print a href=\display.php\Return to CatIndex/a;
looks much nicer, doesn't it

hope it helps
Johannes



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Submit forms

2001-08-13 Thread Ian Grant

Yes, thank you, this works!

Ian.

Paul Burney [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 on 8/10/01 7:50 AM, Ian Grant at [EMAIL PROTECTED] wrote:

  I've got a simply search form, on my site using PHP and MySQL.
  It writes a SELECT query  using WHERE (Field LIKE '%thingy%') where
thingy
  is the word entered in the form. It works fine if the submit button is
  pressed, but if you press return after typing the word, instead, it
fails
  and writes nothing for the query, so it ends up like WHERE ()

 Browsers differ on how they interpret the hitting of the return key and
 which fields get submitted.  I'd guess you have an input type='submit'
 name='submit' value='yes' type field and you are checking isset($submit).
 Some browsers (Netscape on the Mac, for example) won't submit the
name-value
 pair associated with the button.

 One solution is to do this instead:

 input type=hidden name=submit value=yes
 input type=submit value=Search!

 No matter how the form is submitted, the submit variable will be set to
yes.

 Sincerely,

 Paul Burney

 ++
 Paul Burney
 Webmaster  Open Source Developer
 UCLA - GSEIS - ETU
 (310) 825-8365
 [EMAIL PROTECTED]
 http://www.gseis.ucla.edu/
 ++





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Re: Show abbreviated article

2001-08-13 Thread Jon Farmer

NO! This will return the first 20 characters from the field not the first 20
words. To do that you need to use a regexp in the SQL or explode the result
in php and use the first 20 elements of the array!

Regards


Jon Farmer
Systems Programmer
Entanet International Ltd www.enta.net
Tel 01952 428969
Mob 07968 524175

-Original Message-
From: Johannes Janson [mailto:[EMAIL PROTECTED]]
Sent: 13 August 2001 12:15
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Re: Show abbreviated article


hi,

[...]
 My question is this: how can I select only those first 20 words in the
 PHP code?

SELECT LEFT(YourBlobFiekd, 20) FROM YourTable;

hope it helps
Johannes



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Member authentication with PHP and MySQL

2001-08-13 Thread BoNzO

i use this script with apache/php/mysql



?

mysql_connect($server, $user, $pass);
mysql_select_db($database);

$auth = false;
if (isset($PHP_AUTH_USER)  isset($PHP_AUTH_PW)) {
$sql = SELECT Password FROM users WHERE UserID = '$PHP_AUTH_USER';
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$password = $row[Password];
}
$salt = substr( $password , 0 , 2 );
$enc_pw = crypt( $PHP_AUTH_PW, $salt );

if ($password == $enc_pw) {
$auth = true;
}
}

if (!$auth) {
header( 'WWW-Authenticate: Basic realm=Login to phpHelpDesk' );
header( 'HTTP/1.0 401 Unauthorized' );
print 'Authorization Required.';
exit;
}
?


then you can always reach the userid with $PHP_AUTH_USER

/Mattias Aka BoNzO
http://bonzo.sineleven.nu

-- Original Message --
From: Cato Larsen [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Send: 01:47 AM
Subject: [PHP-DB] Member authentication with PHP and MySQL

Hi!

I'm trying to authenticate members by using php and MySQL.

This is what I've come to so far:

?php

$auth = false; // Assume user is not authenticated

if (isset( $email )  isset($password)) {

// Connect to MySQL

mysql_connect( 'localhost', 'Xephiroth', 'lordoftherings' )
or die ( 'Unable to connect to server.' );

// Select database on MySQL server

mysql_select_db( 'members' )
or die ( 'Unable to select database.' );

// Formulate the query

$sql = SELECT * FROM memberinfo WHERE
email = '$email' AND
password = '$password';

// Execute the query and put results in $result

$result = mysql_query( $sql )
or die ( 'Unable to execute query.' );

// Get number of rows in $result.

$num = mysql_numrows( $result );

if ( $num != 0 ) {

// A matching row was found - the user is authenticated.

$auth = true;

}

}

if ( ! $auth ) {

header( 'WWW-Authenticate: Basic realm=Members only' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required to enter the member area';
exit;

} else {

echo '

-SITE CONTENT-


'; } ?


How do I make the authentication to go to site:
members.php?charnick=$charnick

Where $charnick is brung from the DB line who was authenticated?

So that Peter won't end up at John 's membersite?

Thanks for your time and expertese!

Best regards Cato



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]








-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Interbase lob field on the web

2001-08-13 Thread alex.tesi

Hi i have a problem printing a lob field containing an image.
The database i use is Interbase 6.0
I have a blob/lob field with a gif image inside an i like to print this image on the 
web.
Can you help me?

Bye Alessandro



Re: [PHP-DB] Member authentication with PHP and MySQL

2001-08-13 Thread Sheridan Saint-Michel

I would use either cookies or sessions for this.  
First Check for the cookie, and verify its contents.
If there isn't a cookie then do the login prompt like you
are doing now.

Here's some pseudocode to give you a quick idea of what I mean

if (isset($cookie)
{
  if (CheckCookie())
  {
SiteContent();
  }  else {
Kill Cookie
GiveLoginPrompt();
  }
} elseif (isset($login) {
  if (CheckLogin())
SetCookie();
} else {
  GiveLoginPrompt
}

On all the other pages on the site you just have a header check the
cookie and redirect to the login page if it doesn't check out
ie:

if (!isset($cookie))
{
  header(Location: http://www.yourdomain.com/login.php;);
  exit;
}

if (!CheckCookie())
{
  header(Location: http://www.yourdomain.com/login.php;);
  exit;
}

If you want to use sessions just replace cookie with session  =P

Here is an example script I wrote a while back if you want to
see more than metacode
http://www.zend.com/codex.php?id=393single=1

And here is the header for other files on the site using the above script
http://www.zend.com/codex.php?id=397single=1

Let me know if this helps

Sheridan Saint-Michel
Website Administrator
FoxJet, an ITW Company
www.foxjet.com


- Original Message - 
From: Cato Larsen [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, August 12, 2001 6:47 PM
Subject: [PHP-DB] Member authentication with PHP and MySQL


 Hi!
 
 I'm trying to authenticate members by using php and MySQL.
 
 This is what I've come to so far:
 
 ?php
 
 $auth = false; // Assume user is not authenticated
 
 if (isset( $email )  isset($password)) {
 
 // Connect to MySQL
 
 mysql_connect( 'localhost', 'Xephiroth', 'lordoftherings' )
 or die ( 'Unable to connect to server.' );
 
 // Select database on MySQL server
 
 mysql_select_db( 'members' )
 or die ( 'Unable to select database.' );
 
 // Formulate the query
 
 $sql = SELECT * FROM memberinfo WHERE
 email = '$email' AND
 password = '$password';
 
 // Execute the query and put results in $result
 
 $result = mysql_query( $sql )
 or die ( 'Unable to execute query.' );
 
 // Get number of rows in $result.
 
 $num = mysql_numrows( $result );
 
 if ( $num != 0 ) {
 
 // A matching row was found - the user is authenticated.
 
 $auth = true;
 
 }
 
 }
 
 if ( ! $auth ) {
 
 header( 'WWW-Authenticate: Basic realm=Members only' );
 header( 'HTTP/1.0 401 Unauthorized' );
 echo 'Authorization Required to enter the member area';
 exit;
 
 } else {
 
 echo '
 
 -SITE CONTENT-
 
 
 '; } ?
 
 
 How do I make the authentication to go to site:
 members.php?charnick=$charnick
 
 Where $charnick is brung from the DB line who was authenticated?
 
 So that Peter won't end up at John 's membersite?
 
 Thanks for your time and expertese!
 
 Best regards Cato
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Member authentication with PHP and MySQL

2001-08-13 Thread Cato Larsen

Thanks a mill Sheridan!
This was accually what I was looking for, but gave up since the other
tutorials and script examples where too complicated for me to grasp.

One question to the code on the site:

Is it possible to insert info to be grabbed on other sites?
Like
email
password
name

So you can grab like name, instead of having to querity the DB all the time
you need the name of the person and so on?
And if yes, how do you get it from the cookie and insert it into the page
like $name ?

Best regards

Cato Larsen



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Re: Show abbreviated article

2001-08-13 Thread Hugh Bothwell

Jon Farmer [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 From: Johannes Janson [mailto:[EMAIL PROTECTED]]
 Sent: 13 August 2001 12:15
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Re: Show abbreviated article

  My question is this: how can I select only those first 20 words in the
  PHP code?

 SELECT LEFT(YourBlobFiekd, 20) FROM YourTable;

 NO! This will return the first 20 characters from the field not the first
20
 words. To do that you need to use a regexp in the SQL or explode the
result
 in php and use the first 20 elements of the array!

... you could significantly lower bandwidth requirements by returning,
say, the first 150 characters and then explode'ing to make it 20 words.

Another thought: if you want a string of close-to-standard length,
maybe just return 100 chars and truncate to the last word boundary
using strrchr(), instead of requiring a fixed number of words?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Group By problem

2001-08-13 Thread Sharif Islam

I am trying to caregorize to group at the same time, but its not working.
Any hints?
Here's my code:
$temp=Dummy;
while ($row = mysql_fetch_array($result))
{
 if($temp !=$row[group_name]){
 $temp=$row[group_name] ;
 echo bGroup:$tempbr/b;

}

$temp1=blah;
if($temp1 !=$row[service_cat]){
$temp1=$row[service_cat];
echo Services:$temp1br;
}
$machine_name=$row[machine_name];
echo a
href=view_server.php?machine_name=$machine_name$machine_name/abr;
}

This is displaying :
Group:Group_Name
Services:Email
Machine_Name
Services:Email
Machine_name2
Services: Backup
Machine_name
Group:Group_name2

I dont want to print services multiple times. Just like the group name
catagorize it.

Thanks




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: Interbase lob field on the web

2001-08-13 Thread Hugh Bothwell


Alex.Tesi [EMAIL PROTECTED] wrote in message
003901c123fa$1ff2da50$[EMAIL PROTECTED]">news:003901c123fa$1ff2da50$[EMAIL PROTECTED]...
Hi i have a problem printing a lob field containing an image.
The database i use is Interbase 6.0
I have a blob/lob field with a gif image inside an i like to print this
image on the web.
Can you help me?

You need a script to return the image, and you need to
pass the proper parameter from the calling page...

=== image.php ==
?php

// check that param exists
if (!isset($img)) {
// alternatively, you could set img to
// point to an 'error, not found' image
// from your database...
die(Error: 'img' parameter not set);
}

// hacker prevention...
$img = (int) $img;

// connect to the database
$conn = ibase_pconnect(host:dbase, usr, pwd)
or die(Error: .ibase_errmsg());

// query for image
$query = SELECT img_contents 
.FROM imgtable WHERE id=$img;
$res = ibase_query($conn, $query);

// make sure that exactly one result was returned
$num_returned = ibase_num_fields($res);
if ($num_returned == 0)
die(Error: specified image $img not found);
if ($num_returned  1)
die(Error: $num_returned images found for $img);

// return image
// if you kept an image-type field in your
// database, you could store and retrieve
// various image types - gif, jpeg, bmp, png,
// swf, svg, etc...
header(Content-Type: image/gif);
$row = ibase_fetch_object($res);
echo $row-img_contents;

?
=


=== mypage.html ===
html
head
titleExample.../title
/head
body
pHere is image # 394302.../p
img src='image.php?img=394302' align='center'
/body
/html
===



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] SELECTS from multiple tables

2001-08-13 Thread Tom Hodder




Hi,


If I do a select from multiple tables like so

SELECT * FROM,
candidates,
clients,
jobs
WHERE
candidates.ID = clients.candidate_ID
etc etc

i then do

$row = mysql_fetch_array( $results )
or die(mysql_error() );

is there any way to explicitly reference table columns ie [candidates.ID] in
the result set like you can in ASP. As due to poor table column naming,
there are numerous column name duplications across the tables and it would
take ages to add the

SELECT candidates.ID as canID, client_ID as cliID

to the queries.

Regards

Tom Hodder






-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Member authentication with PHP and MySQL

2001-08-13 Thread Cato Larsen

One more thing...

When I've set up the script and run it on my local server I get this error:

Sheridan Saint-Michel [EMAIL PROTECTED] wrote in message
00df01c12400$ad2a1220$[EMAIL PROTECTED]">news:00df01c12400$ad2a1220$[EMAIL PROTECTED]...
 I would use either cookies or sessions for this.
 First Check for the cookie, and verify its contents.
 If there isn't a cookie then do the login prompt like you
 are doing now.

 Here's some pseudocode to give you a quick idea of what I mean

 if (isset($cookie)
 {
   if (CheckCookie())
   {
 SiteContent();
   }  else {
 Kill Cookie
 GiveLoginPrompt();
   }
 } elseif (isset($login) {
   if (CheckLogin())
 SetCookie();
 } else {
   GiveLoginPrompt
 }

 On all the other pages on the site you just have a header check the
 cookie and redirect to the login page if it doesn't check out
 ie:

 if (!isset($cookie))
 {
   header(Location: http://www.yourdomain.com/login.php;);
   exit;
 }

 if (!CheckCookie())
 {
   header(Location: http://www.yourdomain.com/login.php;);
   exit;
 }

 If you want to use sessions just replace cookie with session  =P

 Here is an example script I wrote a while back if you want to
 see more than metacode
 http://www.zend.com/codex.php?id=393single=1

 And here is the header for other files on the site using the above script
 http://www.zend.com/codex.php?id=397single=1

 Let me know if this helps

 Sheridan Saint-Michel
 Website Administrator
 FoxJet, an ITW Company
 www.foxjet.com


 - Original Message -
 From: Cato Larsen [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Sunday, August 12, 2001 6:47 PM
 Subject: [PHP-DB] Member authentication with PHP and MySQL


  Hi!
 
  I'm trying to authenticate members by using php and MySQL.
 
  This is what I've come to so far:
 
  ?php
 
  $auth = false; // Assume user is not authenticated
 
  if (isset( $email )  isset($password)) {
 
  // Connect to MySQL
 
  mysql_connect( 'localhost', 'Xephiroth', 'lordoftherings' )
  or die ( 'Unable to connect to server.' );
 
  // Select database on MySQL server
 
  mysql_select_db( 'members' )
  or die ( 'Unable to select database.' );
 
  // Formulate the query
 
  $sql = SELECT * FROM memberinfo WHERE
  email = '$email' AND
  password = '$password';
 
  // Execute the query and put results in $result
 
  $result = mysql_query( $sql )
  or die ( 'Unable to execute query.' );
 
  // Get number of rows in $result.
 
  $num = mysql_numrows( $result );
 
  if ( $num != 0 ) {
 
  // A matching row was found - the user is authenticated.
 
  $auth = true;
 
  }
 
  }
 
  if ( ! $auth ) {
 
  header( 'WWW-Authenticate: Basic realm=Members only' );
  header( 'HTTP/1.0 401 Unauthorized' );
  echo 'Authorization Required to enter the member area';
  exit;
 
  } else {
 
  echo '
 
  -SITE CONTENT-
 
 
  '; } ?
 
 
  How do I make the authentication to go to site:
  members.php?charnick=$charnick
 
  Where $charnick is brung from the DB line who was authenticated?
 
  So that Peter won't end up at John 's membersite?
 
  Thanks for your time and expertese!
 
  Best regards Cato
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: Group By problem

2001-08-13 Thread Hugh Bothwell


Sharif Islam [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I am trying to caregorize to group at the same time, but its not working.
 Any hints?
 Here's my code:
 $temp=Dummy;
 while ($row = mysql_fetch_array($result))
 {
  if($temp !=$row[group_name]){
  $temp=$row[group_name] ;
  echo bGroup:$tempbr/b;

 }

 $temp1=blah;
 if($temp1 !=$row[service_cat]){
 $temp1=$row[service_cat];
 echo Services:$temp1br;
 }
 $machine_name=$row[machine_name];
 echo a
 href=view_server.php?machine_name=$machine_name$machine_name/abr;
 }

 This is displaying :
 Group:Group_Name
 Services:Email
 Machine_Name
 Services:Email
 Machine_name2
 Services: Backup
 Machine_name
 Group:Group_name2
 ...
 I dont want to print services multiple times. Just like the group name
 catagorize it.

You don't show your SQL, but I assume it's something like
SELECT grp,svc,mach FROM table ORDER BY grp,svc,mach

then
$grp=;
$svc=;
$firstmach = true;
while ($row=mysql_fetch_array($result)) {
if ($grp != $row[grp]) {
$grp = $row[grp];
PrintNewGroup($grp);
$svc = ;// force new-svc when switching groups
}

if($svc != $row[svc]) {
$svc = $row[svc];
PrintNewService($svc);
$firstmach = true;
}

PrintMach($row[mach], $firstmach);
$firstmach = false;
}

Hope this helps...



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Member authentication with PHP and MySQL

2001-08-13 Thread Cato Larsen

Arg...

I get this error:


Unable to update database. Please contact [EMAIL PROTECTED]



Am I missing something in my DB?

Fields in DB:

id, email, password, name, loc, aim, icq, msn, yahoo, charname ,charsname,
charnick, tit, lvl, picurl, born, appearance, charac, streng, bio, breed,
prof, posn.



This is the current source:



?php

//Put in your own info for username, password, DB, email@address,
Cookiename,
//the name of this page (currently login.php) and the name of your subscribe
//or new user page (currently new.php).  I went ahead and included all the
HTML
//so this page should work as is, with only the changes described above
needed
// - Lysander ([EMAIL PROTECTED])

$dblink = mysql_pconnect(localhost,Xephiroth,lordoftherings);
mysql_select_db(members);

$headers=0; //Make Sure HTML Headers are in place before the form


//after Authenticating the script automatically sends the browser to
//the webpage of your choice (note if your page calls this
//script with ?redirect=foobar.php it will automatically
//redirect to foobar.php after authenticating.  Set the default
//redirect page here

if ( !isset($redirect))
   {
 $redirect = default.php;
   }

if (isset($email)  isset($password)) {

  $query = select * from memberinfo where email = \$email\ and password =
\$password\;

  if ( !($dbq = mysql_query($query, $dblink))) {
echo Unable to query database.  Please Contact a
href=\mailto:[EMAIL PROTECTED]\;[EMAIL PROTECTED]/a.\n;
exit;
  }

  $lim = mysql_num_rows( $dbq );

  if ($lim != 1) {

  $headers=1; //HTML headers in place
echo html;
echo head;
echo titleMember logon/title;
echo meta http-equiv=\Content-Type\ content=\text/html;
charset=iso-8859-1\;
echo /head;
echo body bgcolor=\#00\ text=\#FF\ leftmargin=\0\
topmargin=\0\ marginwidth=\0\ marginheight=\0\
background=\../images/back.gif\  bgproperties=\fixed\ link=\#CC\
vlink=\#CC\ alink=\#CC\;
echo BInvalid E-Mail adress and/or Password. Please Try again/BBR;

  }

  if ($lim == 1) {

//make unique session id and store it in Database
  $timer = md5(time());
  $sid = $email . + . $timer;
  SetCookie(ElectrocutedClanRemains,$sid,time()+2592000); //Set Cookie for
30 days
  $query = update members set sid=\$timer\ where email=\$email\;

  if( !($dbq = mysql_query( $query, $dblink))) {
echo Unable to update database.  Please contact a
href=\[EMAIL PROTECTED]\[EMAIL PROTECTED]/a.\n;
  exit;
  }

  $headers=1;
  header(Location: $redirect);
  exit;
  }

}

if (isset($ElectrocutedClanRemains)) {
  $headers=1; //make sure HTML headers are in place before the form
  $sidarray = explode(+, $ElectrocutedClanRemains);
  $query = select * from memberinfo where email = \$sidarray[0]\ and sid
= \$sidarray[1]\;

  if ( !($dbq = mysql_query($query, $dblink))) {
echo Unable to find database.  Please Contact a
href=\mailto:[EMAIL PROTECTED]\;[EMAIL PROTECTED]/a.\n;
exit;
  }

  if (mysql_num_rows( $dbq ) == 1) {
echo html;
echo head;
echo titleMember logon/title;
echo meta http-equiv=\Content-Type\ content=\text/html;
charset=iso-8859-1\;
echo /head;
echo body bgcolor=\#00\ text=\#FF\ leftmargin=\0\
topmargin=\0\ marginwidth=\0\ marginheight=\0\
background=\../images/back.gif\  bgproperties=\fixed\ link=\#CC\
vlink=\#CC\ alink=\#CC\;
echo You are already logged in as $sidarray[0].BR;
echo You may logon as another user or simply begin using our services with
your current session.BR;
  }
}

if ($headers == 0) {
echo html;
echo head;
echo titleMember logon/title;
echo meta http-equiv=\Content-Type\ content=\text/html;
charset=iso-8859-1\;
echo /head;
echo body bgcolor=\#00\ text=\#FF\ leftmargin=\0\
topmargin=\0\ marginwidth=\0\ marginheight=\0\
background=\../images/back.gif\  bgproperties=\fixed\ link=\#CC\
vlink=\#CC\ alink=\#CC\;
}

echo table width=\846\ border=\0\ cellspacing=\0\
cellpadding=\0\;
echo tr;
echo td width=\80\ height=\30\nbsp;/td;
echo td height=\30\nbsp;/td;
echo /tr;
echo tr;
echo td width=\80\nbsp;/td;
echo td;
echo table width=\766\ border=\0\ cellpadding=\0\
cellspacing=\0\;
echo tr;
echo td colspan=\3\;
echo div align=\center\;
echo table width=\766\ border=\0\ cellspacing=\0\ cellpadding=\0\
background=\../images/middletop.gif\;
echo tr ;
echo td width=\8\img src=\../images/left.gif\ width=\8\
height=\29\/td;
echo td background=\../images/middletop.gif\ align=\left\
valign=\middle\font color=\#33\bfont size=\4\Member Logon
/font/b/fontfont size=\4\ face=\Times New Roman, Times, serif\
color=\#33\;
echo b /b/font/td;
echo td width=\9\;
echo div align=\right\img src=\../images/right.gif\ width=\8\
height=\29\/div;
echo /td;
echo /tr;
echo /table;
echo /div;
echo /td;
echo /tr;
echo tr;
echo td width=\3\ background=\../images/framev.gif\img
src=\../images/framev.gif\ width=\3\ height=\100%\/td;
echo td bgcolor=\#33\ width=\760\ align=\center\
valign=\middle\;
echo form name=\auth\ method=\post\ action=\vault.php\;
echo table width=\100%\ 

Re: [PHP-DB] Member authentication with PHP and MySQL

2001-08-13 Thread Hugh Bothwell

Cato Larsen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 Sheridan Saint-Michel [EMAIL PROTECTED] wrote in message
 00df01c12400$ad2a1220$[EMAIL PROTECTED]">news:00df01c12400$ad2a1220$[EMAIL PROTECTED]...

  From: Cato Larsen [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Sunday, August 12, 2001 6:47 PM
  Subject: [PHP-DB] Member authentication with PHP and MySQL
  
   I'm trying to authenticate members by using php and MySQL.
   How do I make the authentication to go to site:
   members.php?charnick=$charnick
   Where $charnick is brung from the DB line who was authenticated?
 
  I would use either cookies or sessions for this.
  First Check for the cookie, and verify its contents.
  If there isn't a cookie then do the login prompt like you
  are doing now.

 One more thing...

 When I've set up the script and run it on my local server I get this
error:

1. what error?

2. replying at the top of a message is poor form.
I know Outlook Express wants to do this; it's just
one more reason to hate the Evil Empire.

3. please trim the replied-to stuff to keep only attributions
 and relevant content.  I don't like having to read
5k of old text just to make sure you haven't added
anything to it...



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Member authentication with PHP and MySQL

2001-08-13 Thread Sheridan Saint-Michel

If you note the part of the script where the cookie is set

//make unique session id and store it in Database
  $timer = md5(time());
  $sid = $UserID . + . $timer;
  SetCookie(Cookiename,$sid,time()+2592000); file://Set Cookie for 30 days
  $query = update members set sid=\$timer\ where UserID=\$UserID\;

I set the cookie with the user id and a Session ID I create... then when it
checks
the cookie it just does

  $sidarray = explode(+, $Cookiename);
  $query = select * from members where UserID = \$sidarray[0]\ and sid =
\$sidarray[1]\;

So using this script you could put whatever else you wanted in the cookie.
You would just change
  $sid = $UserID . + . $timer;
to
  $sid = $UserID . + . $timer . + . $email;

for example.  Then when you do
  $sidarray = explode(+, $Cookiename);

You would have
$sidarray[0] = $UserID
$sidarray[1] = $timer
$sidarray[2] = $email

You could continue adding additional variables (or plain strings for that
matter) in this manner.
The only thing to keep in mind is that cookies have a 4K file size
limitation and anything beyond
4K will be lost.  Check under additional notes on this page for details on
cookie limitations

http://www.netscape.com/newsref/std/cookie_spec.html

I hope all that is clear.  Let me know if you have any more questions

Sheridan Saint-Michel
Website Administrator
FoxJet, an ITW Company
www.foxjet.com


- Original Message -
From: Cato Larsen [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 13, 2001 9:06 AM
Subject: Re: [PHP-DB] Member authentication with PHP and MySQL


 Thanks a mill Sheridan!
 This was accually what I was looking for, but gave up since the other
 tutorials and script examples where too complicated for me to grasp.

 One question to the code on the site:

 Is it possible to insert info to be grabbed on other sites?
 Like
 email
 password
 name

 So you can grab like name, instead of having to querity the DB all the
time
 you need the name of the person and so on?
 And if yes, how do you get it from the cookie and insert it into the page
 like $name ?

 Best regards

 Cato Larsen



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Member authentication with PHP and MySQL

2001-08-13 Thread Sheridan Saint-Michel

My Script uses a Session ID Variable when verifying the user
You don't have a field setup for this.  So either change the code
in this section

 $timer = md5(time());
 $sid = $email . + . $timer;
 SetCookie(ElectrocutedClanRemains,$sid,time()+2592000);
 $query = update members set sid=\$timer\ where email=\$email\;

or Add to your DB
sid char(32)

(md5 always returns a 32 character long string)

Sheridan Saint-Michel
Website Administrator
FoxJet, an ITW Company
www.foxjet.com


- Original Message -
From: Cato Larsen [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 13, 2001 10:10 AM
Subject: Re: [PHP-DB] Member authentication with PHP and MySQL


 Arg...

 I get this error:


 Unable to update database. Please contact [EMAIL PROTECTED]



 Am I missing something in my DB?

 Fields in DB:

 id, email, password, name, loc, aim, icq, msn, yahoo, charname ,charsname,
 charnick, tit, lvl, picurl, born, appearance, charac, streng, bio, breed,
 prof, posn.



 This is the current source:



 ?php

 file://Put in your own info for username, password, DB, email@address,
 Cookiename,
 file://the name of this page (currently login.php) and the name of your
subscribe
 file://or new user page (currently new.php).  I went ahead and included
all the
 HTML
 file://so this page should work as is, with only the changes described
above
 needed
 // - Lysander ([EMAIL PROTECTED])

 $dblink = mysql_pconnect(localhost,Xephiroth,lordoftherings);
 mysql_select_db(members);

 $headers=0; file://Make Sure HTML Headers are in place before the form


 file://after Authenticating the script automatically sends the browser to
 file://the webpage of your choice (note if your page calls this
 file://script with ?redirect=foobar.php it will automatically
 file://redirect to foobar.php after authenticating.  Set the default
 file://redirect page here

 if ( !isset($redirect))
{
  $redirect = default.php;
}

 if (isset($email)  isset($password)) {

   $query = select * from memberinfo where email = \$email\ and password
=
 \$password\;

   if ( !($dbq = mysql_query($query, $dblink))) {
 echo Unable to query database.  Please Contact a
 href=\mailto:[EMAIL PROTECTED]\;[EMAIL PROTECTED]/a.\n;
 exit;
   }

   $lim = mysql_num_rows( $dbq );

   if ($lim != 1) {

   $headers=1; file://HTML headers in place
 echo html;
 echo head;
 echo titleMember logon/title;
 echo meta http-equiv=\Content-Type\ content=\text/html;
 charset=iso-8859-1\;
 echo /head;
 echo body bgcolor=\#00\ text=\#FF\ leftmargin=\0\
 topmargin=\0\ marginwidth=\0\ marginheight=\0\
 background=\../images/back.gif\  bgproperties=\fixed\ link=\#CC\
 vlink=\#CC\ alink=\#CC\;
 echo BInvalid E-Mail adress and/or Password. Please Try again/BBR;

   }

   if ($lim == 1) {

 file://make unique session id and store it in Database
   $timer = md5(time());
   $sid = $email . + . $timer;
   SetCookie(ElectrocutedClanRemains,$sid,time()+2592000); file://Set
Cookie for
 30 days
   $query = update members set sid=\$timer\ where email=\$email\;

   if( !($dbq = mysql_query( $query, $dblink))) {
 echo Unable to update database.  Please contact a
 href=\[EMAIL PROTECTED]\[EMAIL PROTECTED]/a.\n;
   exit;
   }

   $headers=1;
   header(Location: $redirect);
   exit;
   }

 }

 if (isset($ElectrocutedClanRemains)) {
   $headers=1; file://make sure HTML headers are in place before the form
   $sidarray = explode(+, $ElectrocutedClanRemains);
   $query = select * from memberinfo where email = \$sidarray[0]\ and
sid
 = \$sidarray[1]\;

   if ( !($dbq = mysql_query($query, $dblink))) {
 echo Unable to find database.  Please Contact a
 href=\mailto:[EMAIL PROTECTED]\;[EMAIL PROTECTED]/a.\n;
 exit;
   }

   if (mysql_num_rows( $dbq ) == 1) {
 echo html;
 echo head;
 echo titleMember logon/title;
 echo meta http-equiv=\Content-Type\ content=\text/html;
 charset=iso-8859-1\;
 echo /head;
 echo body bgcolor=\#00\ text=\#FF\ leftmargin=\0\
 topmargin=\0\ marginwidth=\0\ marginheight=\0\
 background=\../images/back.gif\  bgproperties=\fixed\ link=\#CC\
 vlink=\#CC\ alink=\#CC\;
 echo You are already logged in as $sidarray[0].BR;
 echo You may logon as another user or simply begin using our services
with
 your current session.BR;
   }
 }

 if ($headers == 0) {
 echo html;
 echo head;
 echo titleMember logon/title;
 echo meta http-equiv=\Content-Type\ content=\text/html;
 charset=iso-8859-1\;
 echo /head;
 echo body bgcolor=\#00\ text=\#FF\ leftmargin=\0\
 topmargin=\0\ marginwidth=\0\ marginheight=\0\
 background=\../images/back.gif\  bgproperties=\fixed\ link=\#CC\
 vlink=\#CC\ alink=\#CC\;
 }

 echo table width=\846\ border=\0\ cellspacing=\0\
 cellpadding=\0\;
 echo tr;
 echo td width=\80\ height=\30\nbsp;/td;
 echo td height=\30\nbsp;/td;
 echo /tr;
 echo tr;
 echo td width=\80\nbsp;/td;
 echo td;
 echo table width=\766\ border=\0\ cellpadding=\0\
 cellspacing=\0\;
 echo tr;
 echo td colspan=\3\;
 

Re: [PHP-DB] Re: Group By problem

2001-08-13 Thread Sharif Islam


Thanks for your reply

 You don't show your SQL, but I assume it's something like
 SELECT grp,svc,mach FROM table ORDER BY grp,svc,mach


Thats right.

But its displaying the same as my code:
---
Group:Desktop
Service:BACKUP
AITSBKUP
Service:E-Mail
AITSMAIL
Service:E-Mail
JEEVES
Group:Unix
Service:Database
APOLLO
Service:FIREWALL
Console
-

I want it like this. Sorry if my previous email wasnt clear enough.

Group:Desktop
Service:BACKUP
AITSBKUP
Service:E-Mail
AITSMAIL
JEEVES
Group:Unix
Service:Database
APOLLO
Service:FIREWALL
Console


 then
 $grp=;
 $svc=;
 $firstmach = true;
 while ($row=mysql_fetch_array($result)) {
 if ($grp != $row[grp]) {
 $grp = $row[grp];
 PrintNewGroup($grp);
 $svc = ;// force new-svc when switching groups
 }

 if($svc != $row[svc]) {
 $svc = $row[svc];
 PrintNewService($svc);
 $firstmach = true;
 }

 PrintMach($row[mach], $firstmach);
 $firstmach = false;
 }

 Hope this helps...



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Group By problem

2001-08-13 Thread Hugh Bothwell


- Original Message - 
From: Sharif Islam [EMAIL PROTECTED]
To: Hugh Bothwell [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, August 13, 2001 11:50 AM
Subject: Re: [PHP-DB] Re: Group By problem


 But its displaying the same as my code:

The SQL was just for reference, to make sure
we were both working on the same basis...

I don't think you looked at the PHP code I gave,
as it should produce exactly what you are asking for.


 Group:Desktop
 Service:BACKUP
 AITSBKUP
 Service:E-Mail
 AITSMAIL
 JEEVES
 Group:Unix
 Service:Database
 APOLLO
 Service:FIREWALL
 Console

try defining

style
body {
font-family: Verdana, Arial, sans-serif;
}
.group {
font-weight: bold;
font-size: 120%;
color: #44;
}
.service {
font-weight: bold;
color: #77;
}
.machine {
font-size: 80%;
color: #77;
}
/style

?php

function PrintNewGroup($grp) {
echo br\nspan class='group'$grp/span;
}

function PrintNewService($svc) {
echo br\n\tspan class='service'$nbsp;$svc/spanbr;
}

function PrintMach($mach, $first) {
if ($first)
echo nbsp;nbsp;
else
echo nbsp;|nbsp;;

echo span class='machine'$mach/span;
}
?

  $grp=;
  $svc=;
  $firstmach = true;
  while ($row=mysql_fetch_array($result)) {
  if ($grp != $row[grp]) {
  $grp = $row[grp];
  PrintNewGroup($grp);
  $svc = ;// force new-svc when switching groups
  }
 
  if($svc != $row[svc]) {
  $svc = $row[svc];
  PrintNewService($svc);
  $firstmach = true;
  }
 
  PrintMach($row[mach], $firstmach);
  $firstmach = false;
  }

How's that?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Another SQL Question

2001-08-13 Thread Barry Prentiss

Thx Alnisa,
 I had tried your suggested approach earlier.
 I just tried it again I got the following from SQL*Plus:

 Connected to:
Oracle8i Enterprise Edition Release 8.1.6.3.0 - Production
JServer Release 8.1.6.3.0 - Production

SQL select cat.id, cat.name, count(faq_cat.cat_id) as num_id
  2  from mdfaq_faq_cat faq_cat, mdfaq_category cat
  3  where faq_cat.cat_id = cat.id group by cat.name;
select cat.id, cat.name, count(faq_cat.cat_id) as num_id
   *
ERROR at line 1:
ORA-00979: not a GROUP BY expression

After removing the Group By:

SQL select cat.id, cat.name, count(faq_cat.cat_id) as num_id
  2  from mdfaq_faq_cat faq_cat, mdfaq_category cat
  3  where faq_cat.cat_id = cat.id;
select cat.id, cat.name, count(faq_cat.cat_id) as num_id
   *
ERROR at line 1:
ORA-00937: not a single-group group function

After removing the cat.* queries:

SQL select count(faq_cat.cat_id) as num_id
  2  from mdfaq_faq_cat faq_cat, mdfaq_category cat
  3  where faq_cat.cat_id = cat.id;

NUM_ID
--
 1

Replacing count() with the cat.* queries:

SQL select cat.id, cat.name
  2  from mdfaq_faq_cat faq_cat, mdfaq_category cat
  3  where faq_cat.cat_id = cat.id;

ID NAME
-- 
 4 MicroStation

Simple select from category:

SQL select * from mdfaq_category;

ID NAME
-- 
 1 Applications
 2 Solid Edge
 4 MicroStation

 It seems like this is a common type of query:
 Select a, b, count(c.e) as d where c.e = a.e;
 Any other suggestions?
 Thx in advance,
 Barry


Alnisa Allgood [EMAIL PROTECTED] wrote in message
news:p05100300b79a3aa685c8@[63.202.15.82]...
 At 4:07 PM -0700 8/10/01, Barry Prentiss wrote:
 Hi,
   I am writing a FAQ machine in PHP using Oracle 8.1.6.
   I can't figure out what's not working in my SQL query.
   I've spent two days on the Oracle site, to no avail.
   I have three tables:
   FAQ[ID,QUESTION,ANSWER]
   FAQ_CAT[FAQ_ID,CAT_ID]
   CAT[ID,NAME] (category)
 
   I'm trying to list CAT.ID, CAT.NAME and count(*) where count(*) is the
 count of all FAQs in each category.
   My latest attempt looks something like this:
   select c.id, c.name, a.num from cat c,(select count(*) num from faq_cat
f
 where f.cat_id = c.id) a;
   I keep getting an 'invalid column name' at the last 'c.id'...
 

 Well first off, I should mentioned that I'm not familiar with the
 specifics of how Oracle implements SQL, that said...

 I noticed a few items,One: you don't define the returned Count(*),
 which means it can't be used by PHP.  Second: you've created a
 subquery where one isn't needed.

 I use php and mySQL, but if I were creating the query, I'd basically
 want the statement to read like so:

Select category id, category name, and the count of the
number
or category articles from the tables category and FAQ
Category.
Limited the results to where category in FAQ equal Category
ID
in Category. Display by category name.

 I would phrase it something like so:

 SELECT cat.id, cat.name, COUNT(faq_cat.cat_id) AS num_id FROM
 faq_cat, cat WHERE faq_cat.id = cat.id GROUP BY cat.name

 I'm not certain if this will work exactly as is in Oracle, but it
 should get you closer.

 Alnisa
 --
.
 Alnisa  Allgood
 Executive Director
 Nonprofit Tech
 (ph) 415.337.7412  (fx) 415.337.7927
 (url)  http://www.nonprofit-techworld.org
 (url)  http://www.nonprofit-tech.org
 (url)  http://www.tech-library.org
.
 Nonprofit Tech E-Update
 mailto:[EMAIL PROTECTED]
.
 applying technology to transform
.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Another SQL Question

2001-08-13 Thread Alnisa Allgood

At 9:29 AM -0700 8/13/01, Barry Prentiss wrote:
Thx Alnisa,
  I had tried your suggested approach earlier.
  I just tried it again I got the following from SQL*Plus:

Wow, Oracle, what a pain. (Actually, it's probably pure laziness that 
MySQL doesn't check for this, but anyway). Anyway, I looked up the 
Oracle errors ORA-00937, and ORA-00979, and they basically both 
indicate that you can't return a column that isn't included in the 
Group BY expression.

You can't just remove the GROUP BY, because the COUNT requires a 
GROUP statement. Error 979 basically says line 1, includes a 
non-grouped expression.  Error 937 is the not-a single-group group 
error, or says basically the same thing. You can look up Oracle 
errors at: 
http://otn.oracle.co.kr/docs/oracle78/server.804/a58312/newch220.htm

SQL select cat.id, cat.name, count(faq_cat.cat_id) as num_id
   2  from mdfaq_faq_cat faq_cat, mdfaq_category cat
   3  where faq_cat.cat_id = cat.id group by cat.name;
select cat.id, cat.name, count(faq_cat.cat_id) as num_id
*
ERROR at line 1:
ORA-00979: not a GROUP BY expression

Applying the above error codes, which indicate that any column 
returned, must be part of the GROUP function, then the code should 
look something like:

SELECT cat.id, cat.name, COUNT(faq_cat.cat_id) AS num_id FROM 
faq_cat, cat WHERE faq_cat.id = cat.id GROUP BY cat.name, cat.id

or in Oracle speak (as close as I can gather anyway)

SQLSELECT cat.id, cat.name, COUNT(faq_cat.cat_id) AS num_id
2   FROM mdfaq_faq_cat faq_cat, mdfaq_category cat
3   WHERE faq_cat.id = cat.id GROUP BY cat.name, cat.id

This just adds the cat.id to the GROUP BY statement. I'm not even 
certain if that's allowable. But if not remove the cat.id and see if 
it works, or what error is returned.  All these different 
implementations of SQL occasional kill me.

Alnisa


-- 
   .
Alnisa  Allgood
Executive Director
Nonprofit Tech
(ph) 415.337.7412  (fx) 415.337.7927
(url)  http://www.nonprofit-techworld.org
(url)  http://www.nonprofit-tech.org
(url)  http://www.tech-library.org
   .
Nonprofit Tech E-Update
mailto:[EMAIL PROTECTED]
   .
applying technology to transform
   .

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Another SQL Question

2001-08-13 Thread Alnisa Allgood

At 10:31 AM -0700 8/13/01, Barry Prentiss wrote:
Thx Again Alnisa,
  You were very close, and instrumental in solving this seemingly simple
query problem.
  The actual query that worked looks like this:

  SQL select cat.id, cat.name, count(faq_cat.cat_id) as num
   2  from mdfaq_faq_cat faq_cat, mdfaq_category cat
   3  where faq_cat.cat_id (+) = cat.id
   4  group by cat.id, cat.name;


Funny, I think I just sent you something somewhat similar. Glad it worked.

Alnisa
-- 
   .
Alnisa  Allgood
Executive Director
Nonprofit Tech
(ph) 415.337.7412  (fx) 415.337.7927
(url)  http://www.nonprofit-techworld.org
(url)  http://www.nonprofit-tech.org
(url)  http://www.tech-library.org
   .
Nonprofit Tech E-Update
mailto:[EMAIL PROTECTED]
   .
applying technology to transform
   .

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Windows+GD-ed Images

2001-08-13 Thread Jonathan Hilgeman

Hi people,
I have a site that is made up of a number of different images that are all
created on the fly with GD. The site works fine on a stable UNIX
environment, but I have tried to transfer it to a regular Windows box for
development, and I am having some troubles.

MOST of the images will work fine, but after clicking through a few pages,
images will begin to break. I have tried increasing the ThreadsPerChild in
the Apache config to 100, then to 200 (originally 50), and if I reload the
page after restarting the server, the new image will show up, but the same
situation repeats after clicking through more pages.

Is there any particular reason that anyone can think of, why this would
happen? Here are the specs:
Machine: Celeron 400-something/128 Mb RAM (Yes I know its not much to look
at)
Apache 1.3.19
MySQL 3.23.37
PHP 4.0.5
GD 1.8.3? (Something like that - it supports PNGs)

I have plenty of hard drive space left.

- Jonathan



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Anyone used Pearson Corilations in PHP

2001-08-13 Thread Robert Trembath

Good Afternoon Everyone,

I am a fellow PHP developer that has run into a project where I need to know if 
anyone has created anything like this.

I need to do Pearson Corilations on Data from MySQL to do a top 10 match that 
compares DNA numerical image data(grayscale(0-255) and creates an image based on 
that image data for each row of image data.

Anyone done this before? Anything similar? Any comment are appreciated.

Thanks,
Robert
-
---
Robert Trembath
[EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Resource Consumption

2001-08-13 Thread Jonathan Hilgeman

I previously posted that GD was giving me grief after a while, once I had
moved the development of my site over to a Windows machine running Apache. I
believe I now know why there were problems. After a while, I began receiving
error messages and they would output in the middle of the image code,
causing the image to break. Setting error_reporting to 0 allowed them to
load.

Now I have another problem. It seems that after Apache uses a file, it does
not release it. I was able to display a sample image using a TrueType font
file, and I was able to see the text perfectly. After refreshing, the text
portion of the image did not work, but other elements of the image did.

I wrote $php_errormsg to a logfile and was able to see the following error:
Could not read font

However, I KNOW the font is there, and it has loaded it before. I
double-checked to make sure, and it was still there. It seems that it cannot
open the file or something - as if another process were using the file. The
only explanation I can think of is that Apache never let go of the file
after using it. Is this a possibility? Remember, I am using a Windows 2k
platform.

- Jonathan



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] MySQL Modules and multiple database

2001-08-13 Thread Szii

Opening multiple databases on the same database machine
seems unsupported.  While you CAN do it, it has a tendency
to reuse the last connection even in lieu of a specific database.
Right now we're using mysql_db_query() to get around it, but
with that becoming deprecated, we need to find anothe solution.

Anyone have any ideas/thoughts?

Thanks.

-Szii 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] MySQL Connection Lost....

2001-08-13 Thread Adam Douglas

Ok I've finally gotten MySQL 3.23.37 installed and operating. Thanks to 
all that helped! The problem I'm now experiencing is when I try to 
interface with MySQL via PHP. MySQL seems to work fine by logging into 
MySQL directly and through a MySQL GUI Client. I get the following error...

Warning: MySQL Connection Failed: Lost connection to MySQL server during 
query...

I'm assuming this is a MySQL issue since everything worked fine before 
the upgrade from MySQL 3.32.22 to MySQL 3.23.37. But for all I know it 
could be PHP I guess.

I'm doing very simple query to see if it works and no success. Even code 
that worked before I upgraded doesn't work anymore. Here's the test 
query I made... (BTW, the below query works fine via MySQL/MySQL GUI Client)

$szQuery = SELECT * FROM People WHERE First_Name='adouglas';
$dbconnection = mysql_connect(207.195.58.33,webuser,adamacc226);
mysql_select_db(venmar, $dbConnection) or die(could not connect to 
venmar for security authentication.);
$saResults = mysql_query($szQuery, $dbConnection) or die (2could not 
query venmar for security authentication.);
$obResults = mysql_fetch_row($saResults)

echo $obResults[0], $obResults[1], $obResults[2], $obResults[3], 
$obResults[4], $obResults[5];


The MySQL Database has it's own dedicated machine running on OpenBSD 
2.9. The web server accessing the MySQL Database is on it's own machine 
with Apache 1.3.12 and OpenBSD 2.9. Any other details needed let me know.

+--+---+
| Variable_name| Value |
+--+---+
| Aborted_clients  | 0 |
| Aborted_connects | 6 |
| Bytes_received   | 4125  |
| Bytes_sent   | 45247 |
| Connections  | 15|
| Created_tmp_disk_tables  | 0 |
| Created_tmp_tables   | 0 |
| Created_tmp_files| 0 |
| Delayed_insert_threads   | 0 |
| Delayed_writes   | 0 |
| Delayed_errors   | 0 |
| Flush_commands   | 1 |
| Handler_delete   | 4 |
| Handler_read_first   | 7 |
| Handler_read_key | 16|
| Handler_read_next| 2 |
| Handler_read_prev| 0 |
| Handler_read_rnd | 0 |
| Handler_read_rnd_next| 2597  |
| Handler_update   | 1 |
| Handler_write| 4 |
| Key_blocks_used  | 4 |
| Key_read_requests| 28|
| Key_reads| 4 |
| Key_write_requests   | 18|
| Key_writes   | 12|
| Max_used_connections | 1 |
| Not_flushed_key_blocks   | 0 |
| Not_flushed_delayed_rows | 0 |
| Open_tables  | 22|
| Open_files   | 44|
| Open_streams | 0 |
| Opened_tables| 38|
| Questions| 135   |
| Select_full_join | 0 |
| Select_full_range_join   | 0 |
| Select_range | 0 |
| Select_range_check   | 0 |
| Select_scan  | 15|
| Slave_running| OFF   |
| Slave_open_temp_tables   | 0 |
| Slow_launch_threads  | 0 |
| Slow_queries | 0 |
| Sort_merge_passes| 0 |
| Sort_range   | 0 |
| Sort_rows| 0 |
| Sort_scan| 0 |
| Table_locks_immediate| 52|
| Table_locks_waited   | 0 |
| Threads_cached   | 0 |
| Threads_created  | 14|
| Threads_connected| 1 |
| Threads_running  | 1 |
| Uptime   | 7235  |
+--+---+

+-+---+
| Variable_name   | Value 
 
|
+-+---+
| ansi_mode   | OFF 
 
|
| back_log| 50 
 
|
| basedir | /usr/local/ 
 
|
| binlog_cache_size   | 32768 
 
|
| character_set   | latin1 
 
|
| character_sets  | latin1 dec8 dos german1 hp8 koi8_ru 
latin2 swe7 usa7 cp1251 danish hebrew win1251 estonia hungarian koi8_ukr 
win1251ukr greek win1250 croat cp1257 latin5 |
| concurrent_insert   | ON 
 
|
| connect_timeout | 5 
 
|
| datadir | /var/mysql/ 
 
 

[PHP-DB] Can PHP exclude % characters in external txt file?

2001-08-13 Thread Brian Tegtmeier

Whats up everybody? I am setting up a PHP script that has a ? include ('data.txt'); 
? text file, but in the actual text file it has a % tag before each item in the list 
due to a way this database is setup.

What i am trying to do is have this txt file display on one of my subpages, but have 
PHP force the removal of the % character when it parses.

Any suggestions? Thanks for the help!  :)

-- 

___
FREE Personalized E-mail at Mail.com 
http://www.mail.com/?sr=signup 

Talk More, Pay Less with Net2Phone Direct(R), up to 1500 minutes free! 
http://www.net2phone.com/cgi-bin/link.cgi?143 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] MySQL Modules and multiple database

2001-08-13 Thread Paul Burney

on 8/13/01 1:56 PM, Szii ([EMAIL PROTECTED]) wrote:

 Opening multiple databases on the same database machine
 seems unsupported.  While you CAN do it, it has a tendency
 to reuse the last connection even in lieu of a specific database.
 Right now we're using mysql_db_query() to get around it, but
 with that becoming deprecated, we need to find anothe solution.

Before each query (from a different database), you can call the function;

mysql_select_db($database_name, $connection_id)

You can also specify the connection id for your queries:

mysql_query($query, $connection_id)

Just make sure that you select the db before each query otherwise a query
will use the last selected database.

Sincerely,

Paul Burney

+-+-+
| Paul Burney | P: 310.825.8365 |
| Webmaster  Programmer | E: [EMAIL PROTECTED]   |
| UCLA - GSEIS - ETU   | W: http://www.gseis.ucla.edu/ |
+-+-+


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] MySQL Modules and multiple database

2001-08-13 Thread Szii

Done both.

In fact, I create an object which has 2 database objects in it.
If I dump the objects, I can WATCH as they merge and point 
at the same database.

I go back to using mysql_db_query() and everything's fine.
It would appear that the mysql_select_db() is not persisting.
If you call it on two different links, it's seems to modify both
links.  Almost like it's global

*shrug*

-Szii

- Original Message - 
From: Paul Burney [EMAIL PROTECTED]
To: Szii [EMAIL PROTECTED]; php mailing list [EMAIL PROTECTED]
Sent: Monday, August 13, 2001 2:28 PM
Subject: Re: [PHP-DB] MySQL Modules and multiple database


 on 8/13/01 1:56 PM, Szii ([EMAIL PROTECTED]) wrote:
 
  Opening multiple databases on the same database machine
  seems unsupported.  While you CAN do it, it has a tendency
  to reuse the last connection even in lieu of a specific database.
  Right now we're using mysql_db_query() to get around it, but
  with that becoming deprecated, we need to find anothe solution.
 
 Before each query (from a different database), you can call the function;
 
 mysql_select_db($database_name, $connection_id)
 
 You can also specify the connection id for your queries:
 
 mysql_query($query, $connection_id)
 
 Just make sure that you select the db before each query otherwise a query
 will use the last selected database.
 
 Sincerely,
 
 Paul Burney
 
 +-+-+
 | Paul Burney | P: 310.825.8365 |
 | Webmaster  Programmer | E: [EMAIL PROTECTED]   |
 | UCLA - GSEIS - ETU   | W: http://www.gseis.ucla.edu/ |
 +-+-+


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: Can PHP exclude % characters in external txt file?

2001-08-13 Thread Phillip Bow

I can't think of a simple way to do it off of an include, but off the top of
my head:
?php
$file = file(data.txt);
for($x=0; $xcount($file); $x++){
$temp = str_replace(%, , $file[$x]);
print $temp\n;
}
unset($file, $temp);
?
--
phill

Brian Tegtmeier [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Whats up everybody? I am setting up a PHP script that has a ? include
('data.txt'); ? text file, but in the actual text file it has a % tag
before each item in the list due to a way this database is setup.

 What i am trying to do is have this txt file display on one of my
subpages, but have PHP force the removal of the % character when it parses.

 Any suggestions? Thanks for the help!  :)

 --

 ___
 FREE Personalized E-mail at Mail.com
 http://www.mail.com/?sr=signup

 Talk More, Pay Less with Net2Phone Direct(R), up to 1500 minutes free!
 http://www.net2phone.com/cgi-bin/link.cgi?143




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] error on post

2001-08-13 Thread John Telesh

I have created a form which I cannot duplicate the error which is coming up
only sometimes.  An affiliate to my client had received emails regarding the
following error:

The requested method POST is not allowed for the URL/index.html

The page this is running on is called maxout.php and it is a post onto
?PHP_SELF?  I do not have a clue what is going on here.  Can anyone help,
or have they seen this error before??

Thanks,

JT Telesh



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] OCIDefineByName/OCIBindByName help?

2001-08-13 Thread Barry Prentiss

Hi,
 Can anyone help me to understand the OCIBindByName/OCIDefineByName
functionality when used with the Oracle 'returning' clause? These two
functions are seriously under-documented at PHP.net.
 I need the sequence-generated ID created during an insert for further
manipulation.
 I tried sequence-name.currval but got an error.
 Here's some code that doesn't work:

   $sql = insert into mdfaq values (null,'$Question','$Answer') returning
ID into :ID;
   $stmt = ociParse($conn,$sql);
   OCIBindByName($stmt,:ID,$faq_ID,-1);
   ociExecute($stmt);

   $sql = insert into mdfaq_faq_cat values ($faq_ID, $req_cat);
   $stmt = ociParse($conn,$sql);
   ociExecute($stmt);

 Any Ideas?
 Thx in Advance,
 Barry Prentiss



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] OCIDefineByName/OCIBindByName help?

2001-08-13 Thread Graeme Merrall

Quoting Barry Prentiss [EMAIL PROTECTED]:

 Hi,
  Can anyone help me to understand the OCIBindByName/OCIDefineByName
 functionality when used with the Oracle 'returning' clause? These two
 functions are seriously under-documented at PHP.net.
  I need the sequence-generated ID created during an insert for further
 manipulation.
  I tried sequence-name.currval but got an error.
  Here's some code that doesn't work:
 
$sql = insert into mdfaq values (null,'$Question','$Answer')
 returning
 ID into :ID;
$stmt = ociParse($conn,$sql);
OCIBindByName($stmt,:ID,$faq_ID,-1);

You don't need to pass by reference and you should be able to ommit the length 
parameter. You should probably bind $Question and $Answer as well. That way 
your queries will be more efficient and you dont have to worry about escaping 
quotes.

Also your SQL should be 
INSERT INTO mdfaq VALUES (sequence.nextval, '$Question', '$Answer') returning 
ID into :id

ID should be the column name of your primary key column.

ocidefinebyname is useful for pulling columns out of Oracle so you don't need 
to make calls to ociresult() all the time. I actually don't see much benefit 
over using fetchstatement()

Cheers,
 Graeme

Cheers,
 Graeme

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] OCIDefineByName/OCIBindByName help?

2001-08-13 Thread Graeme Merrall

Quoting Barry Prentiss [EMAIL PROTECTED]:

 Hi,
  Can anyone help me to understand the OCIBindByName/OCIDefineByName
 functionality when used with the Oracle 'returning' clause? These two
 functions are seriously under-documented at PHP.net.
  I need the sequence-generated ID created during an insert for further
 manipulation.
  I tried sequence-name.currval but got an error.
  Here's some code that doesn't work:
 
$sql = insert into mdfaq values (null,'$Question','$Answer')
 returning
 ID into :ID;
$stmt = ociParse($conn,$sql);
OCIBindByName($stmt,:ID,$faq_ID,-1);

You don't need to pass by reference and you should be able to ommit the length 
parameter. You should probably bind $Question and $Answer as well. That way 
your queries will be more efficient and you dont have to worry about escaping 
quotes.

Also your SQL should be 
INSERT INTO mdfaq VALUES (sequence.nextval, '$Question', '$Answer') returning 
ID into :id

ID should be the column name of your primary key column.

ocidefinebyname is useful for pulling columns out of Oracle so you don't need 
to make calls to ociresult() all the time. I actually don't see much benefit 
over using fetchstatement()

Cheers,
 Graeme

Cheers,
 Graeme

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] mail function

2001-08-13 Thread Travis Cannell

hi all,

I cant seem to get my mail function to work. OK so i am a noob, that might
have something to do with it.  I am using a script I found called the HTML
Mime Mail Class, which does everything i need except actually send the mail.
I am guessing that there is some config problems, but i am not sure.  Even
when i try and use the mail() function i get a server error.  So i guess
that my problem is that my return address is messed up.  Does it have to  be
my own domain, or the domain that the server is running on?  Can i set the
return address as a hotmail account, or do i need my own server mail
program?  And is there anything that i need to config in the php.ini file?

Thanks for helping,

T P K Cannell



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: Show abbreviated article

2001-08-13 Thread Tom Henry


Try using MySQL to do that right in the query itself (and save the 
overhead of retreiving the whole blob then PHP'ing the blob too).

 From the MySQL Doc's   ;-)  RTFM once at least
--
SUBSTRING(str,pos,len)
SUBSTRING(str FROM pos FOR len)
MID(str,pos,len)
Returns a substring len characters long from string str, starting at 
position pos. The variant form that uses FROM is ANSI SQL92 syntax.

mysql select SUBSTRING('Quadratically',5,6);
 - 'ratica'
--


For your problem it might look like
$sql = SELECT field1, field2, SUBSTRING(blobfieldname,0,160) FROM 
articles where 

( BTW I usually assume prox 8 chars per word for something like this so 
20 wds x 8 char = 160 chars total  BUT you might have lots of esoterica 
in there and might want to adjust that ;-) )


HTH
Tom Henry



Cilfa wrote:
 Hi,
 
 On my website I want to display some articles, in Slashdot style. The
 main page should only display the first 20 words of the article, and
 users should be able to click on a link to view the entire article.
 The articles are stored in a MySQL database, the body of the article in a
 blob-field.
 
 My question is this: how can I select only those first 20 words in the
 PHP code?
 
 I hope somebody can help me with this.
 
 Cilfa
 
 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] start over on database read inorder to read from the beggining again

2001-08-13 Thread Caleb Walker

How can I run through a database like I am trying to do here?  It seems like 
at the end of the first I need to start over in order to start reading from 
the beggining of the database on the second.
I hope that I hace explained my problem well if not please reply with your 
questions.  Thank you in advance.

Caleb
!--Snip--
$connect = mysql_connect($host,$user,$pass) OR (die(mysql_error));
$selectdb = mysql_select_db($db) OR (die(mysql_error));
$result = mysql_query(SELECT * FROM teams where week='$list' ORDER BY date);
while($view = mysql_fetch_row($result))
{
code;
}
more code;
and html
while($view = mysql_fetch_row($result))
{
code;
}
!--Snip--

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] start over on database read inorder to read from the beggining again

2001-08-13 Thread Lars B. Jensen, LJ Webnologics


To run with less overhead, I would advice to only access the database when
absolutely nessary. Therefor I would approach the problem with pasting the
database result into an array and then doing the work from here - an array
is much faster to work with rather than db.

An approach could be
?php
$connect = mysql_connect($host,$user,$pass) OR die(mysql_error());
$selectdb = mysql_select_db($db) OR die(mysql_error());
$result = mysql_query(SELECT * FROM teams where week='$list' ORDER BY
date);

if (!mysql_num_rows($result)) {
die (No results);
}

$res = array();
while($foo = mysql_fetch_row($result)) {
$res[] = $foo;
}
$resSize = sizeof($res);

# now add your code... loop through the array using
for ($i=0; $i$resSize; $i++) {
echo $res[$i][RowName];
}
?

/ Lars
LJWeb GmbH

www.ljweb.com



-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: 14. august 2001 13:40
To: Caleb Walker; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] start over on database read inorder to read from
the beggining again


 How can I run through a database like I am trying to do here?  It seems
like
 at the end of the first I need to start over in order to start reading
from
 the beggining of the database on the second.
 I hope that I hace explained my problem well if not please reply with your
 questions.  Thank you in advance.

 Caleb
 !--Snip--
 $connect = mysql_connect($host,$user,$pass) OR (die(mysql_error));
 $selectdb = mysql_select_db($db) OR (die(mysql_error));
 $result = mysql_query(SELECT * FROM teams where week='$list' ORDER BY
date);
 while($view = mysql_fetch_row($result))
 {
 code;
 }
 more code;
 and html
 while($view = mysql_fetch_row($result))
 {
 code;
 }

try adding:

mysql_data_seek($result, 0);

before your second loop. This should reset your dataset so you can loop
again.

regards
--
Jason Wong
Gremlins Associates
www.gremlins.com.hk




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]