Re: [PHP-DB] Is this redundant? {OT}

2003-10-06 Thread David Smith
Robin Kopetzky wrote:

Good afternoon.

I found this code in a program I'm renovating and think this is very
redundant. Also, it does slow queries down while doing all of the
conversions.
prod_id in the mysql database is declared an integer.


where prod_id = '" . (int)$prod_id . "' and

Question: since $prod_is is already an integer, why would someone convert it
into an integer, then convert it into a string to later have mysql convert
it back into an integer?? Could someone shed some light on the intent behind
this weird code??
This is most likely a security measure and not redundant at all. Even if 
someone tries to "inject" malicious SQL into $prod_id, this code will 
cast it as an integer, discarding any non-numeric characters. For 
example, if $prod_id is "42; drop database foo;", that would be very 
dangerous. With the (int) cast, $prod_id will simply be cast to the 
integer 42. A good idea in my view.

--Dave

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


Re: [PHP-DB] stripping carrige returns with SQL

2003-09-26 Thread David Smith
If you are trying to replace the carriage return it needs to be \r
instead of \ n in your query. Also it may not work because in my
experience the replace function under mysql does not replace them in the
db but in the query results. If you are looking to replace them
permanently you will need a script to do that. I have one if that is
what you want to do.
David
On Fri, 2003-09-26 at 12:50, [EMAIL PROTECTED] wrote: 
> I have a query that is pulling user comments, supplied by via web
> internface and creating a text file out of them.  In these comments are all
> sorts of carrige returns.  I've tried stripping them out with the following
> queries, but once imported into excel, the carrige returns are still there.
> so obviously i'm doing something wrong
> 
> I tried doing with the ASCII number .(no idea if this is valid)
> 
> SELECT Business_Unit.Business_Unit, Category.Category_Name,
> REPLACE(Comment_Original, ASCII(10),ASCII(32)) FROM `Comment` INNER JOIN
> Cat
> egory ON Comment.Category_ID = Comment.Category_ID INNER JOIN
> Survey_Response ON Comment.Survey_Key = Survey_Response.Survey_Key INNER
> JOIN Business_Unit ON Survey_Response.BUKey = Business_Unit.BUKey WHERE
> Comment_Original <> ' ' AND Category.Category_Name IS NOT NULL GROUP BY
> Business_Unit.BUKey, Category.Category_Name, Comment_Original ORDER BY
> Business_Unit.BUKey, Category.Category_ID ASC INTO OUTFILE
> '/export/home/jdyke/comments_NoB.csv' fields terminated by ',' OPTIONALLY
> ENCLOSED BY '"' lines terminated by '\n';
> 
> Also with the escaped charatcer.
> SELECT Business_Unit.Business_Unit, Category.Category_Name,
> REPLACE(Comment_Original, '\n',' ') FROM `Comment` INNER JOIN Category ON
> Co
> mment.Category_ID = Comment.Category_ID INNER JOIN Survey_Response ON
> Comment.Survey_Key = Survey_Response.Survey_Key INNER JOIN Business_UnitON
> Survey_Response.BUKey = Business_Unit.BUKey WHERE Comment_Original <> ' '
> AND Category.Category_Name IS NOT NULL GROUP BY Business_Unit.BUKey,
> Category.Category_Name, Comment_Original ORDER BY Business_Unit.BUKey,
> Category.Category_ID ASC INTO OUTFILE '/export/home/jdyke/comments_NoB.csv'
> fields terminated by ',' OPTIONALLY ENCLOSED BY '"' lines terminated by
> '\n';
> 
> Is REPLACE the right SQL Function to use?  is there a better way to
> determine this character?
> 
> Thanks
> Jeff

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



Re: [PHP-DB] best" upload method

2003-09-13 Thread David Smith
If the destination for the uploaded file is on the same host as the web 
server, it will be several orders of magnitude faster to use the first 
method (move_uploaded_file()). Of course, you may have to reorganize 
your permissions to allow the web-server to write to the destination 
directory. If the destination for the uploaded file is on a remote 
server, you must use the second option, unless you want to get fancy and 
use NFS or something which allows the first method to function 
transparently.

With my limted knowledge (limited meaning "none") of your setup, I would 
recommend the first method for speed, ease of implementation, and 
reliability (what if the FTP server goes down?). If you cannot configure 
your file system permissions to allow the web server to write to the 
destination directory, then use the FTP option. Keep in mind that it is 
*very* slow to initiate an FTP transation, upload the file (to the same 
machine!) and then close the connection. Copying a file locally will be 
much faster, and probably more reliable.

Good luck.

--Dave

open-mind wrote:

Sorry but I didn't know which is the name of the first method
I will rephrase
which is the best method to upload a file to server ??
this:
//
$result =
move_uploaded_file($HTTP_POST_FILES['img_6']["tmp_name"],"dir/filename.jpg")
;
$result = $result ? "OK":"NOT OK";
print $result;

or ... this:
/
$conn_id = ftp_connect("$ftp_server");
$upload = ftp_put($conn_id, "$destination_file", "$source_file",
FTP_BINARY);
ftp_quit($conn_id);

how depends on the application ?

- Original Message -
From: "David Smith" <[EMAIL PROTECTED]>
To: "open-mind" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, September 12, 2003 9:04 PM
Subject: Re: [PHP-DB] best" upload method
 

which is the "best" upload file method ?
file uploads or FTP commands from PHP
 

Now that's the most open ended question I've read all day. Here, flip a
coin. If it falls heads, FTP. If it falls tails, the other one. Even
still, I'm not sure I understand the question: File uploads or FTP command
from PHP? One of your options is just the question restated...
Regardless and all sarcasm aside, this question depends seriously on the
application.
:)

--Dave

   

 

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


