RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(

2004-05-12 Thread Gryffyn, Trevor
First, I don't think you are likely to use COM calls on a linux box
since COM and DCOM are MS things aren't they?   Even if not, it might
require some configuration on the server end which you can't do.
 
I use the ADOdb database library for PHP in all the things I do:
http://php.weblogs.com/adodb
 
I have a dbconnect.inc file that has all my connect strings in a
switch/case statement that dynamically changes the connect string.
 
I think you can connect DSNLess to an Access database this way.
 
I'll paste a stripped down version of the dbconnect.inc to my message
since I don't know if this list accepts attachments.   Let me know if
you have any questions.. good luck!
 
-TG
 
Connect($myDSN);
#$db->debug=true;
 
if ($sqlquery <> "") {
  $rs = $db->Execute($sqlquery);
  if ($rs === false) {
print "Error: (" . $db->ErrorNo() . ") " . $db->ErrorMsg() .
"\n";
  } else {
$arr = $rs->GetArray();
print "Status: (" . $db->ErrorNo() . ") " . $db->ErrorMsg() .
"\n";
  }
} else {
  $rs = $db->Execute($sql);
  if ($rs === false) {
print "Error: (" . $db->ErrorNo() . ") " .
$db->ErrorMsg()."$sql\n";
  }
}
 
$sqlquery = "";
$sql = "";
 
$db->Close();
?>
-Original Message-
From: Alex Gemmell [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 8:12 AM
To: PHP List
Subject: [PHP-DB] Linux/PHP/Access Database - oh boy :(


Hello all,
 
I am fairly new to Linux/PHP so please bear with me.  I have an
awfully awkward problem to solve - a stop gap solution for the next 6
months until we have out in-house servers set up and running.  I also
have a very short timeframe to sort this out.  I am using PHP on a
remotely hosted Linux web server to build my website, however I have
been given a MS Access database to use!  Despite my best efforts (and
two days Google trawling) I haven't found a suitable solution so I am
turning to your collective knowledge...
 
First things first - I do not run the server and cannot install
any new tools on to it (I cannot access the folders above my web root).
There are lots of suggestions on the net about installing MDBTools and
UnixODBC RPM (http://bryanmills.net:8086/archives/99.html) - but
that involves the admin who won't do it!  I can, of course, put scripts
that may help in the actual web folder and reference them if anyone has
any ideas...
 
I know I must use a DSN-less connection.  I first tried
connecting directly to the mdb file using:
$conn = new COM("ADODB.Connection") or die ("Cannot
create ADODB Connection object."); 

//$connstr =
"PROVIDER=MSDASQL;DBQ=/prices/mydb.mdb;"."DRIVER={Microsoft Access
Driver (*.mdb)};" 
//$connstr = "Provider=Microsoft,.Jet.OLEDB.4.0;
Data Source=". realpath("prices/mydb.mdb") ." ;";
// I've never got the above two connection strings
to work but I include them for completeness and in case any realises
they might help me!
$connstr = "DRIVER={Microsoft Access Driver
(*.mdb)}; DBQ=". realpath("prices/mydb.mdb") ." ;";
 
$conn->open($connstr);
 
This worked on my localhost running IIS 5 (unsurprisingly) but
fell over immediately on the Linux box.  I am told this is because COM
support in PHP before version 4.3.x is buggy (he PHP version installed
on the server is 4.1.2).  Is this true?  Will upgrading to version 4.3.x
solve all my problems?
 
Also, I heard that converting the .mdb file to a .dbf file might
help - but how do I connect to that with PHP?  The PHP manual says this
about dbase functions:
"These functions allow you to access records stored in
dBase-format (dbf) databases. There is no support for indexes or memo
fields."
That's no good because I have long text fields in the Access
database that are of type "memo"!
The Manual also says "we recommend that you do not use dBase
files as your production database" - eek!  It's only a small database
(one table with about 50 records, each with no more than 20 fields) so
hopefully it will suffice.
 
Am I right in thinking I have very few options?   I don't want
to move over to ASP (would that even help?) because it means learning
VBScript and I don't have a lot of time.  Also, I can't use another
database (e.g. MySQL) cos the server admin is NOT helping me and won't
install anything new.
 
I know 99% of you will want to tell me to just back out of this
horrible tangle and take a different route, but is there one person out
there who can help me get through this nightmare?
 
Thank you!
 
Alex Gemmell
|:| Reply-to: [EMAIL PROTECTED]
  |:|
 
Or call me for free using Skype: 
  
 


RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(

2004-05-12 Thread Gryffyn, Trevor
Yeah, go ahead and steal the connection strings, that's why I posted
them :)
 
Also check out:
http://www.connectionstrings.com/
http://www.afn.org/~afn45181/Ben/SPSS/Merant/merant/client/win32/program
%20files/SPSSOEM/ODBC42/help/wwhelp/wwhimpl/common/html/wwhelp.htm?conte
xt=ODBC&file=Rdbasfox6.html
 
The first one has sample connection strings for lots of databases and
the second seems to have info on dbase5 specifically.   If not,
searching the web should work.  The connection string should be the same
or very similar to what ASP and other such things use.
 
As for not being able to access MDB files from PHP..   I really think
there's got to be a way.  I could be wrong, but when I was reading
around it seems like PHP doesn't like to do DSNless connections which is
why I started using ADOdb because it let me do DSNless connection
strings and all.  Maybe it's just the fact that most people use ODBC
sources to connect and aren't used to dealing with DSNless connections
that they're telling you that it won't work without ODBC or some other
intermediary.  Worth trying ADOdb though I think.
 
realpath is a good idea and it's something I used when I used to do ASP
in order to do the DSNless connections.  You kind of have to anyway
because you need the actual path of the MDB file that you're using.
 
I actually had a hosting company try to charge me $35 apiece for
"database setup fees" something like 6 months after I set up some ASP
with MDB using DSNless connections.   I argued with them that they
didn't set anything up, I did.   They wanted $35 to set up an ODBC
source (and to cover part of the server load that database connections
were likely to cause I guess).  But since I circumvented that, they
couldn't legally justify themselves in charging me the money and ended
up refunding the auto-charge to my credit card.
 
Something to think about for anyone settnig up PHP or ASP stuff with a
DSNless connection on a web hosting site.
 
-TG
-Original Message-
From: Alex Gemmell [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 10:27 AM
To: 'PHP List'
Cc: Gryffyn, Trevor
Subject: RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(


Thank you Trevor!

Funny you should mention ADOdb.  I just d/l it and uploaded it
to my web site!  I am working through the docs now.  I was losing hope
because I couldn't find what I was looking for but if you don't mind I
will help myself to your connection string:
 
case "OtherDB":
# Sample connect string to Access MDB file
$myDSN="PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver
(*.mdb)};Dbq='C:\Database.mdb';UID=;PWD=;";
 
I have been using the realpath function of PHP in other
connection strings to map the path from the server root to the database
location.  I assume will work fine here:
 
  $myDSN="PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver
(*.mdb)}; Dbq=". realpath("prices/mydb.mdb") .";UID=;PWD=;";
 
I'm still not sure this will work.  I'm getting a lot of
information from people saying a .mdb file (the MS Access database) just
can't be accessed this way and I should use an intermediate database
format, like .dbf which can be made by exporting the database out of MS
Access into  "dbase 5".
 
Does anyone know what the connection string for a .dbf (dbase 5)
format database is?
 
Alex
|:| Reply-to: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>  |:|

  _  

From: Gryffyn, Trevor [mailto:[EMAIL PROTECTED] 
Sent: 12 May 2004 15:09
To: PHP List
Cc: Alex Gemmell
Subject: RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(
 
First, I don't think you are likely to use COM calls on a linux
box since COM and DCOM are MS things aren't they?   Even if not, it
might require some configuration on the server end which you can't do.
 
I use the ADOdb database library for PHP in all the things I do:
http://php.weblogs.com/adodb
 
I have a dbconnect.inc file that has all my connect strings in a
switch/case statement that dynamically changes the connect string.
 
I think you can connect DSNLess to an Access database this way.
 
I'll paste a stripped down version of the dbconnect.inc to my
message since I don't know if this list accepts attachments.   Let me
know if you have any questions.. good luck!
 
-TG
 
Connect($myDSN);
#$db->debug=true;
 
if ($sqlquery <> "") {
  $rs = $db->Execute($sqlquery);
  if ($rs === false) {
p

RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(

2004-05-12 Thread Gryffyn, Trevor
Good point Bob.  If you're running IIS and can get PHP installed then
you can use the ADOdb or probably various other methods for accessing
the MDB files. No need to learn ASP then!  That should speed up
development time a little at least.

So looks like the options are:

1. Get various database tools installed on the linux box that probably
aren't going to really help you out too much
2. Get PHP installed on the Windows box and use ADOdb or something
similar to connect to the MDB files
3. Learn enough ASP to pull the data.  You could always just create an
ASP file that all it does is pull the data from the MDB and use PHP for
all the rest of your processing.

-TG

> -Original Message-
> From: Robert Twitty [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, May 12, 2004 11:46 AM
> To: Alex Gemmell
> Cc: 'PHP List'; Gryffyn, Trevor
> Subject: RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(
> 
> 
> Hi Alex
> 
> ADODb will not work either.  ADODb is basically a PHP 
> abstraction class library that relies on lower level database
extensions to 
> connect to the various databases.  The problem for you is that other
than the odbc
> extension combined with MDBTools, and the odbtp extension, there is no
> other way to connect to an MS Access database from Linux under PHP.
> 
> BTW, you mention that your other alternaive is to learn ASP.  
> This implies that you will be using IIS on another machine.  Can PHP
be 
> installed on that machine?
> 
> -- bob
> 
> On Wed, 12 May 2004, Alex Gemmell wrote:
> 
> > Thank you Trevor!
> >
> > Funny you should mention ADOdb.  I just d/l it and uploaded 
> it to my web
> > site!  I am working through the docs now.  I was losing 
> hope because I
> > couldn't find what I was looking for but if you don't mind 
> I will help
> > myself to your connection string:
> >
> > case "OtherDB":
> > # Sample connect string to Access MDB file
> > $myDSN="PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver
> > (*.mdb)};Dbq='C:\Database.mdb';UID=;PWD=;";
> >
> > I have been using the realpath function of PHP in other 
> connection strings
> > to map the path from the server root to the database 
> location.  I assume
> > will work fine here:
> >
> >   $myDSN="PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver 
> (*.mdb)}; Dbq=".
> > realpath("prices/mydb.mdb") .";UID=;PWD=;";
> >
> > I'm still not sure this will work.  I'm getting a lot of 
> information from
> > people saying a .mdb file (the MS Access database) just 
> can't be accessed
> > this way and I should use an intermediate database format, 
> like .dbf which
> > can be made by exporting the database out of MS Access into 
>  "dbase 5".
> >
> > Does anyone know what the connection string for a .dbf 
> (dbase 5) format
> > database is?
> >
> > Alex
> > |:| Reply-to:  <mailto:[EMAIL PROTECTED]> 
> [EMAIL PROTECTED] |:|
> >   _
> >
> > From: Gryffyn, Trevor [mailto:[EMAIL PROTECTED]
> > Sent: 12 May 2004 15:09
> > To: PHP List
> > Cc: Alex Gemmell
> > Subject: RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(
> >
> > First, I don't think you are likely to use COM calls on a 
> linux box since
> > COM and DCOM are MS things aren't they?   Even if not, it 
> might require some
> > configuration on the server end which you can't do.
> >
> > I use the ADOdb database library for PHP in all the things I do:
> > http://php.weblogs.com/adodb
> >
> > I have a dbconnect.inc file that has all my connect strings 
> in a switch/case
> > statement that dynamically changes the connect string.
> >
> > I think you can connect DSNLess to an Access database this way.
> >
> > I'll paste a stripped down version of the dbconnect.inc to 
> my message since
> > I don't know if this list accepts attachments.   Let me 
> know if you have any
> > questions.. good luck!
> >
> > -TG
> >
> >  > include("adodb/adodb.inc.php");
> >
> > ADOLoadCode("ado_mssql");
> > $db = &ADONewConnection("ado_mssql");
> >
> > switch ($database) {
> >   
> >   # Cargo System databases
> >   
> >
> >   case "PhotoGallery":
> > # Where the photos are stored
> > $myDSN="PROVIDER=MSDASQL;DRIVER={SQL
> > 
> Serv

RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(

2004-05-12 Thread Gryffyn, Trevor
I think you'd have the same issue with Chilisoft ASP as you would with
PHP because the issue isn't with the scripting language but with the
OS's support for ODBC or DSNless connections to an Access database.I
did a little reading on Chilisoft ASP a while ago and (1) it's not free
from what I understand and (2) I heard it doesn't function exactly how
ASP is supposed to so you could have some stability issues.   The MySQL
thing along with MDBTools or something sounds like it could be the best
way to go.

Or if you keep your master data set in MySQL and just use Access to pull
a copy from it when necessary for distribution (you said you distributed
the data via MDB files right?  Or do people change the MDBs and that
becomes the master?)

At any rate, good luck!  And keep us updated!

-TG


> -Original Message-
> From: Alex Gemmell [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, May 12, 2004 12:09 PM
> To: Gryffyn, Trevor; 'PHP List'
> Cc: 'Robert Twitty'
> Subject: RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(
> 
> 
> Thanks again Trevor and Bob!
> 
> The reason I was mentioning ASP is because "Chilli Soft! ASP" 
> thingy (?) is
> installed on the live (Linux/Apache) server.  IIS doesn't 
> come in to play
> (other than on my localhost I was (stupidly) testing on!).
> 
> I have just got off the phone having managed to get the 
> server admin to
> concede to allowing MySQL to be installed.  Hopefully he will 
> actually do
> this!
> 
> If so, this will solve ALL my problems!  Hurrah for 
> Linux/Apache/PHP/MySQL!
> Hurrah!
> 
> 
> Alex
> |:| Reply-to: [EMAIL PROTECTED] |:|
>  
> Or call me for free using Skype: 

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



RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(

2004-05-12 Thread Gryffyn, Trevor
In that case, you could write a PHP script on your PC (Windows right?)
that reads the data from the MDB file then posts the data to the MySQL
database.  Sounds easy enough. Hah  (that phrase has bitten me on the
backside more times than I can remember.. Challenges are fun though heh)

-Tg

> -Original Message-
> From: Alex Gemmell [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, May 12, 2004 12:19 PM
> To: Gryffyn, Trevor; 'PHP List'
> Subject: RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(
> 
> 
> Apologies if my situation isn't clear.  My brain is 
> noodle-soup after all
> this!
> 
> I am given an updated copy of the MS Access database 
> periodically. That
> needs uploading to the website and a few pages use it to 
> populate themselves
> with relevant data.
> 
> Basically - username/password check to login.  If successful 
> then show them
> most of the fields in their record.  Simple!
> 
> Simple, yeah, nothing to it...  ;)
> 
> Now my server admin are playing ball I have hope.  If I can 
> convert the MS
> Access db to MySQL without too many problems then I should be home and
> dry...
> 
> 
> Alex
> |:| Reply-to: [EMAIL PROTECTED] |:|
> 
> |-Original Message-
> |From: Gryffyn, Trevor [mailto:[EMAIL PROTECTED]
> |Sent: 12 May 2004 17:13
> |To: PHP List
> |Cc: Alex Gemmell
> |Subject: RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(
> |
> |I think you'd have the same issue with Chilisoft ASP as you 
> would with
> |PHP because the issue isn't with the scripting language but with the
> |OS's support for ODBC or DSNless connections to an Access 
> database.I
> |did a little reading on Chilisoft ASP a while ago and (1) 
> it's not free
> |from what I understand and (2) I heard it doesn't function 
> exactly how
> |ASP is supposed to so you could have some stability issues.  
>  The MySQL
> |thing along with MDBTools or something sounds like it could 
> be the best
> |way to go.
> |
> |Or if you keep your master data set in MySQL and just use 
> Access to pull
> |a copy from it when necessary for distribution (you said you 
> distributed
> |the data via MDB files right?  Or do people change the MDBs and that
> |becomes the master?)
> |
> |At any rate, good luck!  And keep us updated!
> |
> |-TG
> |
> |
> |> -Original Message-
> |> From: Alex Gemmell [mailto:[EMAIL PROTECTED]
> |> Sent: Wednesday, May 12, 2004 12:09 PM
> |> To: Gryffyn, Trevor; 'PHP List'
> |> Cc: 'Robert Twitty'
> |> Subject: RE: [PHP-DB] Linux/PHP/Access Database - oh boy :(
> |>
> |>
> |> Thanks again Trevor and Bob!
> |>
> |> The reason I was mentioning ASP is because "Chilli Soft! ASP"
> |> thingy (?) is
> |> installed on the live (Linux/Apache) server.  IIS doesn't
> |> come in to play
> |> (other than on my localhost I was (stupidly) testing on!).
> |>
> |> I have just got off the phone having managed to get the
> |> server admin to
> |> concede to allowing MySQL to be installed.  Hopefully he will
> |> actually do
> |> this!
> |>
> |> If so, this will solve ALL my problems!  Hurrah for
> |> Linux/Apache/PHP/MySQL!
> |> Hurrah!
> |>
> |>
> |> Alex
> |> |:| Reply-to: [EMAIL PROTECTED] |:|
> |>
> |> Or call me for free using Skype:
> 
> 

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



RE: [PHP-DB] folder creation in php

2004-10-12 Thread Gryffyn, Trevor
The browser will automatically do this when you click on a link to a
file that the web browser knows as a file that you download versus HTML
or text being sent to the browser where it's just displayed instead of
triggering the download prompt.

Maybe that doesn't make much sense.. My head's a bit foggy right now.
But the deal is, you just need to create a link that when clicked on,
sends the browser something other than HTML or text or a known picture
format (you might have to send headers declaring the MIME type too...
Most likely do).

The link itself is something that's just done in HTML.  What happens
when you click the link might be PHP driven, but in general this isn't a
PHP or DB question unless there's something with the link that you're
having trouble creating.

-TG

> -Original Message-
> From: Adil [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 12, 2004 2:28 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] folder creation in php
> 
> 
> Here's what i'm trying to do in php and a mySQL database:
> 
> I want a button on a page that if clicked it launches the 
> browser's or OS's
> "Save As" window, allowing me to specify where to save my 
> file and/or create
> a new folder
> 
> thx in advance
> Adil..
> 
> -- 
> 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] folder creation in php

2004-10-12 Thread Gryffyn, Trevor
It's worth noting that if you're just generating HTML that creates just
a regular old HREF pointing to a regular old file, that the web server
will handle sending out the proper headers.

For example:

Your Download

You don't need to do anything special with PHP to make this send
correctly and PROBABLY (assuming the web server is configured properly
for that filetype) trigger your web browser to do the whole Save As...
Thing (again, assuming that your BROWSER is configured to ask what you
want to do.. Firefox, for example, will automatically download to your
desktop on a windows box by default).

If, for example, you generated html like this though:

Your Download

Then your "datasendscript.php" would have to generate the proper
headers.

-TG

> -Original Message-
> From: Dylan Barber [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 12, 2004 2:52 PM
> To: Gryffyn, Trevor
> Subject: RE: [PHP-DB] folder creation in php
> 
> 
> 
> you need to send headers to tell the os what the page is like 
> mime type etc. look on the PHP documentation
> -Original Message-
> From: "Gryffyn, Trevor" <[EMAIL PROTECTED]>
> Sent: Oct 12, 2004 1:34 PM
> To: [EMAIL PROTECTED]
> Cc: Adil <[EMAIL PROTECTED]>
> Subject: RE: [PHP-DB] folder creation in php
> 
> The browser will automatically do this when you click on a link to a
> file that the web browser knows as a file that you download 
> versus HTML
> or text being sent to the browser where it's just displayed instead of
> triggering the download prompt.
> 
> Maybe that doesn't make much sense.. My head's a bit foggy right now.
> But the deal is, you just need to create a link that when clicked on,
> sends the browser something other than HTML or text or a known picture
> format (you might have to send headers declaring the MIME type too...
> Most likely do).
> 
> The link itself is something that's just done in HTML.  What happens
> when you click the link might be PHP driven, but in general 
> this isn't a
> PHP or DB question unless there's something with the link that you're
> having trouble creating.
> 
> -TG
> 
> > -Original Message-
> > From: Adil [mailto:[EMAIL PROTECTED] 
> > Sent: Tuesday, October 12, 2004 2:28 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-DB] folder creation in php
> > 
> > 
> > Here's what i'm trying to do in php and a mySQL database:
> > 
> > I want a button on a page that if clicked it launches the 
> > browser's or OS's
> > "Save As" window, allowing me to specify where to save my 
> > file and/or create
> > a new folder
> > 
> > thx in advance
> > Adil..
> > 
> > -- 
> > 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
> 
> 
> 
> mailto:[EMAIL PROTECTED]">Dylan Barber
> Webmaster / Web Developer / Programing
> http://codegalaxy.com";>-codegalaxy.com-
> http://summer-swim.com";>-summer-swim.com-
> http://clipurl.com";>-clipurl.com-
> 
> 

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



RE: [PHP-DB] Names with apostrophe's

2004-09-29 Thread Gryffyn, Trevor
Try:

Echo "$row[book]\";

I'm dubious on the $row[book] bit took, maybe you meant $row["book"] or
$row[$book].

Anyway, you didn't have a closing quote on the HREF, you don't need the
( and ) on the echo, you used the ' instead of " for the HREF (which is
probably allowed but I don't like it myself).

As for apostrophes, you should be able to escape them with \'

If you use ' to start an echo or href, then another ' is going to close
it.  If you use " to open an echo or href, then the ' should go through
ok, or maybe require a \' but should still be ok.

When you insert apostrophes into a database, use '' to escape it (I
believe that works in MySQL as well as other DBs), don't use \' when
inserting into a DB.

Your question is a little cloudy, but maybe that helped clarify a few
things for you.

-TG

> -Original Message-
> From: Craig Hoffman [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, September 29, 2004 2:23 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Names with apostrophe's 
> 
> 
> Hello,
> I could use some help here.  I have an entry in the MySQL, 
> that use an  
> apostrophe,  for example lets call it "O'Reilly".  I have added  
> addslashes to my insert statement so MySQL accepts it with out  
> complaining.
> 
> The problem I am having is I use this information "O'Reilly" 
> in a GET  
> URL somewhere else in the site.
> For example here's my link:
> echo(" href='user_book_results_detail.php?book=$row[book]>$row[book] td>");
> 
> When I mouse over and view the URL, PHP thinks the apostrophe 
> (single  
> quote) is the end and quits.   I know I need to include a 
> back slash or  
> escape this character  but I am not entirely sure how I do it?
> Suggestions?
> 
> Sample URL:
> http://user_book_results_detail.php?book=O
> 
> -- 
> 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] Invisible Submit

2004-10-01 Thread Gryffyn, Trevor
You could do something trick with an IFRAME or something that calls
another script passing the data via the URL/$_GET instead of submitting
a hidden form.  Or just record the data in the session variables and
process it that way.  If you're using PHP, there's lots of things you
can do to capture data without user interaction that doesn't require a
secret 'submit' function.

If you absolutely have to do some kind of submit, then you might be able
to do something via javascript, but I don't think it'd be necessary.
Using IFRAME or some kind of frames method, you can access another file
(passing variables to it or using it to snag session data) without
changing the appearance of the main page the user is viewing.  Again,
some javascript might be helpful in addition to some PHP Stuff.

-TG

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
> Sent: Friday, October 01, 2004 10:20 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Invisible Submit
> 
> 
> I'm sure this can be done, just not sure how, or more
> what it's called. 
> 
> If I have an awaiting form to capture input from
> session and url variables , instead of having a button
> to click to submit the form, a way that the form
> submits on it's own ?
> 
> Stuart
> 
> -- 
> 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] microsoft access

2004-10-01 Thread Gryffyn, Trevor
I'm guessing that COM is going to be overkill for this.  I thought some
systems like ADOdb let you get to Access tables directly without COM.

I'm imaginging that COM might not always be a viable way to go anyway,
if you have an Access .MDB file on a server where your PHP stuff is
hosted, they probably don't have Access installed on their server (why
would they?).

If I have time later, I'll double-check ADOdb and such, but I'd look
into something like that before I'd use COM.

-TG

> -Original Message-
> From: Matt M. [mailto:[EMAIL PROTECTED] 
> Sent: Friday, October 01, 2004 11:54 AM
> To: Matthew Perry
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] microsoft access
> 
> 
> > Does anyone know of a good online source for using php and microsoft
> > access.
> > I don't want to have to use asp.
> > Thank you for your time.
> 
> you could use com objects with Microsoft ADO
> 
> -- 
> 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] microsoft access

2004-10-01 Thread Gryffyn, Trevor
Thanks for the clarification, Bob.  ADOdb is one of those things that I
use, but don't really think about much so terms like "abstraction layer"
didn't come immediately to mind.  So in the interest of not sounding
like a dumbass and using the wrong terms, I just kept my response vague
:)

At any rate, COM is still going to require Access to be installed.  ODBC
I have experience with, so that sounds like the best route for general
use.  And I have no experience with odbtp, so can't really judge on that
one.

Anyway, thanks again Bob, input is goood.

-TG

> -Original Message-
> From: Robert Twitty [mailto:[EMAIL PROTECTED] 
> Sent: Friday, October 01, 2004 2:27 PM
> To: Gryffyn, Trevor
> Cc: [EMAIL PROTECTED]; Matt M.; Matthew Perry
> Subject: RE: [PHP-DB] microsoft access
> 
> 
> ADODB is a PHP abstraction layer class. In other words it 
> hides the fact
> that it is using the odbc extension to connect to Access. And, it has
> another driver that uses the COM extension to connect to Accesss
> (ado_access).
> 
> Basically there are only 3 options for connecting to Access 
> from PHP. They
> are odbc, COM and odbtp. So, the comparison must be done 
> amongst them, and
> not with an abstraction layer that uses them.
> 
> -- bob
> 
> On Fri, 1 Oct 2004, Gryffyn, Trevor wrote:
> 
> > I'm guessing that COM is going to be overkill for this.  I 
> thought some
> > systems like ADOdb let you get to Access tables directly 
> without COM.
> >
> > I'm imaginging that COM might not always be a viable way to 
> go anyway,
> > if you have an Access .MDB file on a server where your PHP stuff is
> > hosted, they probably don't have Access installed on their 
> server (why
> > would they?).
> >
> > If I have time later, I'll double-check ADOdb and such, but I'd look
> > into something like that before I'd use COM.
> >
> > -TG
> >
> > > -Original Message-
> > > From: Matt M. [mailto:[EMAIL PROTECTED]
> > > Sent: Friday, October 01, 2004 11:54 AM
> > > To: Matthew Perry
> > > Cc: [EMAIL PROTECTED]
> > > Subject: Re: [PHP-DB] microsoft access
> > >
> > >
> > > > Does anyone know of a good online source for using php 
> and microsoft
> > > > access.
> > > > I don't want to have to use asp.
> > > > Thank you for your time.
> > >
> > > you could use com objects with Microsoft ADO
> > >
> > > --
> > > 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] -14 Days Ago

2004-10-08 Thread Gryffyn, Trevor
That's probably the best way to go, but if you wanted another way:

$mySqlDate = "20041008";
$month = substr($mySqlDate,4,2);
$day = substr($mySqlDate,6,2);
$year = substr($mySqlDate,0,4);

$mySqlDateSerial = mktime(0,0,0,$month,$day,$year);
$twoWeeksAgoSerial = mktime(0,0,0,date("m"),date("d")-14,date("Y"));

If ($mySqlDateSerial < $twoWeeksAgoSerial) {
  echo "Assignment In Void:Assignments in the void are
read-only";
  require('footer.php');
  exit;
}


But I always do things the hard way.  Haha.

-TG


> -Original Message-
> From: Wendell Frohwein [mailto:[EMAIL PROTECTED] 
> Sent: Friday, October 08, 2004 2:57 PM
> To: 'Cole S. Ashcraft'; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] -14 Days Ago
> 
> 
> You can trying using the MySQL DATE_ADD() , DATE_SUB , and NOW()
> functions.
> 
> 
> -wendell frohwein
> 
> -Original Message-
> From: Cole S. Ashcraft [mailto:[EMAIL PROTECTED] 
> Sent: Friday, October 08, 2004 11:36 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] -14 Days Ago
> 
> I am trying to see whether a data in an array pulled from a MySQL DB 
> (YEARMONTHDATE) is older than 14 days ago. I am trying to do this in 
> PHP. My code looks like:
> 
> if($array['due'] <= $today - 14)
> {
> echo "Assignment In Void:Assignments in the void are 
> read-only";
> require('footer.php');
> exit;
> }.
> 
> I am having problems with the math. How do I do a date subtraction 
> without ending up with something like 20040994 (not a valid date)?
> 
> Thanks,
> Cole

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



[PHP-DB] Copyright law, how to protect your investment, how to protect your work... Was - RE: [PHP-DB] Please point me in the right direction.......

2004-11-10 Thread Gryffyn, Trevor
I'm surprised I havn't seen this question come up before (might have
just missed it) but it's an excellent question so forgive the
crossposting as it's extremely relevant to coders and those purchasing
services of coders.

Anyone who's gotten married and hired a wedding photographer is probably
familiar with the idea of "You can't make your own reprints, the photos
are owned by the photographer".  What kind of BS is that eh?  It was
your wedding!  You paid the guy, right?

I read a really interesting article talking about this a while ago and
found out that they key words you want to use (if you want to own what
you pay for) are the words "work for hire".  Usually this would be put
in the contract or even on the check you use to pay for the services..
"Signing this check constitutes the payee's acknowledgement that the
services performed and the final output/art/photos/etc is considered a
Work for Hire" or something like that.  It's not good enough to say "All
copy rights transfer to the client" apparently.

How I understand it is this...   Any artist (musician, coder, author,
painter, etc) has an implicit copyright on whatever they make as soon as
they make it.   While in the process of making something, it's
considered a "Work in progress" and has additional rights under certain
laws (see the Steve Jackson case with the Secret Service about them
seizing electronic copies of a game manual that was "in progress" as a
suspected guide to hacking.  The electronic copies weren't protected
back then whereas a printed copy would have been.. But they may be
protected from seizure in legal cases these days... Not sure).


Anyway... So you write this code and you own it.  Regardless of whether
someone paid you to write it.  Unless of course you have an
"intellectual property" thing with the company you work for (like I do..
It says whatever I create for the company... On company time... Is
theirs).

So all those websites and PHP scripts that you set up for people...
They're yours.  Unless the client specifies that it's a "work for hire"
in your contract or on the check you gotta sign to get your bucks.


Now from the client's side of things.. Because we don't always write our
own stuff..  It's important to know about this as well so you can
protect your investment.   I don't know that a coder can legally demand
that you stop using their code, but it means that if you want to re-sell
what you had developed, you need to clear it with the coder first.   A
lot of people don't know this stuff and it's hard to find out when
someone's pirating code that technically belongs to you.. But it's good
to know what rights you do have.


Doing a quick search on Yahoo for "work for hire" and "copyright", I
found a TON of sites that seem to cover the subject.  I don't have time
to read them, but at a glance, some of these sounded like good things to
check up on:

http://www.weblawresources.com/Work-For-Hire-Clause.htm

http://www.gigalaw.com/articles/2000/loc-2000-02.html

http://www.copylaw.com/new_articles/wfh.html

http://repositories.cdlib.org/boaltwp/55/

http://www.keytlaw.com/Copyrights/wfhire.htm

http://www.copyright.gov/circs/circ1.html

http://www.music-law.com/workforhire.html


Hope this helps and maybe informs a few people.   You can ask me
questions if you want, but this is literally all I know about the
subject.  You're better off reading up on the sites above (and Googling
for others) and talking to a copyright lawyer about the matter if you
want more details.

Good luck everyone!

-TG

> -Original Message-
> From: Michael Cortes [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, November 10, 2004 2:12 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Please point me in the right direction...
> 
> I have a question about contracts or agreements.  
> 
> I am considering hiring a local company to do some coding for 
> us in LAMP to 
> augment what we have done already.  I have a problem with the 
> standard "we 
> own the code and copyright" clause in thier service agreement.  
> 
> Can someone point me to the correct mailing list as I don't 
> wish to start an 
> inapropriate thread.
> 
> 
> Thank you.
> -- 
> 
> Michael Cortes
> Fort LeBoeuf School District
> 34 East Ninth Street
> PO Box 810
> Waterford PA 16441-0810
> 814.796.4795

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



RE: [PHP-DB] query of two tables returns too many rows, many more than the two tables contain

2004-11-11 Thread Gryffyn, Trevor
This is a common join issue.  If you don't specify ANYTHING to connect
between the two tables, it'll do one row from the first table, then ALL
the rows from the second.  Row #2 from the first, then ALL the rows from
the second.

If you had 600 rows in each table, you'd end up with 360,000 rows as a
returned result.

Chances are, you're just not being specific about what links the two
tables.

You might try something like this:

SELECT dealers.account_no,
   dealers.DealerName,
   blackgate_users.User_Name, 
   blackgate_users.DealerName
FROM dealers, blackgate_users
WHERE dealers.account_no <> blackgate_users.User_Name
AND dealers.DealerName = blackgate_users.DealerName


Or something like that.


Just read the last thing you wrote.. Let me revise what I said then.

You say you want everything where there's an entry in Dealers, but no
corresponding entry in blackgate_users eh?  That's an outer join.  Try
this (syntax happy with SQL Server, I don't use MySQL a lot so it might
be slightly different):

SELECT dealers.account_no,
   dealers.DealerName,
   blackgate_users.User_Name, 
   blackgate_users.DealerName
FROM dealers left join blackgate_users on dealers.DealerName =
blackgate_users.DealerName
WHERE blackgate_users.DealerName is null


What this says is take everything in Dealers, left join it against
blackgate_users (left join says to take everything from the left side..
And match against the right side but leave NULL entries where there's no
match).   Then we tell it that the field we want to compare is
DealnerName in both cases.  The WHERE clause says only show us where
DealerName is null (meaning no corresponding record in blackgate_users).


I think that'll do it for ya.

-TG


> -Original Message-
> From: Chip Wiegand [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, November 11, 2004 4:28 PM
> To: PHP DB
> Subject: [PHP-DB] query of two tables returns too many rows, 
> many more than the two tables contain
> 
> 
> I have two tables I want to get out the rows that are 
> different between 
> them. The results I am getting is almost 50,000 rows, but the 
> two tables, 
> combined, contain only about 600 rows total. Here is the 
> select statement 
> -
> 
> SELECT dealers.account_no, dealers.DealerName, 
> blackgate_users.User_Name, 
> blackgate_users.DealerName
> FROM dealers, blackgate_users
> WHERE dealers.account_no NOT 
> LIKE blackgate_users.User_Name
> 
> in these tables the 
> dealers.account_no is the same data as the blackgate_users.User_Name
> dealers.DealerName is the same data as the blackgate_users.DealerName
> I just want the rows that are in the dealers table but not in the 
> blackgate_users table. 
> 
> Thanks for any help,
> Chip Wiegand
> Computer Services
> Simrad, Inc
> 425-778-8821 
> 425-771-7211 (FAX)
> 
> -- 
> 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] PHP vs ASP

2004-11-15 Thread Gryffyn, Trevor
These are some good points.  My gut reaction is similar to Robby's, but
here are the points he made:

> PHP = free
> ASP = not
> 
> PHP = most widely used scripting language online
> 
> PHP5 is out
> 
> PHP = tons of open source libraries..free to download

ASP comes free with PWS and IIS.  So if you're already in a Microsoft
environment, then PHP vs ASP as far as cost goes isn't a factor.

PHP most widely used scripting language?   I did some research on this
(because I, myself, had a "convince my Boss" session a little while
ago..  Which I'm never going to do, but I wanted to at least arm myself
a little bit) and I found some surveys and the general breakdown seemed
to be:

IIS = 1/3 of the servers online (roughly)
Apache = 2/3 of the servers online (roughly)

PHP = 45+% of the primary scripting on Apache servers.

Assuming ASP is used on 100% of the IIS boxes (or close to it), that
puts PHP and ASP almost dead even on usage.  I'm sure it sways depending
on the survey, winds, alignment of the planets, etc.  I don't think
we'll ever get a fair, unbiased survey of such things.

So that point is semi-debateable.   The idea that they're neck and neck
is encouraging though.

PHP5 vs ASP, ASP.NET, or other current flavors of ASP.. I don't have
direct head to head comparisons, but this seems to be a subjective
measurement of worth.

Tons of open source libraries,etc...There's a lot of sites devoted
to posting code snippets and even full applications.   Many for ASP as
well as PHP.   I think PHP's uniformity helps find useful code, whereas
when I look for ASP stuff, I get ASP, ASP.NET (VB), ASP.NET (C#) and
other mish-mashes of code samples.  But there's certainly not a lack of
ASP online resources.


So back to Martin's post, these are definitely points to consider.

Do you have in-house coders who already know something (that's the
battle I fight right now.  I'm the only PHP guy and we have at least two
ASP.NET coders and another couple of VB or other MS based coders that
could probably do the ASP.NET if needed.. So I'm outnumbered on that
one).

Do you have existing code that would have to be ported to PHP or would
you have to support two different scripting languages (most companies
prefer not to do this if they can help it).

Will it be web based or do you desktop applications (where a VB.NET or
some kind of Visual Studio compiled and developed application type
language would be better than PHP... At least until WinBinder gets fully
going hah).

Server... Yes.. Do you already have a server?  Do you have people that
know Apache?  Do you already have IIS running?If you're a small
shop, these things could change on a whim, if you have a larger user
base where even small changes can affect a lot of people, these can be
very heavy considerations.


I love developing in PHP, but there's no use trying to teach a pig to
sing If you work for a pig, then you gotta learn to grunt and just
use whatever they tell you to use.  Don't force a change that's going to
create a lot of problems, downtime, etc.


"Free" is only free if you either don't have anything already or you
have coders and servers that are already in-line with the new plan.  If
you take a bunch of ASP programmers and force them to learn PHP, then
you have a learning curve, code porting and other things that can cost
the company money and possibly create downtime or project delays.  This
makes Apache + PHP changover hardly "free" to the company.

-TG


> -Original Message-
> From: Norland, Martin [mailto:[EMAIL PROTECTED] 
> Sent: Monday, November 15, 2004 11:29 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] PHP vs ASP
> 
> 
> >From: Perry, Matthew (Fire Marshal's Office)
> [mailto:[EMAIL PROTECTED] 
> >I need some ammo to convince my boss not to use ASP but use PHP
> instead. 
> >
> >Anyone have some info I can give him?
> 
> If you want us to give you live ammo instead of blanks, we'll 
> need more
> details on your setup.  There is a possibility that you should use ASP
> instead of PHP, albeit slim.
> 
> Things like:
>   What languages the coder(s) already know
>   What code is already in place
>   What kind of interfacing will you be doing (what data sources,
> etc.) if any
>   What type of server it's running off
>   Etc.
> 
> You can certainly start off with apache+php is going to be 
> cheaper than anything else (assuming you or someone else know the
> particulars already).  It's no longer the case that bosses will
> complain that "if you leave no one can maintain it!" - PHP is
> definitely here to stay and pretty mainstream.

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



RE: [PHP-DB] Numeric question

2004-11-16 Thread Gryffyn, Trevor
$number = 0.5907;

Round($number,2);


YAY! 

:)

-TG

> -Original Message-
> From: Chris Payne [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, November 16, 2004 3:38 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Numeric question
> 
> 
> Hi there everyone,
> 
>  
> 
> Just a quick question, I'm having to calculate some values 
> from an existing
> database, but on some of the results I get (For example)
> 
>  
> 
> 0.5907
> 
>  
> 
> How can I limit the result to only 2 digits after the decimal 
> point with
> PHP?
> 
>  
> 
> Thanks
> 
>  
> 
> Chris
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.797 / Virus Database: 541 - Release Date: 11/15/2004
>  
> 

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



RE: [PHP-DB] password encryption

2004-11-18 Thread Gryffyn, Trevor
You can use PHP to handle the auth headers and all:

http://www.php.net/manual/en/features.http-auth.php


That might give you more flexibility than trying to dynamically set it
on the .htpassword and such.


There are a couple of ways to encrypt something.  You can do it in a way
that can be decrypted and checked against what the user entered.   Or
you can do a one-way encryption that uses the same method every time, so
someone enteres "dog" and it encrypts into "sdlkfj"..  If you do a
one-way encryption, there's no feasible way to turn "sdlkfj" back into
"dog" but if the user enters "dog" again, and you encrypt it the same
way, it'll always come out as "sdlkfj" which will match the one-way
encrypted string that you stored.

If you want to be cheesy, you can also use something like an MD5 has on
"dog" and get whatever it gets Then every time someone enters "dog"
it always ends up with the same MD5 hash.

The chance of two different strings having the same MD5 hash is very
very unlikely.

Anyway, some stuff to think about.  Good luck!

-TG

> -Original Message-
> From: Han [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, November 18, 2004 11:29 AM
> To: Bastien Koert; [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: [PHP-DB] password encryption
> 
> 
> Hello,
> 
> I'm having a real problem and wondering if anyone can help.
> 
> I need to set up htaccess ans htpasswd files to authenticate 
> users on my 
> system.
> I need to do it with PHP, but can't find a way of encrypting 
> the password so 
> it works.
> 
> I've used an online encrypter for testing the system, and 
> I've got the 
> .htaccess and .htpasswd files correct, but I need to programmatically 
> encrypt the password in my script then write it to the 2 files.
> 
> Han.
> 
> -- 
> 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] password encryption

2004-11-18 Thread Gryffyn, Trevor
Hah.. Because I figured it wouldn't be an accepted solution by "real
security" people. :)  I've used it too.  Also used the md5_file()
function to create a duplicate file scanner for my home PC.

The only problem with using MD5 or another one-way solution on a general
site that doesn't require super-security is that when people forget
their password, you have to do a "Click this to reset your password",
have it reset to something random, then have them change it when they
log in.  There's no "Send me my password" ability, which I find kind of
useful on general sites that make you log in (free registration and
such).

As for why you're in the direct mail.. I don't know.  I just did "Reply
all" to the original question and you must have been in it. :)

Just enjoy the love and stop complaining. Hah.

-TG

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, November 18, 2004 12:15 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] password encryption
> 
> 
> Quoting "Gryffyn, Trevor" <[EMAIL PROTECTED]>:
> 
> > If you want to be cheesy, you can also use something like 
> an MD5 has on
> > "dog" and get whatever it gets Then every time someone 
> enters "dog"
> > it always ends up with the same MD5 hash.
> 
> How is using MD5 cheesy?  I've implemented exactly that 
> solution a number of times.  Admittedly, only for a very
> small site, mainly as the 'site content update' password.
> 
> -P
> 
> ps. and on another note, why am I in the list of direct 
> addressees here?

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



php-db@lists.php.net

2004-11-19 Thread Gryffyn, Trevor
How are you storing the file in your PHP code?

If it'll fit in a variable, it should be able to be stored in $_SESSION.

This might mean using serialize() and unserialize().

Although someone may have a better way of doing this.  It seems to me
that storing an entire file in a variable is going to be cumbersome on
your server.  You might try storing the file name and path or something:

C:\somepath\somefilename.ext


Someone probably has a better way to do this, but those are my initial
thoughts.. Without much experience having to do something like this with
files and without knowing more about your situation.

-TG



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 19, 2004 11:46 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Question on Files&Sessions
> 
> 
> Can you hold a file in a session?   I am trying to send a 
> file to a third page and it won't seem to work sending
> it in a session.   Does anyone know how to do this?
> 
> Thanks
> 
> 
> Kathy A Wright | Keane Inc. | Suite: 
> Outside: 617-517-1706 | E-mail: [EMAIL PROTECTED]
> [ Mailing: 100 City Sq.  Charlestown, MA 02129 USA ]
> 

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



RE: [PHP-DB] Currency and number types...

2004-11-19 Thread Gryffyn, Trevor
You might try this:
http://us2.php.net/manual/en/function.money-format.php

Money_format()

In your database query, you can probably format the number how you want
there too... Before you even get to PHP and round()ing it inside PHP.
But do your math and using the money_format() function to display it
should work just fine I think.

-TG

> -Original Message-
> From: Mark Benson [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 19, 2004 12:36 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Currency and number types...
> 
> 
> I'm trying to display data calculated by my script as a 
> currency. The problem I have is that PHP is treating the 
> results of the math as a 'float' number (or 'double') so I am 
> getting results like:
> 
> 12.0594393
> 
> in my table. I have tried using:
> 
> print round($foobar,2)
> 
> but that cuts off the trailing zero on numbers that comne out 
> as, for example '12.10' or '12.00'.
> 
> Does anyone know a way to force PHP to print numbers to a set 
> number of significant figures (i.e. 2) and stop the trailing 
> zero suppression?
> 
> -- 
> Mark Benson
> 
http://homepage.mac.com/markbenson

-- 
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] Currency and number types...

2004-11-19 Thread Gryffyn, Trevor
Either way. :)

> -Original Message-
> From: Joseph Crawford [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 19, 2004 12:48 PM
> To: Gryffyn, Trevor; [PHP-DB] Mailing List
> Subject: Re: [PHP-DB] Currency and number types...
> 
> 
> how about good old number_format()
> 
> -- 
> Joseph Crawford Jr.
> Codebowl Solutions
> [EMAIL PROTECTED]
> 
> For a GMail account
> contact me OFF-LIST
> 

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



RE: [PHP-DB] Optimize Query Output

2004-11-22 Thread Gryffyn, Trevor
To say that your query is "never going to look like that" isn't entirely
true.  I'm sure with enough CASE statements and the use of some
variables and such you could get your SQL output to look like that.  SQL
is pretty powerful like that.

BUT..  Everyone who said "Use PHP to filter/display the data" is
correct.  That's probably the preferred method of accomplishing this
goal.  It's how I would do it at least.  I don't think SQL is the best
for  doing custom display of data, you just need to learn what data
you're getting back from the SQL statement and what you need to do to it
in order to get the information that you need and display it how you
want to.

Someone else mentioned the "Group By" not containing one of the fields,
that's a good call, but I'm wondering why "Group By" is used here at
all.  There are no aggregate functions like SUM or MAX or anything, so
Group By isn't needed.   If for some reasons you were getting duplicate
records, the Group By would elimate them (I believe) in this case, but a
SELECT DISTINCT ...  Would do the same thing.

Actually, Group By wouldn't need to contain any/all of the SELECT fields
because there's no aggregate, so you can probably do any number of the
SELECT items in the Group By without an error.  No aggregate means no
Group By required so you could do one, three, fifty items.. Doesn't
matter.  Shouldn't produce an error, it'll just do a selective DISTINCT
instead of a total DISTINCT.

Sounds like GH thinks that "Group By" is a function that will create the
output that he's looking for.  It's not really used for that.  It's used
for telling SQL how to group data that's not part of the MAX or SUM or
AVG or other aggregate functions.

If you did:

SELECT A.`AttID` , MAX(S.`SessionDate`) , P.LastName, P.FirstName,
A.`Present`
FROM `Attendance` A, Sessions S, Participants P
WHERE S.SessionID = A.`Session` AND P.Part_ID = A.`Participant`
GROUP BY A.`AttID`, P.LastName, P.FirstName, A.Present, A.AttID

This will give, for each name and unique SessionDate, you one AttID, one
Last Name, one First Name, one Present... All for the latest
SessionDate. Because we're looking at the max SessionDate (greatest
value) and returns the info for that date value.

If someone attended more than one Session on the same day, it'll return
more than one line for that person with different AttID's.

Just some random thoughts.

-TG

> -Original Message-
> From: John Holmes [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, November 20, 2004 10:22 AM
> To: GH
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Optimize Query Output
> 
> 
> GH wrote:
> > I have the following query:
> > 
> > SELECT A.`AttID` , S.`SessionDate` , P.LastName, 
> P.FirstName, A.`Present`
> > FROM `Attendance` A, Sessions S, Participants P
> > WHERE S.SessionID = A.`Session` AND P.Part_ID = A.`Participant`
> > GROUP BY P.LastName, P.FirstName, A.Present, A.AttID
> > 
> > I would like to have the output to have the P.LastName and 
> P.FirstName
> > values only shown once and the rest of the output printed...
> > 
> > So instead of something like:
> > 
> > | 1 | 2004-10-30  | Apple | Robert  | Yes |
> > |11 | 2004-11-06  | Apple | Robert  | Yes |
> > 
> > To have it look like:
>  >
> > | Apple | Robert S. | 1 | 2004-10-30  | Yes |
> > |   |   |11|  2004-11-06 | Yes |
> > |   |   |31|  2004-11-13 | Yes |
> > | Bravo | Luz   | 2 | 2004-10-30  | Yes |
> > |  | |32|  2004-11-06 | No |
> 
> Your query is never going to look like that. You use PHP to 
> format the result set so it displays how you want it. As you
> loop through the returned rows, keep track of what the current
> first and last name are. 
> If they change, then output them, otherwise output a blank cell.
> 
> -- 
> 
> ---John Holmes...

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



RE: [PHP-DB] Client username

2004-11-22 Thread Gryffyn, Trevor
First of all, some people may give you a hard time because this isn't
really a database related question.  You're better off asking questions
like this on PHP General or even PHP Windows if it's windows specific.

Also..  You need to specify whether you're talking about a Windows login
to a domain, a local windows login (which version of Windows also?), or
something un*x based?  There are big differences in how they're all
stored and if they're accessible at all.  Also, it's worth noting,
especially in the case of Windows, if the client machine is in the same
domain as the server PHP is running on.


If you have a Windows domain set up, your server is on that domain (or
you have some kind of authentication passthrough to that domain.. I
think there's a way to do that between domains) and the computer that
someone is hitting the PHP server with (the client machine) has a user
logged into the same domain, THEN.. You at least have one option.

If you use NTLM or the NT Challenge/Response type authentication on your
webserver, then the web server will request auth information from the
client's web browser.  This will show up in the $_ENV["AUTH_USER"]
variable as well as the $_ENV["LOGON_USER"] variable.

You can test to see if this is already active by checking your phpinfo()
for your current login.


I believe you have to turn OFF anonymous and basic authentication on the
web server to get this to work though.  But maybe that'll give you
enough to Google for the rest of the info.

If you're talking about a Windows login on a client machine that's NOT
on the same domain or where the user is logged into the local machine
and not the domain, then I think you're out of luck.

I'm not sure how you'd do it through un*x logins.

Good luck!

-TG

> -Original Message-
> From: Ganesh Babu Nallamothu, Integra-India 
> [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, November 16, 2004 10:22 AM
> 
> Hi all,
> 
> How to find the login name of client machine in php?
> 
> Regards,
> Ganesh

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



RE: [PHP-DB] how to implement "pages" of results

2004-11-24 Thread Gryffyn, Trevor
Off the top of my head, doesn't LIMIT accept two paramters?

Can't you do:

LIMIT 30,2

That'd give you page 2 of a 30+ record result set, right?


Using that, you can pass a page # when you click "next page" so previous
page ends up being current page - 1 (and "if that is less than 1, then
it equals 1... And if it's > recordcount / 30 + 1, then it equals
recordcount / 30 + 1)

Try working checking into that.

-TG

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, November 24, 2004 3:20 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] how to implement "pages" of results
> 
> 
> Hi,
> 
> I'm sure this is a common question, so please forgive if it's 
> been posted before.
> 
> I have a select statement that selects records from a table:
> "select * from $table where host='$somename'"
> 
> I then propagate a table with the returned data.  My goal is 
> to only display 30 records per "page", with links on each 
> page that take the user to the next and previous 30 records.  
> I have played around with using "limit", but this seems to 
> only get me the next 30.  How to achieve the previous 30?  It 
> would be easy if the records returned were sequentially 
> numbered...but, since I'm being selective in which records I 
> return (host=$somename), this is not the case.  The first row 
> may be 1, and the second row may be 10, etc.
> 
> Anyone have any ideas on how to solve this?
> 
> Thanks!
> 
> -- 
> 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] how to implement "pages" of results

2004-11-24 Thread Gryffyn, Trevor
Oh yeah..   LIMIT 30,2  would show 30 records starting with the second
record.  I knew I was forgetting something.  Sorry for the
misinformation.  Trying to finish some stuff before leaving for the
weekend, but wanted to at least give you a nudge before disappearing.

Good luck!

-TG

> -Original Message-
> From: Norland, Martin [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, November 24, 2004 3:38 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] how to implement "pages" of results
> 
> 
> Basic example: (handwritten in email client, syntax errors may exist)
> 
> if (!isset($pagenum) || $pagenum < 0) { $pagenum = 0; }
> $range = 30;
> $start = $range*$pagenum;
> $end = $start + $range;
> $limit = " limit $start, $end";
> $query = "select * from $table where host='$somename'$limit";
> 
> Then just pass the pagenum around.  You'll probably want to 
> pull another
> query that just gets the count(), and use that and some basic math to
> make the page range(s) to create hyperlinks.
> 
> Cheers.
> 
> - Martin Norland, Database / Web Developer, International 
> Outreach x3257
> The opinion(s) contained within this email do not necessarily 
> represent
> those of St. Jude Children's Research Hospital.
> 
> 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, November 24, 2004 2:20 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] how to implement "pages" of results
> 
> 
> Hi,
> 
> I'm sure this is a common question, so please forgive if it's been
> posted before.
> 
> I have a select statement that selects records from a table: "select *
> from $table where host='$somename'"
> 
> I then propagate a table with the returned data.  My goal is to only
> display 30 records per "page", with links on each page that take the
> user to the next and previous 30 records.  I have played around with
> using "limit", but this seems to only get me the next 30.  How to
> achieve the previous 30?  It would be easy if the records 
> returned were
> sequentially numbered...but, since I'm being selective in 
> which records
> I return (host=$somename), this is not the case.  The first row may be
> 1, and the second row may be 10, etc.
> 
> Anyone have any ideas on how to solve this?
> 
> Thanks!
> 
> -- 
> 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] fatal error

2004-11-29 Thread Gryffyn, Trevor
What version of PHP are you using?   Did you develop it on one system
then move it to 'production' and now it doesn't work?

PHP 5 has SQLite functions built into it, but PHP 4 doesn't (I think I
got that right).  You may need to make sure your extensions are loading
properly and such.

Is it just that one script that's failing or is ALL of your SQLite stuff
failing now?

Check your PHP version and your phpinfo() to make sure your extensions
are loading correctly.  After that, I'm not sure.

-TG

> -Original Message-
> From: Aravalli Sai [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, November 27, 2004 3:47 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] fatal error
> 
> 
> i had created an inventory management system in php using 
> sqlite DB..with ADD,DELETE,UPDATE,VIEW,FIND functions...and 
> it was working properly..but suddenly it is giving an error as
> Fatal error: Call to undefined function: sqlite_open() in 
> /home/saravall/.HTML/view.php on line 25
> 
>  
> can anyone figure out  the error..
>  
> thanks in advance..
>  
> --regards
>  
> 
>   
> -
> Do you Yahoo!?
>  Read only the mail you want - Yahoo! Mail SpamGuard.
> 

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



RE: [PHP-DB] Is there any replication service for MySQL?

2004-11-29 Thread Gryffyn, Trevor
http://dev.mysql.com/doc/mysql/en/Replication.html

Check this page, it might be helpful.

-TG

> -Original Message-
> From: Sadeq Naqashzade [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, November 27, 2004 11:51 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Is there any replication service for MySQL?
> 
> 
> Hi all,
> Do you know any replicator server to synchronize database on local
> server with my web server?
> 
> Sadeq Naqashzade Yazdi

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



RE: [PHP-DB] Multi-User Update Problem

2004-11-29 Thread Gryffyn, Trevor
Yeah, all good thoughts.  Someone else had a similar question that I
answered recently (I think it was in private email) and in addition to
the thoughts below, you might also look into recording WHEN the record
was opened (and locked) so you can expire the lockout.  I'd use this in
conjunction with a browser side META REFRESH and a PRAGMA cache expire
command so if the person who opened the record doesn't do anything with
it within 2 hours, their browser auto-refreshes (maybe notifying them
that their session was terminating and if they want to save the work
they've done already) and it unlocks the file.

You could also have a nightly job run that looks for all records locked
over 2 hours ago or something and auto-unlock them (or just have the
script that looks to see if something's locked see if it was over 2
hours ago and ignore the Locked == TRUE tag in the database).


Anyway, the idea is to expire the session and user's cache so that
they'll get a "Warning: Page Expired" making it impossible for them to
update something after 2 hours has passed or something like that.  Also
to free up locked pages on a regular basis or allow people to get into
them again if they "time out".

-TG

> -Original Message-
> From: Bastien Koert [mailto:[EMAIL PROTECTED] 
> Sent: Monday, November 29, 2004 10:22 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Multi-User Update Problem
> 
> 
> Its a tough one. My personal fav is to mark the record as 
> locked by changing 
> a field called 'locked' from 0 to 1. Check for this when 
> extracting the 
> record and if is present, alert the user this record is 
> locked (if you want 
> to get fancy you could even track who locked it and the tell 
> the user that) 
> and show a non-updatable form of the page (either with the fields as 
> readonly or by creating some kind of view only page where the 
> data is simply 
> echoed out). If you want to get REALLY out there, you could track who 
> requested the locked record and notify them when it was 
> released(by the 
> original requestor submitting the form). The possibilities are endless
> 
> The other option is to create/write an entire concurrency 
> module that will 
> store the record in a separate entity (another table or 
> session object)  and 
> then compare any changes made upon submission. I have seen 
> this but I don't 
> really like it, since the ultimate choice is left to the user 
> as to what 
> data is correct.
> 
> 
> 
> Bastien
> 
> >From: "SCALES, Andrew" <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: [PHP-DB] Multi-User Update Problem
> >Date: Mon, 29 Nov 2004 11:16:08 -
> >
> >Hello,
> >
> >Does anyone know a good way of locking out access to a 
> record on a MySQL
> >database when someone has the update page open?
> >The problem is that we have a local intranet site which is 
> accessed by
> >members of different departments. Now at the moment when 
> someone loads the
> >page all of the data is pulled into the form, and then when 
> they submit, 
> >all
> >of that data is passed back to the database, including anything they 
> >haven't
> >changed.
> >
> >What we are trying to avoid is situations where for example 
> someone leaves
> >the form open on their computer and goes away for lunch. In 
> the meantime
> >someone else at a different station makes changes to the 
> form. Then when 
> >the
> >first person comes back from lunch, they submit the form, 
> thereby writing
> >over all of the second person's changes with the old data.
> >
> >Does anyone know of a good way to solve or work around this 
> problem? We 
> >have
> >thought about setting a flag on the database whenever 
> someone pulls down 
> >the
> >data, however if their browser crashes or they shutdown with 
> the window 
> >open
> >then this is going to leave the data locked.
> >
> >Thanks very much,
> >
> >Andy

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



RE: [PHP-DB] Excel - merging cells with PHP

2004-11-29 Thread Gryffyn, Trevor
You can also do a "Click here to download", send it headers identifying
the the page being loaded as something like "application/Excel" or
whatever the mime type is and pass it HTML.  Excel will interpret it and
load the data into cells.

That gets around the whole COM thing.

If you do that, then doing a rowspan or colspan should "merge" cells:



Some merged data in col1 and col2
Column 1Column 2



Also, I've run into problems with HTML in Excel sometimes using 's
or something where I didn't use a colspan or rowspan and it put things
into new cells.  I think it was with 's at least.  It was an
annoyance to me but you might use that to your advantage.

With COM, you'd select a range then use the "Merge" method.

In VBA, it's:

Range("A1:A4").Merge

I'm rusty on my PHP COM + Excel stuff.

Or you can just look into the PEAR stuff that Martin recommended
(probably your best bet).  :)

-TG

> -Original Message-
> From: Bastien Koert [mailto:[EMAIL PROTECTED] 
> Sent: Monday, November 29, 2004 10:24 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Excel - merging cells with PHP
> 
> 
> You would need to access the XL sheet via the COM interface 
> (don't know how 
> are doing currently) and then work out the macros or commands 
> to pass to the 
> XL sheet to have it do the things you need.
> 
> Bastien
> 
> >From: "Perry, Matthew (Fire Marshal's Office)" 
> <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: [PHP-DB] Excel - merging cells with PHP
> >Date: Mon, 29 Nov 2004 08:48:52 -0600
> >
> >When you export a table to excel, is there a way to merge 
> cells and create
> >borders?  I want my excel file to look exactly like my html 
> table looks.
> >
> >
> >
> >Matthew Perry

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



RE: [PHP-DB] Multi-User Update Problem

2004-11-30 Thread Gryffyn, Trevor
You could always lock a record and only allow that user to see the
locked files (maybe showing an icon indicating that it SHOULD already be
checked out in another browser window and ask if the user still wants to
open the file (in the case of a computer crash or they closed their
browser without properly checking the file back in, etc).

Keeping hits on a database to a minimum is a good goal, but databases
are meant to be used and abused too.. So don't be afraid to do a little
select or update from time to time.   It's when you do things like
"select * from MillionRowTable" repeatedly that you have issues. :)

Good luck!

-TG

> -Original Message-
> From: SCALES, Andrew [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, November 30, 2004 9:45 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Multi-User Update Problem
> 
> 
> Thanks very much for your help. The main difficulty I was 
> having really was
> unlocking the record again if the user crashed out or just 
> closed down their
> browser/computer (something they have a bad habit of doing) 
> but storing the
> time the record was locked and ignoring the lock if it's over 
> that time
> sounds interesting.
> I may try storing the data in a session variable and then 
> comparing that to
> the database before the updated data is inserted into the 
> record as Bastien
> suggested. We wanted to keep hits on the db to a minimum, but 
> seen as some
> extra traffic will be necessary anyway I may just try that.
> 
> Thank you both for the advice,
> Andy

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



RE: [PHP-DB] [PHP-DEV] KEYBOARD

2004-12-01 Thread Gryffyn, Trevor
If the touch screen emulates a mouse, then you could do something in
HTML + Javascript. It wouldn't have anything to do with PHP, just a
mouse driven entry page in HTML.  You could put Internet Explorer (or
most other browsers) in "kiosk mode" (aka "full screen mode") to hide
the fact that it's in a browser (and hide the OS behind it).

If you wanted to create a non-web server and HTML based solution, then
the two main GUI's available for PHP would be GTK (multi-OS but ugly I
think, http://gtk.php.net/) and Winbinder if you want Windows-native GUI
functionality (http://winbinder.sourceforge.net).

I've been a big fan of Winbinder since I saw the initial announcement
and finally got a chance to check it out this weekend. Great stuff!
Even though it's on "version 0.31 pre-alpha", it should be stable enough
to create an on screen keyboard that lets you enter data its own window.

You could probably get it to send keypresses or raw data to other
applications using one of the following:

1. COM - for interprocess communication in Windows
2. php_ffi - For loading 'foreign' DLLs
(http://pecl.php.net/package/ffi)
3. DDE - Dynamic Data Exchange in Windows (sorry, can't find a good
example quickly.. I've seen some things with PHP talking to WinAmp which
I believe was through a DDE call, but maybe I'm getting it confused with
something else)

DDE and COM let you talk directly to an application and give it
commands.  Loading a DLL might let you do the same thing.

Just some thoughts.  It's probably easiest to either do the HTML +
Javascript or do the Winbinder or GTK method.  But it all depends on
what you need.

Good luck!  Let us know what you end up doing.

-TG

> -Original Message-
> From: balwantsingh [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 01, 2004 4:09 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] [PHP-DEV] KEYBOARD
> 
> 
> May pls. help me.
> 
> Can anybody guide me whether virtual keyboard can be made using PHP.
> Actually i am developing a site for our internal use where we 
> will not give
> keyboard to user, the data can be entered by help of 
> touchscreen pasted on
> the monitor.
> 
> with best wishes
> balwant

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



[PHP-DB] Basic JOIN tutorial - RE: [PHP-DB] Job interview test - I give up...

2004-12-01 Thread Gryffyn, Trevor
Looks like you got a lot of good responses.  I downloaded the zip file
but then got slammed with some priority stuff and havn't had a chance to
take a look at this.  So in the interest of not forgetting and of
closing this reply window :)  just a quicky response.

I had a lot of trouble initially wrapping my brain around JOINs
conceptually but they're really rather easy.  Here's my 2 cent tour
(because most of the documentation I read didn't really put it in "plain
english").  Someone please correct me or add to what I've said if it's
not accurate:

Inner Join - This is when you have two tables and the items in the ON
clause need to exist in both tables for you to get a row returned.
Doing a " a INNER JOIN b ON somecriteria " is functionally the same as
doing "from a, b where somecriteria"   Maybe there's a performance
difference, maybe only on certain database systems, not sure.  They
should return the same output:

SELECT trucks.truckid, crates.crateid
FROM trucks INNER JOIN crates ON trucks.truckid = crates.truckid

Should be the same as...

SELECT trucks.truckid, crates.crateid
FROM trucks, crates
WHERE trucks.truckid = crates.truckid

This will return all trucks that have crates on them.  If a truck is
empty, it doesn't show up on the list.


Outer Joins - This is where you know you have items in one table, but
may or may not have items in another table.

SELECT trucks.truckid, crates.crateid
FROM trucks LEFT JOIN creates ON trucks.truckid = crates.truckid

This should give you a list of all trucks, even empty ones, and their
associated crates (if there are any.. If no crates are on the trucks,
then an empty cell is returned for 'crateid'.

SELECT trucks.truckid, crates.crateid
FROM creates RIGHT JOIN trucks ON trucks.truckid =
crates.truckid  

This should return the same thing.   The LEFT or RIGHT "points" to the
table that definitely has rows, the other table will show empty (NULL)
cells if there are no matches.


I believe there's a join that will show NULLs in either column if
there's no match, but I don't know what it is off the top of my head.
Anyone know this one?


Also, some systems like Oracle, let you do shorthand like:

SELECT trucks.truckid, crates.crateid
FROM creates, trucks
WHERE trucks.truckid = crates.truckid(+)

(this syntax is probably wrong).  It uses a (+) in the WHERE clause to
indicate the join.  Microsoft SQL-Server has some kind of shorthand way
to do this as well, but it's documented as "never having worked
properly" so I'd recommend not using it.

To me, the Oracle shorthand is much more intuitive, but once you get the
hang of the LEFT JOIN type syntax, it's not too bad.


One last note, you can JOIN on multiple tables, you just need to wrap
everything in parentheses.  It gets a little sticky, but work from the
inside out and keep an image in your head of what's going to be returned
by each layer and join accordingly.


If you have Microsoft Access or something else that graphically lets you
create queries, you might try building a query that you know works and
returns what you need, then looking at the SQL VIEW to see how the
syntax goes.  It can help you understand how to do the raw SQL yourself.


Good luck!

-TG



> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 01, 2004 8:14 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Job interview test - I give up...
> 
> 
> I recently saw a job that I thought I'd be good for, so they 
> sent me a 
> test...
> All good.. but I realised that I couldn't do it..
> I got sooo damned close, but could not finish... :-(
> 
> Anyhoo, here's the test:
> http://www.beertastic.co.uk/test_problem.zip
> 
> And the test parameters are below
> If anyone can tell me the answer, I'd appreciate it, then I can 
> de-engineer it, and hopefully learn something.
> I've already mailed them and said thanks, but I give up ;-)
> 
> I my prob was in gettin ga distict list of all DVD 
> categories, from within 
> the final results page...
> 
> Hmmm, any takers?
> 
> TASK:-
> 
> Modify the test.php file (attached) so a list of categories and the
> number of DVDs in each category are displayed when the script 
> is called
> in a browser. (See resultspage.html for the EXACT output required)
> 
> You must complete the getNumDvdsInCategories() function to query the
> database and return a multidimensional array in the required format.
> 
> You may use the PHP and MySQL manuals available online.
> 
> 
> RESTRICTIONS:-
> 
> You may only make ONE select query to the database.
> Do not edit code outside the getNumDvdsInCategories() function. The
> results in the table must be in alphabetical order (category 
> name). The
> Drama category MUST appear even though there are no DVDs in the
> category. Categories beginning with the letter "T" must not be
> displayed. Values in the database cannot be hardcoded anyw

RE: [PHP-DB] Use of 'as' name in where sub-clause

2004-12-01 Thread Gryffyn, Trevor
Yeah, I've asked this question myself a million times.  It'd be very
useful and maybe some DB system knows how to do this, but for the most
part you just have to deal with this reality.

I believe that it's a matter of timing, really.  You can't use the alias
in the WHERE clause because it hasn't been created yet.

I believe everything is evaluated and executed then when it comes to the
final output, it uses the aliases as column headers (if no alias is set,
it'll use the column name... Unless it's an aggregate function, then it
uses nothing.. Which doesn't work well when you do a sub-select as a
table.. But that's another story).


What you COULD do, although it can add a little (or a lot) of overhead
to your query:

SELECT total FROM (SELECT (sales * cost) as total FROM
sometable) t1 where t1.total > 100


There may be some cases where you'd want to do this, but be aware that
it most likely executes like this:

1. Performs the SELECT (sales * cost) query on ALL rows in the
database.. If you have a million rows and only 10 of them have sales *
cost > 100, it's going to be a major drag on your system to get those 10
rows.   It MAY have perform the function on all rows anyway since it's a
math function.   So this is "maybe" a drain if you do it as "WHERE
(sales * cost) > 100" but it's definitely a drain if you do it with the
sub-select I used above.   Also, not sure, but if you're using MySQL,
I'm not sure that it supports it below version 4.1 (or was that another
database I worked with recently?  I forget).

2. After performing the "total" on everything, then it evaluates the
"SELECT total... WHERE t1.total > 100" on the result set.  It treats the
sub-select as if it were a table, using it's results to select from.


Some just DB trivia for ya.  If you figure out a way to use an alias in
your WHERE clause without doing a sub-select, let me know. :)

-TG


> -Original Message-
> From: Ross Honniball [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 01, 2004 4:54 AM
> To: php DB
> Subject: [PHP-DB] Use of 'as' name in where sub-clause
> 
> 
> Hi All,
> 
> In MySql, you CAN'T do the following:
> 
> SELECT sales * cost AS total WHERE total > 100
> 
> Instead, you need to say:
> 
> SELECT sales * cost AS total WHERE sales * cost > 100
> 
> 
> I'm just curious WHY you can't do it. You can, for example, 
> specify ORDER 
> BY total.
> 
> I can't think of any reason why it would be either difficult 
> or ambiguous 
> for the SQL engine to allow you to use your calculated field 
> name in the 
> WHERE part of the query.
> 
> If someone can give me a good reason why this is so, it will stop it 
> annoying me so much.
> 
> Regards ... Ross
> .
> . Ross Honniball. JCU Bookshop Cairns, Qld, Australia.
> .
> 
> -- 
> 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] Question on the use of where statements

2004-12-01 Thread Gryffyn, Trevor
I think you may hit the limit on the number of characters in the SELECT
statement before you hit the max number of WHERE items.

It's a good question though.Try doing a worst case scenario (pick
all the options, enter data that's the max character length for each
item, etc).  Either through your form or typing it all manually.  The
worst that'll happen is it'll say "Sorry.. Too many characters" or "Too
many WHERE items" or something.

Also, check the documentation for the database system you're using
(MySQL or whatever) and see if it says anything under the WHERE clause
or max length of SELECT statement.

If you find anything interesting, let us know.  Sorry couldn't give you
a better answer.

-TG

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 01, 2004 10:56 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Question on the use of where statements
> 
> 
> --- Bastien Koert <[EMAIL PROTECTED]> wrote:
> 
> > so...best to build the statement dynamically and
> > execute it once only if the 
> > input box has a value in it...
> > 
> 
> And that is the way I'm building it.  Just thinking
> about the scenario that somone actually chooses 75% of
> the options - would that potentially make a huge hit
> on the system.
> 
> Stuart

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



RE: [PHP-DB] getting data back when inserting

2004-12-01 Thread Gryffyn, Trevor
I know this is only semi-helpful, but maybe it'll give you a kick in the
right direction.

In Microsoft SQL-Server you'd use @@IDENTITY to get the ID of the last
row you inserted.  There's bound to be something similar in other DB
systems.  "identity" is what SQL Server calls auto-number type fields,
fyi.

One thing to watch out for...  Make sure you're getting your 'local'
auto-number and not a global one.  If your script inserts something, and
someone else's script (or a different user using your script) inserts
something else, THEN you snag the ID, you could get the other user's
auto-number ID instead of the one you just inserted.

If you make sure you're getting the 'local' ID, then it'll always return
the last one that you inserted.


Another note is that usually 'local' ID is determined by database
connection session.  If you use something like ADOdb (or another
abstraction layer... Or just in general), make sure you're getting the
ID before you close your connection to the database.

Thought that could be helpful even if not specific to MySQL, the
concepts and caveats should be similar.

-TG

> -Original Message-
> From: Aaron Todd [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 01, 2004 11:01 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] getting data back when inserting
> 
> 
> I was wondering if somone might be able to suggest a command 
> to me...I am 
> inserting data into a MySQL database that has an 
> auto-incrementing primary 
> field.  When I insert the data I would like to somehow get 
> the value of the 
> auto-incrementing primary field.  I thought I could just run a SELECT 
> statement on some of the data that I am inserting, but the 
> problem is that 
> it could have a duplicate already in the database.
> 
> Anyone know of a command or something to point me in the 
> direction I am 
> looking to go?
> 
> Thanks,
> 
> Aaron 
> 
> -- 
> 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] 5 hours later - sql error.

2004-12-02 Thread Gryffyn, Trevor
Looks like your $expLevl value is empty.  It's probably set, but has no
value in it.  Check that.

-TG

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 02, 2004 1:46 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] 5 hours later - sql error.
> 
> 
> I'm running into a syntax error:
> 
> You have an error in your SQL syntax. Check the manual
> that corresponds to your MySQL server version for the
> right syntax to use near ') AND Prof.WorkExp IN () AND
> Prof_Industries.
> 
> Now I printed out the query and that works as I dumped
> it into a mysql client and it returned correctly.
> 
> Maybe I can get by here with out all the code. 
> Basically I do a select of all the tables, then the
> joins.  No where condition yet.  This is a dynamic
> query - 
> 
> After the sql I have 
> 
> $aWHERE = array();
> 
> if(isset($resAge)) $aWHERE[] = "Prof_Rez.Age >=
> DATE_SUB(CurDate(), Interval($resAge) DAY)";
> if(isset($workAuth)) $aWHERE[] = "Prof.WorkAuth IN
> ($workAuth)";
> if(isset($expLevel)) $aWHERE[] = "Prof.WorkExp IN
> ($expLevel)"; ..etc.
> 
> $query_rsCS .= ' WHERE '.implode(' AND ',$aWHERE);
> 
> Anyway while I basically took this code from a search
> that is working - what I wonder is if the where
> statement is correct .  
> 
> Well let me start here and see.
> Thank you 
> Stuart
> 
> -- 
> 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_fetch_assoc() bug with mysql 4.1 and fields escaping?

2004-12-02 Thread Gryffyn, Trevor
Funny, questions about MySQL 4.1.x seem to be popping up a lot recently.  With 
good reason.  There are some changes that make old mysql_*() functions not work 
anymore.   I don't know all the ins and outs yet, but I ran into it last 
weekend and everything I saw seemed to recommend switching to the Improved 
MySQL Functions:

http://www.php.net/manual/en/ref.mysqli.php

It is definitely supposed to help with being able to connect and log into the 
database since the new password hashing scheme is incompatible with the old 
MySQL standards.  It might help you with this other stuff too.

Good luck!

-TG

> -Original Message-
> From: Clément MOULIN [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 02, 2004 7:55 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] mysql_fetch_assoc() bug with mysql 4.1 and 
> fields escaping?
> 
> 
>  
> Hi,
>  
> We have recently upgraded our mysql server from 4.0.X to 4.1.7.
> But now, the mysql_fetch_array() & mysql_fetch_assoc() 
> doesn't work anymore
> when escaping fields names like that:
>   SELECT `name` FROM `db`;
> mysql_fetch_assoc() returns a associative arrays, but not 
> with good key
> names (somes binary characters like square character or 
> '#B'...), and some
> lines are missing.
> 
> With: SELECT name FROM `db`;
> It works fine... But sometimes we _really_ need to escape field name.
> 
> Running php 4.3.9. Is it a known bug?
>  
> --
> Clément Moulin
> SimpleRezo - Simplifiez-vous le réseau !
> Tél.: +33 871 763 102 - Web: http://www.simplerezo.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