Re: [PHP-DB] best" upload method

2003-09-12 Thread David Smith
> which is the "best" upload file method ?
> file uploads or FTP commands from PHP

Now that's the most open ended question I've read all day. Here, flip a
coin. If it falls heads, FTP. If it falls tails, the other one. Even
still, I'm not sure I understand the question: File uploads or FTP command
from PHP? One of your options is just the question restated...

Regardless and all sarcasm aside, this question depends seriously on the
application.

:)

--Dave

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



Re: [PHP-DB] RH 8.0 Mysql help

2003-09-09 Thread David Smith
One comand and you are done:

   apt-get install mysql-server httpd php php-mysql

Don't have apt for RedHat? Download this:

   
http://ftp.freshrpms.net/pub/freshrpms/redhat/8.0/apt/apt-0.5.5cnc6-fr0.rh80.1.i386.rpm

and run 'rpm -i' on it. There's no better way to install software than 
apt. Prefer a graphical installer? Do this:

   apt-get install synaptic

Good luck!

--Dave

Robin Kopetzky wrote:

Would some kind soul who has installed MySql on a RH8.0 box please email me
(off list) and help me get this running?? I have installed it a dozen times,
followed the post-installation and testing from the Mysql manual and STILL
can't make this run. I need this for a e-commerce site like yesterday!!
Please help...

Robin 'Sparky' Kopetzky
Black Mesa Computers/Internet Service
Grants, NM 87020
[EMAIL PROTECTED]

 

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


Re: [PHP-DB] copy tables between db's

2003-09-07 Thread David Smith
David Smith wrote:

   insert into database1.tablename select * from database2.tablename;

database1 and database2 are the names of the two databases. tablename 
is the name of the table you want to copy from database1 to database2. 


Correction: from database2 to database1, not vice versa.

--Dave

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


Re: [PHP-DB] copy tables between db's

2003-09-07 Thread David Smith
Have you tried something like this:

   insert into database1.tablename select * from database2.tablename;

database1 and database2 are the names of the two databases. tablename is 
the name of the table you want to copy from database1 to database2. In 
your case I guess this would be:

   insert into database1.states select * from database2.states;

Good luck!

--Dave

Jeremy wrote:

I need to copy some tables from one mysql database to another mysql database
on the same server.
I looked at the php manual and couldn't find it...I found stuff on
mysqlhotcopy, but it doesn't look like that will do what I need it to do, or
maybe I'm reading the manual wrong.
Can someone please show me how to do this? To be specific, it's just a table
with a list of US states in it...
table name: states
fields: state_id, name, abbreviation
Thanks,

Jeremy

 

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


Re: [PHP-DB] how to recognize user login name?

2003-09-04 Thread David Smith

>> >I've tried to use $USERNAME variable but it isnt what i want because it
>> >recognize login name on server not remote user
>>
>> If you are referring to the Windows login name, this is not possible
>> with PHP via the web browser.
>
> Sure it is. It's usually in $_SERVER['LOGON_USER'] or something similar.

Well, if it *is* actually there in some strange case, you can find it like
this:

   ';
   print_r( $GLOBALS );
   ?>

This works great to discover the name of variables that are set by the
system.

I can imagine that the Windows login name will only be avaible in the
strictest of circumstances: IIS server, IE browser, in a domain setup or
something. Good luck. Sounds nuts to me. :)

--Dave

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



Re: [PHP-DB] copy files (ftp?)

2003-09-04 Thread David Smith
Lars Jedinski wrote:

I have to copy files created with php on www.aaa.com
to another domain, e.g. www.bbb.com
Is and if how is this possible with PHP?
If you have an FTP server running on www.bbb.com, then it is possible. 
Here are the relevant functions:

   http://php.net/ftp

And here's some relevant sample code from that page:




$source_file = "somefile.txt";
$destination_file = "somefile.txt";
// set up basic connection
$conn_id = ftp_connect($ftp_server); 

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 

// check connection
if ((!$conn_id) || (!$login_result)) { 
   echo "FTP connection has failed!";
   echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 
   exit; 
   } else {
   echo "Connected to $ftp_server, for user $ftp_user_name";
   }

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); 

// check upload status
if (!$upload) { 
   echo "FTP upload has failed!";
   } else {
   echo "Uploaded $source_file to $ftp_server as $destination_file";
   }

// close the FTP stream 
ftp_close($conn_id); 
?>



You could also resort to a more platform specific solutions, perahps 
with scp (using exec() or backticks `scp file.txt 
[EMAIL PROTECTED]:/dest/path/file.txt` ).

Good luck.

--Dave

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


Re: [PHP-DB] how to recognize user login name?

2003-09-04 Thread David Smith
Spychała Wojciech wrote:

I have to do user recognizing in m php project. Simplest method i know is to
recognize for example login name (when user is logging into his local PC)
I've tried to use $USERNAME variable but it isnt what i want because it
recognize login name on server not remote user
If you are referring to the Windows login name, this is not possible 
with PHP via the web browser.

--Dave

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


Re: [PHP-DB] Problem in executing linux command from PHP

2003-09-02 Thread David Smith
Gnanavel wrote:

I have problem in executing  linux command
$output=exec("ls -a");
echo "$output";
the above coding works, but

$output=exec("cp file1 file2");
echo "$output";
does not works. can any one help me out of this problem

When I was executing the "cp" command it doesn't return anything. 
But it returned the name of the last file when i executed the "ls" command

"cp" does not return anything on the command line on success.

--Dave

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


Re: [PHP-DB] Database backup

2003-08-27 Thread David Smith
Just do a mysqldump on the command line. It will dump a whole bunch of 
SQL code that can be used to recreate the database in the event of 
disaster. You could even pipe the output to gzip to compress it.

   mysqldump --all-databases -u root | gzip -c > mysql_backup.gz

That works fine for me. Then just do this to restore the database from 
backup:

   gunzip mysql_backup.gz
   mysql -u root < mysql_backup
I recommend putting this in a shell script cron job that stores each 
backup with the date in the file name.

Enjoy.

--Dave

Chris Payne wrote:

Hi there everyone,

Is there a quick way I can backup all my databases on Linux so I can download them to my HD/Burn them onto CD?

I've started a very large travel project and there is going to be over 100 DB's in the end, each with who knows how many tables and going through PHPMyADMIN and exporting 1 DB at a time is going to take forever.

My Server is the Rehat Linux 8.0 with Apache and MySQL and PHP.

Thanks, any help would be really appreciated (And save me alot of headaches).

Chris
 

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


Re: [PHP-DB] Comparing tables

2003-08-26 Thread David Smith

> I would like to compare 2 tables in a database to determine which records
> are different!!!  Any clues out there.  Thanks in advance!

You didn't say which DBMS you are using. If you're using a DBMS which
supports INTERSECT (not MySQL), and assuming the two tables have the same
column names and types, you can do this:

  (SELECT * FROM table1) INTERSECT (SELECT * FROM table2)

For MySQL INTERSECT support, monitor this doc:

  http://www.mysql.com/doc/en/TODO_sometime.html

--Dave

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



Re: [PHP-DB] Renaming .htm pages to .php

2003-08-03 Thread David Smith
This doesn't have much to do with PHP and databases, but here's a thought:

You can leave them all .htm and have apache treat .htm files as .php 
files. Just check out httpd.conf for configuration. If your box is 
sufficiently zippy, you will see now slow down by running pure html 
files through PHP.

--Dave

David Blomstrom wrote:

I'm just about ready to publish my first "professionally" designed 
website, but there's a catch - all the pages end in .htm extensions, 
but I'm hoping to eventually learn how to use php and add some 
technical functions. Thus, I'd have to go back and change the .htm 
extensions to .php.

So, could I change all the extensions to .php NOW, so search engines 
will register them in the first place - even though I'm not currently 
using php? Will a page that has no server side includes, database 
management functions, etc. act just the same with a .php extension as 
it would with a .htm extension? In other words, is there a 
DISADVANTAGE to giving a page a .php extension if I'm not actually 
using any php functions on it?

Also, I like to name my pages index and place them inside folders, so 
I can access them easier on the Internet. For example, I can access 
www.geobop.com/birds/index.htm by typing www.geobop.com/birds/ into a 
browser. Does it work the same with php, or would I have to type in 
www.geobop.com/birds/index.php?

I recently downloaded a preconfigured package with Apache, PHP and 
MySQL, but I haven't had a chance to work with it yet. I'm really 
racing the clock to get my websites revised, so I'll probably try to 
get them online first, then go back and try to learn php and add 
server side includes and databases as I find time.

Thanks.





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


Re: [PHP-DB] subtracting dates...

2003-08-02 Thread David Smith
Try this (taken from http://us2.php.net/manual/en/ref.datetime.php):

*menaurus at gmx dot de*
16-Jul-2003 02:37   
|The argument has to be in the standard mysql format (y-m-d)...
function age($date) {

if (!$date) return false;
$year=0+substr($date,0,4);
$month=0+substr($date,5,2);
$day=0+substr($date,8,2);
$t=0;
$d=date("d");
$m=date("m");
$y=date("Y");
$age=$y-$year;
|if ($month<$m) $t=-1;
else if ($m==$month AND $day<$d) $t=-1;|||
return ($age+$t);
}
|
Good luck.

--Dave

John Ryan wrote:

Hi,

In mySQL, I store dates as -MM-DD, a standard DATE type. It stores users
date of births. I need to calculate in a PHP script, the users age from this
DOB. I get a PHP date in the same format as the mySQL and subtract, which
returns the year rounded off. ie, it doesnt matter if your birthdays in june
of 1983 and the date is januray 2003, your age is still returned as 20, when
it should be 19.
Does anyone know how can i get the right age?



 



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


Re: [PHP-DB] hi (php-SSH)

2003-07-28 Thread David Smith
Suman Aluru wrote:

hi ,
 is there any way to write a PHP program for SSH.
I want to establish a SSH connection and work some commands in the remote 
system and close the connection.

Yes, just do this (uses an SSH key file):

";
   echo `ssh -i /path/to/key/file [EMAIL PROTECTED] ls /tmp`;
   echo "Done executing remote command.";
?>
Use an SSH key file so you won't have to provide a password. I do this 
all the time for system administration, works great for inter-host 
communication.

--Dave

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


RE: [PHP-DB] Formatting numbers

2003-07-24 Thread David Smith

Thanks. That works perfectly.
David Smith



-Original Message-
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 24, 2003 3:36 PM
To: David Smith; php-db
Subject: Re: [PHP-DB] Formatting numbers


>  I am a little new to PHP, but I am trying to pull numbers from a database
> that has both phone numbers and social security numbers for a client. My
> Client doesn't want the numbers to come out like 55 but (555)
> 555-. My question is can I use format_number() to do this and if so
how
> do I make it change from a comma and every three spaces to fit the formats
> above? I know that this is probably pretty simple, but I can't seem to
find
> the answer anywhere (possibly right under my freakin' nose :D).

Use substr() to grab the pieces you want and add formatting around them.

us2.php.net/substr

---John Holmes...


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




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



[PHP-DB] Formatting numbers

2003-07-24 Thread David Smith
BlankHi,
 I am a little new to PHP, but I am trying to pull numbers from a database
that has both phone numbers and social security numbers for a client. My
Client doesn't want the numbers to come out like 55 but (555)
555-. My question is can I use format_number() to do this and if so how
do I make it change from a comma and every three spaces to fit the formats
above? I know that this is probably pretty simple, but I can't seem to find
the answer anywhere (possibly right under my freakin' nose :D).
Thanks.
David Smith



Re: [PHP-DB] Downloading Database?!?!

2003-07-23 Thread David Smith
You can create a batch file like this or if you want it to be in a web
interface much like phpmyadmin, but with your backup scheme you can use
the load data outfile command. This page from the mysql manual describes
both the infile and outfile methods:
http://www.mysql.com/doc/en/LOAD_DATA.html. This will tell you how to
use the syntax for the text files. It will let you do it with tabs,
commas, etc. Then you can use php to create the interface for your new
guy and make it as simple or complex as you like, but you don't even
have to use the filesystem functions to do it this way. Which does make
it a little simpler so that you can plan for 14 weeks of whatever you're
doing.
David Smith

On Wed, 2003-07-23 at 01:32, Stephen March wrote:
> Have you considered using the console-tool,  "mysqldump  "  ?
> You could write a quick script  ... say
> 
> mysqldump -u adminuser -p adminpass --all-databases > backup.sql
> tar -zcvf backup.tar.gz backup.sql
> mv backup.sql  /somepath/backup.sql
> 
> if you're on Winders, a batch file:
> 
> mysqldump -u adminuser -p adminpass --all-databases > backup.sql
> move backup.sql z:\somepath\backup.sql
> 
> If you write a batch script, or shell script, all the "new guy" would 
> have to do is run it. 
> Create a cron job (on linux) or scheduled task (on windows) and the "new 
> guy" just has to figure out the coffee machine  :)
> Food for thought,
> 
> ~Steve
> 
> Brenton Dobell wrote:
> 
> >Hello all,
> >
> >I am developing an Intranet page for my workplace, ATM i use phpmyadmin to
> >do rutine backups ect, this is cool but i am going on long service leave for
> >14 weeks and during that time a new guy will attempt to continue to maintain
> >the site and perform regular "backups"... I tried to show him how to use
> >phpmyadmin but has proved too dificult for him to understand, how can i make
> >a quick script to implement into a page that prompts you to download the
> >entire sctipt in .txt form?? just like php myadmin, and starting tips and
> >hints would be great.
> >
> >
> >Cheers in advance
> >
> >Brenton
> >
> >
> >  
> >
> 
> 
> 
> 
> -- 
> 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] Pros/Cons Database vs Excel

2003-07-23 Thread David Smith
Not to long ago I was in a very similar situation. I walked into a new
job where they were using Lotus Notes to take care of all of there phone
lists (telemarkers) and were using this dbase file to weed out all of
the do not call lists for particular states. Well, I was looking at the
data and the places this company wanted to go and realized several
things:
First: Limits within Lotus (and excel) is that once you begin to add
large numbers of data it slows the results greatly.
Two: I did try at first to look at other options such as Access and
Excel (I wasn't very familiar with Lotus and a little uncomfortable with
it) Excel will eventually stop keeping records passed 65 something
something rows. 
Three: Any data can be exported to Excel or Lotus and made "pretty".
While the database can be used to keep things stable and up to
date...with multiple excel sheets all over the place you may never know
who is up to date and who isn't. All that has to happen is a new release
of the excel data named the exact same as the last time it was released
and you have a problem.
Four: In my experience there seems to always be data that you don't want
people to have...usernames, passwords, and the list grows and grows. In
a database you can choose what to give them and what not to give them.
What I would suggest for your problem would be this create a multiple
set of tables to handle the data that you have, create a script to
output the data into whatever format you want, and tell your boss it's
as easy for you to add fields to the database as it is for him to add
them to excel :D. 
These of course are just my opinions so you can always take it or leave
it as if I said nothing at all.
David Smith
On Tue, 2003-07-22 at 22:35, Ow Mun Heng wrote:
> Hi,
> 
>   I'm having a problem convincing my boss of the benefits of using a
> database vs just using excel as a way of tracking events.
> 
>   The boss' stance is that excel is more 'simple' columns can be
> expanded as and when it's wanted. You can put links into excel that points
> to files residing in the system (within the web server's reach), can be
> mailed out to distribution lists (some ppl are lazy to need to open up a
> browser, log on etc.. to view the data). It can be stored on the web server
> for retrieval later etc..
> 
>   For a database, actually a database can do all of the above but to
> me, it's makes more sense as it can store all the above and provide
> additional functionality (as long as The code is written to make it more
> functional).
> 
>   Can anyone help me out and give me a few pointers on why using a
> database makes more sense then excel.
> 
> What's needed:
> 
> 1. Method for tracking sequence of events (sort of like experiment results)
> 2. Links embedded inside to relevent files (results of experiment)
> 3. Can be mailed around
> 4. additional fields can be added whenever wanted
> 
> something like that..
> 
> 
> Cheers,
> Mun Heng, Ow
> H/M Engineering
> Western Digital M'sia 
> DID : 03-7870 5168
> 
> -- 
> 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] Error notice

2003-07-12 Thread David Smith
You are referencing variables that you have not created (or perhaps 
array indexes that don't exist). To suppress these messages, fix your 
code to not do such things, or just put this at the top of your scripts:

   error_reporting( E_ALL ^ E_NOTICE );

Or edit php.ini to make it happen globally:

   error_reporting  =  E_ALL ^ E_NOTICE

--Dave

Marco Mastrorilli wrote:

-Notice: Use of undefined constant data..
-Notice: Use of undefined constant mail...
-Undefined variable
Why in my scripts i always get error notice like this? 
How can i solve this problem?

Thanks



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


Re: [PHP-DB] Removing cart items with hyperlink question

2003-06-08 Thread David Smith
Boa Constructor wrote:

The first line below works but the second one doesn't.  If $quantity were to
equal 0 then I want both of these to do exactly the same thing.
echo "";

echo "Remove Item";
 

Are you using POST or GET on the receiving end of the script? Also, try 
urlencoding the href like this:

echo "Remove Item";

And add this line prior to the echo:

$PHP_SELF = $_SERVER['PHP_SELF'];

In case regiester_globals is off (I hope it is).

--Dave

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


Re: [PHP-DB] Using fopen() for internet URL

2003-06-08 Thread David Smith
Tony S. Wu wrote:

I have an auto-update script to gather some information from other web 
pages to update information in my database.
And i use fopen() to open the URL.
as far as i know, the return result contains image, which i don't need.


If you call fopen()/fread() on a web page that contains an image, you 
will _not_ get the image in your result. You will only get the HTML text 
of the web-page.

For example:
$f = fopen( 'http://www.google.com/', 'r' );
$page = fread( $f, 2048 );
fclose( $f );
// $page will _not_ contain the Google image logo, but rather just the 
text of the HTML page.

--Dave



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


Re: [PHP-DB] Anyone know what Error 502 Bad Gateway means?

2003-04-12 Thread David Smith
Try this out:

http://www.checkupdown.com/status/E502.html

Robert Johnson wrote:

Hi all. I'm getting this error using Dreamweaver MX, php and mysql on a IIS
server over my intranet.  I can't figure out what it means... it happens
when I try to connect to a table using php.
TIA,

Robert



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


Re: [PHP-DB] temporary files

2003-03-23 Thread David Smith
You might consider using tmpnam() instead. tmpnam() doesn't give you a 
file handle (like tmpfile() does), but rather a file name. Just pass it 
a directory (like "/tmp") and a prefix to help identify it (can be "" ). 
It returns the unique file's name, and you could open a file handle to 
it with fopen(). Keep in mind that you have to unlink() it when you're done.

Hope this helps!

--Dave

Lars Tvedt wrote:

Im trying to create a way of storing php scripts in a mySQL database and
then execute them using temporary files as executable script buffers..
Ive got a mysql table with 4 fields: execID, execName, execDesc and execProc
The last one contains php code.
This is what i have so far:




But i need to get the name of the tempfile in order to include it..
all i have now is the handle_id
any help appreciated.






 



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


Re: [PHP-DB] Display results on html page

2003-03-20 Thread David Smith
You appear to have a ton of extra braces. I've modified your code below. 
That should do it, though keep in mind that your HTML is faulty too, 
though most browsers will probably tolerate it. :)

--Dave

Michelle Whelan wrote:

I am looking to display results of a query inside of an html table.  When I tested to see if this was correct it returned with a blank page on my website. 

Here is my code:

TIA

Michelle 

/* If there was a problem with the query... */
if (!$result || @mysql_num_rows($result) < 1)
{
 print("No entries in table $table.");
 exit;
}
print("RESULTS FOR:'$ZipCode'");
print('');
   
/* For each table entry returned... */
while($row = mysql_fetch_array($result))
{
 print("");
 print(" ");
//}
//{ 
 print("");
 print("Dirt Type:");
 print("" . $row['havedirtype'] . ""); 
 print(" ");
//} 
//{
 print("");
 print("Yards:");
 print("" . $row['noyards'] . "");
 print(" ");
//}
//{
 print("");
 print("Contact:");
 print("" . $row['contactname'] . "");
 print(" ");
//}
//{
 print("");
 print("Phone #:");
 print("" . $row['areacode'] . "");
 print(" ");
 print("" . $row['prefix'] . "");
 print(" ");
 print("" . $row['suffix'] . "");
 print(" ");
//}
//{
 print("");
 print(" ");
 print("Zip Code:");
 print("" . $row['zipcode'] . "");
 print(" ");
//}
//{
 print("");
 print(" ");
 print("Exp. Date:");
 print("" . $row['date_month'] . "");
 print(" ");
 print("" . $row['date_day'] . "");
 print(" ");
 print("" . $row['date_year'] . "");
 print(" ");
//}
//{
 print("");
 print(" ");
//}
//{
 print(""); 
 print(" ");
 print("Email:");
 print(" ");
 print("" . $row['email'] . "");
//}
//{
 print("");
 print(" ");
 print("Job City:");
 print(" ");
 print("" . $row['jobcity'] . "");
//}
//{
 print("");
 print(" ");
 print("X-Streets:");
 print(" ")
 print("" . $row['xstreets'] . "");
//}
//{
 print("");
 print(" ");
}

print("");

 



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


Re: [PHP-DB] Not seeing whats wrong with code

2003-03-19 Thread David Smith
Mike Delorme wrote:

Hello,

I am trying to write a script that conects to mysql, then SHA database. Then I need to list ALL the rows of table members. It sais there is a error on line 18. The while statement is on line 18, and I cant firgure out whats wrong with it:


$host = "localhost";
$uname = "sniper";
$pass = "starcraft";
$database = "SHA";
$tablename = "members";
$connect = "mysql_connect ($host, $uname, $pass)"; 
$select = "mysql_select_db ($database)";
$query = "SELECT * from $tablename";
$result = mysql_query ($query)
while ($row = mysql_fetch_row($result))
{
$row

You are missing a semi-colon here. And you are not printing the info. 
Try this instead of "$row": "print_r( $row );".

}
?>
Thanks,
Mike Delorme
--Dave

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


Re: [PHP-DB] mysql_connect() problem

2003-03-17 Thread David Smith
You need to install the php-mysql rpm. You can get this on your RedHat CD,
or through apt-get:

apt-get install php-mysql

Get apt here: http://apt.freshrpms.net/

Does the PHP project ever plan to do something as impressive as CPAN so
users won't have to reinstall or recompile just to extend its
functionality?

--Dave


>
> Hi,
>
>   I am using Apache 2 in Linux 8 .Whenever in my php script I want to
> connect to mysql through mysql_connect() function a error occured.
>
> My script is like that
>   $linlid=mysql_connect("localhost","user1","user1")or
> die("Connections
> failed");
> print "Connected successfully";
>
> The script writes this.
> %
> Fatal error: Call to undefined function: mysql_connect()
>
> Please help me.I have installed Apache and php through RPM.
> Anybody can help me.
>
> Indrajit
>
>
>
>
>
> _
> Get more buddies in your list. Win prizes
> http://messenger.msn.co.in/promo
>
>
> --
> 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] Authenticating through a php script

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

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

--Dave

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

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

2003-01-09 Thread David Smith
Jeremy,

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



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

Let us know how it goes.

--Dave



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



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




Re: [PHP-DB] Re: blob

2003-01-08 Thread David Smith
On Wed, 2003-01-08 at 06:50, [EMAIL PROTECTED] wrote:
> 
> i know this is a bit down the chain, but i'm trying to keep the message
> strings in tact
> 
> but can't you set up your directory just like you set up your mysql Grants.
> I have a directory that the web user owns, who is in its own group.  so i
> set the permisssions once, and its done.  Also i don't store the folder
> structure, i have a variable named for that folder structure then if the
> folders move or you need to move your webservers, the path will dynamically
> update, regardless of location.


Here's the problem. You have two choices for permissions with uploads:
1. You can make the upload directory world-writable. This is a major
security risk, as any other user on the system can write to it as well.
2.  You can make the upload directory owned by the apache user (or
whatever user your web-server runs as). This is a problem because you
have to be root in order to make the change. Many users don't have this
option.

Uploading the file to a DB solves both of these problems.

It presents its own problems too, though. Downloads of the binary data
are slow. And it's difficult to get a user's browser to cache the
dynamic pages. For example: Mozilla will cache a URL that looks like
this: http://example.com/image.jpg, but it has trouble caching a URL
like this: http://example.com/image.php?id=3. Does anyone know the right
headers to send to get browsers to cache these dynamic image pages as if
they were static images? 

--Dave


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




Re: [PHP-DB] Re: blob

2003-01-07 Thread David Smith
On Tue, 2003-01-07 at 15:52, [EMAIL PROTECTED] wrote:
> 
> I agree with this method.  i have not yet seen an advantage of storing
> blobs in a database.  Is there one?  i'm sure those on this list would have
> an opinion if there was one.  personally, i like storing all this stuff on
> the file system.

There is one advantage. You must either chown the upload directory to
the user that your web-server runs as, or chmod it to be world-writable.
When creating a web-application that you plan to distribute (like
Slashcode), you can't assume that your users will have that privilege.
So, storing it in MySQL is a great option.

--Dave


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




Re: [PHP-DB] Query with optional params

2003-01-05 Thread David Smith
Rich,

When I do searches with multiple fields, I construct the SQL string on
the PHP side. You can do something like this:

$sql = "SELECT * FROM docmeta WHERE ";

if( $PartNumber )
$sql .= "PartNumber='$PartNumber'";

if( $Title )
$sql .= " AND Title='$Title'";

and so on...

That has worked well for me in the past. You could make it more general
by creating an array of field names and iterating through that array
checking for the presence of the appropriate variables. Then, if you add
an additional field, just add it to the array of field names.

If there is a way to do this sort of "optional search field" with MySQL,
then I don't know about it.

--Dave

On Sun, 2003-01-05 at 12:52, Rich Hutchins wrote:
> I have a search page on which I place six fields into which users may enter
> data to perform a search. For ease of explanation, the fields are:
> Part Number
> Title
> Subtitle
> Print Date
> Status
> Type
> 
> All of these fields reside in the same table, named docmeta, in a MySQL
> database.
> 
> I'm running into a logic problem when a user enters data into only one or
> two of the six fields. The question/problem is how do I write a MySQL query
> when not all of the parameters are filled in each time? Is this a problem
> that needs to be handled on the PHP side with a bunch of IF statements when
> constructing the MySQL string or is there a MySQL command or syntax that
> accommodates variable length parameter sets?
> 
> The problem is when a search parameter is left blank by the user. If I
> include the empty parameter in the query (e.g. SELECT * FROM docmeta WHERE
> partnum LIKE "%" AND title LIKE "%" AND subtitle LIKE "";) then an empty set
> is returned when subtitle is not blank in the database. This is totally
> understandable, since that's what subtitle LIKE "" means, but it's not what
> I want to send.
> 
> Essentially, I want to skip sending the subtitle LIKE "" part when subtitle
> field is not filled in by the user.
> 
> Incidentally, the query works fine if I use OR instead of AND, but switching
> to an all OR query is not an option; I need to be able to perform both.
> 
> I've checked the archives and the MySQL manual (especially the language
> reference) and I haven't found anything that answers my question.
> 
> I'm fairly certain I'll be able to figure this out if somebody points me in
> the right direction, but I don't think I even know what (or where) to look
> for the answer. Any help would be appreciated.
> 
> Thanks,
> Rich
> 
> 
> -- 
> 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 Ques: default for date field be current date

2002-12-17 Thread David Smith
This can be done using the 'timestamp' type for your column. Note that
this field will be updated to the current time any time the row is
modified (including when it is created).

An alternative is to do it on the scripting side with the MySQL NOW()
command like so:

INSERT INTO your_table (field1,field2,...,create_date) values(
'val1','val2',...,NOW())

The create_date field can be of type time, date, or datetime. I
recommend datetime.

--Dave

On Tue, 2002-12-17 at 22:22, Michael Zornek wrote:
> I'm trying to convert an ASP/Access tutorial to PHP/MySQL and have a
> question regarding MySQL.
> 
> In Access one can create a date field and set the default to "Date()" to get
> the current date but according to the mysql manual:
> 
> http://www.mysql.com/doc/en/CREATE_TABLE.html
> 
> > Default values must be constants. This means, for example, that you cannot set
> > the default for a date column to be the value of a function such as NOW() or
> > CURRENT_DATE.
> 
> Is there any other way to have MySQL automate this? I've heard of something
> called stored procedures but am unfamiliar. -- Must this be done on the
> scripting side?
> 
> Thanks,
> ~ Mike
> -- 
> MikeZornek.com
> New blog, new Q&A column, new content everywhere!
> http://www.mikezornek.com
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



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




Re: [PHP-DB] multiple table inserts at the same time

2002-12-07 Thread David Smith
These two methods are nearly identical. Practically, you will probably
never see a performance difference. The time it takes to perform a query
is an order of magnitude greater than the time it takes to allocate
space for and iterate through an array. I would imagine that you will
never notice a difference between these two examples, even under heavy
loads. Perhaps Peter can speak to heavy loads better than I.

--Dave

On Sat, 2002-12-07 at 16:53, rolf vreijdenberger wrote:
> hi there,
> 
> I have multiple tables in my mysql db.
> Users register, and after submitting there are multiple tables that need
> inserts.
> 
> What is the best way to do this? speedwise, efficiencywise, codewise?
> (pseudo code)
> 
> A) $sql[]='insert1';
> $sql[]='insert2';
> $sql[]='insert3';
> foreach($sql as $doMe){
> mysql_query($doMe);//i left safety checks aside for clarity
> }
> 
> B)$sql='insert1';
> mysql_query($sql);
> $sql='insert2';
> mysql_query($sql);
> $sql='insert3';
> mysql_query($sql);
> 
> I'd prefer the first method, as it makes for easier updating of the queries
> in a centralized place.
> but I am wondering what your methods are, and any advantages or
> disadvantages known to you.
> 
> thanks a lot
> 
> 
> 
> -- 
> 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 and mysql

2002-12-07 Thread David Smith
Three words:

php dot net

--Dave

On Fri, 2002-12-06 at 23:19, Jason Wong wrote:
> On Saturday 07 December 2002 11:54, Dallas wrote:
> > hey, i'm just new to using php and mysql
> >
> > i would like to know how to do the following for a assignment of mine
> > (shopping site):-
> >
> > and if I could ask for full codes, and only relevant coding, no extra stuff
> > plz
> 
> Should you be asking for a quotation as well?
> 
> > *connect to the mysql database and display results in random areas of the
> > page
> > (the prices of the items will be displayed in different areas)
> >
> > *connect to a mysql database and show the results on the form in the text
> > fields
> > (basically so that they can see the current price on the form before they
> > edit it)
> >
> > *change the prices after submission of the form into the mysql database
> >
> > THANKS A LOT, it will really help
> 
> I bet it will ;-)
> 
> -- 
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> 
> 
> /*
> Most people in this society who aren't actively mad are, at best,
> reformed or potential lunatics.
>   -- Susan Sontag
> */
> 
> 
> -- 
> 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] Re: PHP/MySQL not available remotely...

2002-12-04 Thread David Smith
Are you able to connect to the MySQL server from the command line using
a non-php client?

--Dave

On Wed, 2002-12-04 at 09:04, [EMAIL PROTECTED] wrote:
> 
> do you have the persmissions set either for [EMAIL PROTECTED](which
> would only work from remotehost.com) or username@'%' (which would work for
> that username from any host)
> 
> 
> hth
> jeff
> 
> 
>  
>   
> "Chase"  
>   
>
> biz> cc: 
>   
>  Subject: [PHP-DB] Re: PHP/MySQL not 
>available remotely...  
> 12/04/2002   
>   
> 10:58 AM 
>   
>  
>   
>  
>   
> 
> 
> 
> 
> Okay, it was suggested that I may not have my "register_globals" flagged to
> "on" but I do.  I still can't seem to make any remote connect to the
> server.
> Again, there are no errors, it just flat don't work.
> 
> Chase
> 
> 
> "Chase" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > I seem to have a bit of an issue with my PHP/MySQL settings...
> >
> > A basic PHP bit like  works great on my
> > webserver.  However, with any form of DB access the page just hangs... I
> > don't get an error, but I don't get results either.  I also have
> > phpMyAdmin-2.3.3 running.  I can access that from the server directly,
> but
> > if I try to get to it via any other machine I get NO results.
> >
> > I am running IIS 5 with PHP4 and MySQL v3.23.53-max.
> >
> > Suggestions?
> >
> >
> 
> 
> 
> --
> 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] some data output formatting and grouping question...

2002-12-02 Thread David Smith
I don't see an easy way to do this in one SQL statement. But, the
following PHP does the trick for me (assuming MySQL):

// get the list of Y values
$r = mysql_query( "SELECT * FROM table GROUP BY Y" );
while( $y_val = mysql_fetch_array( $r ) )
$y_vals[] = $y_val['Y'];

// For each Y, fetch the Xs from the table
foreach( $y_vals as $y )
{
echo "$y";
// get all the Xs for this Y
$r = mysql_query( "SELECT * FROM table WHERE Y='$y'" );
while( $row = mysql_fetch_array( $r ) )
echo $row['X'] . "";
}

Let us know if this works.

--Dave

On Mon, 2002-12-02 at 00:53, Victor wrote:

> Consider the following table:
> 
> U | X | Y 
> --|---|--
> me|001|0a
> me|002|0a
> me|003|0a
> me|002|0b
> me|003|0b
> me|004|0b
> ..|...|..
> 
> then the code says:
> 
> SELECT * FROM Y WHERE U = me
> 
> So now what?
> - remember I do not know the value of Y, so it has to be an automatic
> thing; I can't just say ... WHERE U = me AND Y = a.
> 
> I want this output:
> 
> 0a
> 001
> 002
> 003
> ___ ()
> 
> 0b
> 002
> 003
> 004 
> 
> How the hell do I do that? I can't think of the goddamn' syntax!
> 
> __ 
> 
> Post your free ad now! http://personals.yahoo.ca
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



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




[PHP-DB] HTTP Authentication with MySQL/PHP

2002-11-17 Thread David Smith
I have a directory 'admin' that has been .htaccess'ed off. Ie, If you
point your browser at that directory, you will be prompted with an HTTP
authentication dialog. Nothing special about PHP or MySQL there. I like
the security that .htaccess and Apache give me.

Now, I have users in a MySQL table with md5 passwords stored for each.
These users use an HTML form to log in to my site. Some of these users
are admin users. When these admin users log in, I'd like them to have
access to the 'admin' directory without being prompted with the HTTP
authentication dialog. Is there anyway to use PHP to tell Apache that a
user has been authenticated and that it need not throw up the HTTP
authentication dialog?

In case any of the foregoing is unclear, here's the process I want:

1. A non-authenticated user tries to access the directory 'admin', so
Apache tosses up the HTTP authentication dialog. If they enter their
user name and password, they will be admitted (done without PHP or
MySQL, .htaccess and a passwd file).

2. A non-admin user authenticates with my HTML form, then they try to
hit the 'admin' directory. The same thing happens as above.

3. An admin user authenticates with my HTML form, PHP tells Apache that
this user has been authenticated. Then the user goes to the 'admin'
directory, and is admitted without any other authentication.

So, another question: To solve this problem from a different angle, is
there a way to have Apache's .htaccess specify SQL to determine a user's
credentials? Ie, when they visit the 'admin' directory, Apache could
look up their record in the user table and determine if they are an
admin.

Sorry for the long explanation, but I wanted to make sure I was clear as
this is a little bit of a funky request.

Thanks,
Dave




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




Re: [PHP-DB] Select Fields

2002-11-06 Thread David Smith
Tyler,

You probably need one or two of the following:

1. Put single-quotes around case in your SQL (where type like 'case')
2. Use wild-cards in your where statement (where type like '%case%')

Good luck!

--Dave

On Wed, 2002-11-06 at 23:31, Tyler Whitesides wrote:
> Hi,
> Sorry if this is ametuer, but I have been staring at this code for so long, trying 
>to find out why my selection fields are gathering values, and I cant find the problem.
> Thanks,
> Tyler
> --
>  include './include/vars.php';
> include './include/dbconnect.php';
> ?>
> 
> 
> 
> 
> function totalCost()
> {
> var form = document.system;
> var casing = form.casing.value;
> var processor = form.processor.value;
> var ram = form.ram.value;
> var hdd = form.hdd.value;
> var video = form.video.value;
> var sound = form.sound.value;
> var nic = form.nic.value;
> var monitor = form.monitor.value;
> var speakers = form.speakers.value;
> var interfaces = form.interfaces.value;
> var total = casing + processor + ram + hdd + video + sound + nic + monitor + 
>speakers + interfaces;
> form.price.value = total;
> }
> 
> 
> 
> 
> 
> 
> 
> height="15">
> height="1">
> height="15">
> 
> 
> height="1">
> 
> 
> 
> 
> src="images/clear.gif" width="10" height="1">
> 
> 
> 
> 
> 
> 
> 
> Services
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Build Your Custom System
> 
> 
> 
> Case:
> 
>  while($item = mysql_fetch_array($parts))
> {
> echo "$item[part]";
> }
> ?>
> 
> 
> 
> Total Cost Of Parts: size="6">
> 
> 
> 
> 
> 
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> src="images/corner_bl.gif" width="15" height="15">
> 
> src="images/corner_br.gif" width="15" height="15">
> 
> 
> 
> 
> 
> 
> 
> 
> 



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




Re: [PHP-DB] global vars

2002-10-30 Thread David Smith
When you redirect, you lose your variables. This means that you must
send them in some form to the other script. If you change your redirect
command to the following, you will see that $a gets transferred and
echoed in the second script as well as the first:

Header("Location: second.php?a=$a");

Note: this only works if you have "register globals" on which you seem
to have, so it should fix your problem.

Good luck!

--Dave


On Wed, 2002-10-30 at 23:05, Tomas Kubis wrote:
> Hello,
>  I have big problem. I upgraded PHP from 4.1.2 to 4.2.3 and my scripts with
> doesn´t work. Please help me!
> in php.info register globals=On
> 
> For example I have one script:
> first.php
>  global $a;
> $a=150;
> Header("Location: second.php");
> ?>
> 
> second.php
> 
>  echo $a;
> echo $GLOBALS['a'];
> echo "END";
> ?>
> 
> Where I have a bug?
> 
> Thank you very much
> 
> Tomas Kubis
> 
> 
> 
> -- 
> 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] Server Upgrade and DB Move(s)

2002-10-15 Thread David Smith

On Tue, 2002-10-15 at 15:31, [EMAIL PROTECTED] wrote:
> and the file copy method
> just seems to easy, it almost seems wrong  ;-),

This is a feature that is pretty nice about MySQL. You cannot do this
with Postgres, which caused my quite a few nice headaches over the
summer. You must dump the tables to an SQL file and read it into the new
database. MySQL is pretty cool.

--Dave


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