RE: [PHP] Referring Page

2004-10-14 Thread Ben Miller
Thanks all.  That did it perfectly.

-Original Message-
From: Matt M. [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 14, 2004 2:21 PM
To: Ben
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Referring Page


> I am trying to set up a script that will do different things based on the
> reffering page, without having to include the information in the URL.
Does
> PHP have a built in variable or function that would tell the rest of the
> script what page the user came from?  Any help is much appreciated.

there is $_SERVER['HTTP_REFERER']

but it is unreliable

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

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



[PHP] Simple Time Question

2004-10-21 Thread Ben Miller
Probably a stupid question, but hopefully has a simple answer.  Is there a
way to get Grenwich Mean time?  time() and date() functions that I can see
only seem to get date/time from the server, which knowing where that is,
could easily figure out GM time, but would rather go the other way.

Thanks.

Ben

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



[PHP] preg_replace

2009-06-05 Thread Ben Miller
I bought PHP & MySQL for DUMMIES and it shows me how to use special 
characters for pattern matching and I've figured out the basics of using 
preg_replace to replace pattern matches.  What I am having trouble with, 
though, is figuring out how to replace anything that does not match the 
pattern.  For example, I want to replace anything that is NOT an 
alphanumeric character.  Any help would be appreciated.  Thanks.


Ben 



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



RE: [PHP] preg_replace

2009-06-05 Thread Ben Miller
Oh yeah - not sure if spaces are considered alphanumeric or not, but I need
to keep spaces - replacing anything that is NOT a letter, a number or a
space.  Thanks again.

-Original Message-
From: Ben Miller [mailto:biprel...@gmail.com] 
Sent: Friday, June 05, 2009 2:09 AM
To: php-general@lists.php.net
Subject: [PHP] preg_replace

I bought PHP & MySQL for DUMMIES and it shows me how to use special 
characters for pattern matching and I've figured out the basics of using 
preg_replace to replace pattern matches.  What I am having trouble with, 
though, is figuring out how to replace anything that does not match the 
pattern.  For example, I want to replace anything that is NOT an 
alphanumeric character.  Any help would be appreciated.  Thanks.

Ben 


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


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



[PHP] Single Quotes in Form Inputs

2009-07-27 Thread Ben Miller
Hi,

 

I have a form in which my sales reps can add new clients into the database,
but I'm running into a problem if the client's name includes a single quote,
such as O'Henry, when it comes time to input the form data into the database
table.  I'm guessing I need to use ereg_replace, or something similar, to
change the single quote, but I still can't seem to get the syntax right.
Any help would be appreciated.  For what it's worth, here is a shortened
version of what I have:

 

$ firstName = "$_POST[form_firstName]";

$ lastname = "$_POST[form_lastName]";

 

$query = mysql_query("INSERT INTO customers (`cust_first`,`cust_last`)
VALUES ('$firstName','$lastName')");

 

Ben Miller

 



[PHP] Case Insensativity in String Comparisons

2009-08-25 Thread Ben Miller
Is there a simple to way to compare two strings with case insensitivity so
that the following will return true?

$foo = "Arnold";
$bar = "arnold";

If($foo == $bar) {

}

Thanks.


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



[PHP] Backup to local drive

2009-12-11 Thread Ben Miller
Hello - I have an application I'm building that allows users to store
personal information and files (images, PDFs, etc.) in our database, but I
need a way for them to be able to save the HTML output of that personal data
to a local (for the user) flash drive.  I'm guessing I'm going to need a
clientSide language like javascript for this, but was wondering if maybe
there was a PHP addon or something like that for downloading content to the
user's PC.  Thanks in advance.

 

Ben



RE: [PHP] Backup to local drive

2009-12-11 Thread Ben Miller
Users would be updating data via form input (address, tel, product
catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating
their own presentations and saving those presentations to a flash drive as
HTML files with calls to the images/PDFs so that they can simply plug their
drive into a USB port and present the info on the road, regardless of
connection to the internet.

Ben

-Original Message-
From: Roberto [mailto:prof...@gmail.com] 
Sent: Friday, December 11, 2009 11:58 AM
To: Ben Miller
Cc: php-general@lists.php.net
Subject: Re: [PHP] Backup to local drive

Hi,

you lost me a bit. Let say a user uploads a PDF file to one of your servers.
What do you mean when you say "I want the users to be able to save the
HTML output of their data"?!?

Roberto Aloi
http://aloiroberto.wordpress.com
Twitter: @prof3ta

On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller  wrote:
> Hello - I have an application I'm building that allows users to store
> personal information and files (images, PDFs, etc.) in our database, but I
> need a way for them to be able to save the HTML output of that personal
data
> to a local (for the user) flash drive.  I'm guessing I'm going to need a
> clientSide language like javascript for this, but was wondering if maybe
> there was a PHP addon or something like that for downloading content to
the
> user's PC.  Thanks in advance.
>
>
>
> Ben
>
>


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



RE: [PHP] Backup to local drive

2009-12-11 Thread Ben Miller
Too much reliance on the user knowing how to extract the files to the flash 
drive – need something that does it all for them so all they have to do is 
insert the flash drive on their own computer to store the preformatted 
presentation and then insert into a prospect’s computer and either a) 
(preferred) run the presentation via an autoplay command or b) open the 
presentation.html file.

 

Ben

 

From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Friday, December 11, 2009 2:25 PM
To: Ben Miller
Cc: 'Roberto'; php-general@lists.php.net
Subject: RE: [PHP] Backup to local drive

 

On Fri, 2009-12-11 at 14:25 -0700, Ben Miller wrote: 

 
Users would be updating data via form input (address, tel, product
catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating
their own presentations and saving those presentations to a flash drive as
HTML files with calls to the images/PDFs so that they can simply plug their
drive into a USB port and present the info on the road, regardless of
connection to the internet.
 
Ben
 
-Original Message-
From: Roberto [mailto:prof...@gmail.com] 
Sent: Friday, December 11, 2009 11:58 AM
To: Ben Miller
Cc: php-general@lists.php.net
Subject: Re: [PHP] Backup to local drive
 
Hi,
 
you lost me a bit. Let say a user uploads a PDF file to one of your servers.
What do you mean when you say "I want the users to be able to save the
HTML output of their data"?!?
 
Roberto Aloi
http://aloiroberto.wordpress.com
Twitter: @prof3ta
 
On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller  wrote:
> Hello - I have an application I'm building that allows users to store
> personal information and files (images, PDFs, etc.) in our database, but I
> need a way for them to be able to save the HTML output of that personal
data
> to a local (for the user) flash drive.  I'm guessing I'm going to need a
> clientSide language like javascript for this, but was wondering if maybe
> there was a PHP addon or something like that for downloading content to
the
> user's PC.  Thanks in advance.
> 
> 
> 
> Ben
> 
> 
 
 


Why not create all the HTML files and images on the server, and zip it up then 
send that down to the user?


Thanks,
Ash
http://www.ashleysheridan.co.uk



 



RE: [PHP] Backup to local drive

2009-12-11 Thread Ben Miller
That’s exactly why I need something that will put all the needed files directly 
onto the flash drive – to take that responsibility away from the user.  Pulling 
the data from the DB and creating the folder structure is easy with PHP – just 
not sure how to copy that folder structure and related files to the flash drive 
without the user having to know much of anything about computers.  Was hoping 
there is maybe a PHP extension that I didn’t know about, but sounds like a 
client side is going to be my best bet.

 

From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Friday, December 11, 2009 2:39 PM
To: Ben Miller
Cc: 'Roberto'; php-general@lists.php.net
Subject: RE: [PHP] Backup to local drive

 

On Fri, 2009-12-11 at 14:36 -0700, Ben Miller wrote: 

 
Too much reliance on the user knowing how to extract the files to the flash 
drive – need something that does it all for them so all they have to do is 
insert the flash drive on their own computer to store the preformatted 
presentation and then insert into a prospect’s computer and either a) 
(preferred) run the presentation via an autoplay command or b) open the 
presentation.html file.
 
 
 
Ben
 
 
 
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Friday, December 11, 2009 2:25 PM
To: Ben Miller
Cc: 'Roberto'; php-general@lists.php.net
Subject: RE: [PHP] Backup to local drive
 
 
 
On Fri, 2009-12-11 at 14:25 -0700, Ben Miller wrote: 
 
 
Users would be updating data via form input (address, tel, product
catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating
their own presentations and saving those presentations to a flash drive as
HTML files with calls to the images/PDFs so that they can simply plug their
drive into a USB port and present the info on the road, regardless of
connection to the internet.
 
Ben
 
-Original Message-
From: Roberto [mailto:prof...@gmail.com] 
Sent: Friday, December 11, 2009 11:58 AM
To: Ben Miller
Cc: php-general@lists.php.net
Subject: Re: [PHP] Backup to local drive
 
Hi,
 
you lost me a bit. Let say a user uploads a PDF file to one of your servers.
What do you mean when you say "I want the users to be able to save the
HTML output of their data"?!?
 
Roberto Aloi
http://aloiroberto.wordpress.com
Twitter: @prof3ta
 
On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller  wrote:
> Hello - I have an application I'm building that allows users to store
> personal information and files (images, PDFs, etc.) in our database, but I
> need a way for them to be able to save the HTML output of that personal
data
> to a local (for the user) flash drive.  I'm guessing I'm going to need a
> clientSide language like javascript for this, but was wondering if maybe
> there was a PHP addon or something like that for downloading content to
the
> user's PC.  Thanks in advance.
> 
> 
> 
> Ben
> 
> 
 
 
 
 
Why not create all the HTML files and images on the server, and zip it up then 
send that down to the user?
 
 
Thanks,
Ash
http://www.ashleysheridan.co.uk
 
 
 
 
 


That could end up in a lot of HTML and image files. Also, if you can't rely on 
people to unzip a file, can you rely on them to know that they need to keep the 
images with the HTML?


Thanks,
Ash
http://www.ashleysheridan.co.uk



 



[PHP] MySQL Increment/Decrement

2009-12-28 Thread Ben Miller
I hope this isn't a bone-head question - Is there a MySQL query that will
increment/decrement the value in an integer column with a single query - in
other words, I don't have to run a SELECT query to get the value,
add/subtract to/from the value, and then run an UPDATE query to store the
new value?

 

Thanks in advance.

 

Ben



[PHP] http vs https

2010-01-23 Thread Ben Miller
Is there a PHP function that will return whether the request was http or
https?  I have functions that need to cURL other servers - sometimes over
SSL, sometimes not, depending whether the function is called from
http://www.mydomain.com/script_that_calls_function.php or
https://www.mydomain.com/script_that_calls_function.php

 

Hope the question is clear.  Thanks,

 

Ben

 

 



[PHP] Sessions across subdomains

2010-01-29 Thread Ben Miller
Hi, I've always thought that session data was subdomain specific and would
not carry over between http://www.mydomain.com and
https://secure.mydomain.com, but it seems to be working for me now.  Can I
rely on this and post from http://www.mydomain.com to
https://secure.mydomain.com and simply pass a hidden input containing
PHPSESSID, or do I need to pass each key=>value pair that _SESSION contains
at www.  and reset them as _SESSION vars at secure.
 ? 

 

Thanks in advance,

Ben



[PHP] Sessions across subdomains

2010-01-29 Thread Ben Miller
Hi, I've always thought that session data was subdomain specific and would
not carry over between http://www.mydomain.com and
https://secure.mydomain.com, but it seems to be working for me now.  Can I
rely on this and post from http://www.mydomain.com to
https://secure.mydomain.com and simply pass a hidden input containing
PHPSESSID, or do I need to pass each key=>value pair that _SESSION contains
at www.  and reset them as _SESSION vars at secure.
 ? 

 

Thanks in advance,

Ben



[PHP] FTP Site

2010-02-16 Thread Ben Miller
Hi,

 

I'm building a site for a client that has a need to allow their users to
upload large files (up to 100mb or more) and store them on the server.  I've
never had a need to work with PHP's FTP functions until now and, before I go
reading the manual to learn how, I wanted to see if this something that I
can handle with just PHP, or if I'm going to need to adopt a third party
Ajax app or something like that?  Any thoughts or even a point in the right
direction would be greatly appreciated.  Thanks,

 

Ben



[PHP] SELECT AVG(rating)

2010-07-02 Thread Ben Miller
Hi - I have a MySQL table full of product reviews and I'm trying to select
info for only the top 5 rated products.  The only way I can figure out how
to do it so far is something like:

$query1 = mysql_query("SELECT * FROM products");
for($i=1;$i<=mysql_num_rows($query1);$i++) {
$row1 = mysql_fetch_array($query1,MYSQL_ASSOC);
$query2 = mysql_query("SELECT AVG(rating) as rating FROM reviews
WHERE product_id='" . $row1['product_id'] . "'");
...
$product[$i]['name'] = $row1['product_name'];
$product[$i]['rating'] = $row2['rating'];
}

And then use array functions to sort and display only the first 5.

Is there any easier way to get this done with a single query - something
like "SELECT AVG(rating) WHERE product_id=DISTINCT(product_id)"? <<= I tried
that - it didn't work.  Would greatly appreciate any advice.  Thanks,

Ben 



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



RE: [PHP] SELECT AVG(rating)

2010-07-02 Thread Ben Miller


-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Friday, July 02, 2010 2:43 PM
To: b...@tottd.com
Cc: php-general@lists.php.net
Subject: Re: [PHP] SELECT AVG(rating)

On Fri, 2010-07-02 at 14:32 -0600, Ben Miller wrote:

> Hi - I have a MySQL table full of product reviews and I'm trying to select
> info for only the top 5 rated products.  The only way I can figure out how
> to do it so far is something like:
> 
> $query1 = mysql_query("SELECT * FROM products");
> for($i=1;$i<=mysql_num_rows($query1);$i++) {
>   $row1 = mysql_fetch_array($query1,MYSQL_ASSOC);
>   $query2 = mysql_query("SELECT AVG(rating) as rating FROM reviews
> WHERE product_id='" . $row1['product_id'] . "'");
>   ...
>   $product[$i]['name'] = $row1['product_name'];
>   $product[$i]['rating'] = $row2['rating'];
> }
> 
> And then use array functions to sort and display only the first 5.
> 
> Is there any easier way to get this done with a single query - something
> like "SELECT AVG(rating) WHERE product_id=DISTINCT(product_id)"? <<= I
tried
> that - it didn't work.  Would greatly appreciate any advice.  Thanks,
> 
> Ben 
> 
> 
> 


How about something like this (untested)

SELECT products.product_id, AVG(reviews.rating) AS rating
FROM products
LEFT JOIN reviews ON (reviews.product_id = products.product_id)
GROUP BY products.product_id
ORDER BY rating
LIMIT 1,5

I'm unsure about that order and limit there, so you might have to wrap
that inside of a temporary table query and take your 5 out of that. A
join is the right way to go with this though I reckon.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Adding a DESC after ORDER BY rating did it perfectly.  I had tried a few
JOIN queries, but was building them incorrectly.  Thank you so much for your
help.

Ben



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



[PHP] Password protected directory

2010-11-02 Thread Ben Miller
I need to access and read the files in a password protected directory with a
PHP script using the readdir function.  I'm already making users login to a
secure area, so I don't want to make them enter a password again to access
the files - is there a way to include the password with the readdir/opendir
function with PHP?

 

Thanks in advance.

 

Ben



[PHP] MySQL Query Help

2010-11-20 Thread Ben Miller
Hi,

I'm building a website for a client in which I need to compare their
products, side-by-side, but only include criteria for which all selected
products have a value for that criteria.

In my database (MySQL), I have a tables named "products","criteria" and
"criteria_values"

If I have something like

$selected_product = array("1"=>"Product 1","2"=>"Product 2"...)  //  All
products selected for comparison by the user

I need to get only rows from "criteria" where there is a row in
"criteria_values" matching "criteria.criteria_id" for each $selected_product
- in other words, if any of the $selected_product does not have a row in
"criteria_values" that matches "criteria.criteria_id", that criteria would
not be returned.  I hope that makes sense.

I've played around with a few join queries, but none have given the desired
results.  Best I've been able to come up with so far is to query "criteria"
for each DISTINCT(criteria_id) and then run through each $selected_product
to make sure each has a criteria_value with a matching criteria_id,
eliminating any criteria where the number of criteria_values <
count($selected_product), but this seems pretty inefficient.

Thanks in advance for any help.

Ben Miller


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



RE: [PHP] MySQL Query Help

2010-11-21 Thread Ben Miller


SELECT * FROM products p LEFT JOIN criteria_values cv ON p.key=cv.key LEFT
JOIN criteria c ON cv.key=c.key WHERE c.value IS NOT NULL

Hard to answer without more detail, but I am guessing the answer will be
something like the above. Your question makes it hard to understand whether
c or cv is joined to p. So swap em around if I misunderstood. 

iPhone 4. It rocks!

On Nov 21, 2010, at 1:37 AM, Simcha Younger  wrote:

> On Sat, 20 Nov 2010 13:54:29 -0700
> "Ben Miller"  wrote:
> 
>> Hi,
>> 
>> I'm building a website for a client in which I need to compare their 
>> products, side-by-side, but only include criteria for which all 
>> selected products have a value for that criteria.
>> 
>> In my database (MySQL), I have a tables named "products","criteria" 
>> and "criteria_values"
>> 
>> If I have something like
>> 
>> $selected_product = array("1"=>"Product 1","2"=>"Product 2"...)  //  
>> All products selected for comparison by the user
>> 
>> I need to get only rows from "criteria" where there is a row in 
>> "criteria_values" matching "criteria.criteria_id" for each 
>> $selected_product
>> - in other words, if any of the $selected_product does not have a row 
>> in "criteria_values" that matches "criteria.criteria_id", that 
>> criteria would not be returned.  I hope that makes sense.
> 
> It would be a lot easier to think about this if you could provide the
table structure or create table statements.
> 
> If I understood correctly, you have products which reference a criteria ID
which has no matching value. If this is the problem you have a to first take
care of the integrity of your data, as this should never happen. 
> 

To help clarify - the 3 tables look something like the following (tableName
=> column,column,column...):

Products => product_id,product_name,product_description...  (key =
product_id)
Criteria => criteria_id,criteria_title,criteria_text,...  (key =
criteria_id)
Criteria_values => product_id,criteria_id,criteria_value,... (key =
product_id & criteria_id)

The user selects up to X product_id's to compare, stored in
$selected_products.

I then need to get each criteria_title and criteria_text from
table(criteria) where there is a matching criteria_id in
table(criteria_values) for each/all $selected_products, also returning the
criteria_value for each $selected_products, ultimately ending up with an
array or object that looks something like:

(Assuming the user selected Product A (product_id=1), Product B
(product_id=2) and Product C (product_id=3)

criteria => Array  (
[$criteria_id] => Array (
[title] => query_row[criteria_title]
[text] => query_row[criteria_text]
[values] => Array (
[1] => Product A's value for this criteria
[2] => Product B's value for this criteria
[3] => Product C's value for this criteria
)
)
[$criteria_id] => Array (
.
)
)

Again, displaying only/all criteria where there is a matching value for
each/all $selected_products

Thanks again,
Ben



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



[PHP] Removing non-numbers

2005-02-14 Thread Ben Miller
OK - easy one here, I know.  Having troubles removing anything that is not a
number from user input.  According to manual, [!] is supposed to mean set of
non-matching optional characters.  Tried

$var = ereg_replace("[!0-9]","",$var);

and it removes the numbers, but so does

$var = ereg_replace("[0-9]","",$var);

Any quick fix is greatly appreciated.  Would be great to not have to list
every possible character a user might enter between the [ and the ].
Doesn't matter how may times and how big of letters I use to say "enter
numbers only", people still enter non-numbers.

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



[PHP] Floored!

2006-02-23 Thread Ben Miller
If anyone has an answer for this, I would be greatly appreciative.

I was trying to compare two values, the first is the total cost of products
to be refunded, and the second is the original order total.  To the naked
eye, they both were coming out as 102.85, yet an if($Refund_Amount >
$Order_Total) was coming back true, so.

I ran some tests, and did the following:

$Order_Total = sprintf("%01.20f",$Order_Total);
$Refund_Amount = sprintf("%01.20f",$Refund_Amount);

which produced:

$Order_Total = 102.84431566
and $Refund_Amount = 102.85852651

so, I figured I would try the following to make sure that the figures in the
database weren't weird:

$Bar = 102.85;
$Foo = sprintf("%01.20f",$Bar);

echo "\$Foo = $Foo";

which produced:

$Foo = 102.84431566;

I am completely lost.

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



[PHP] Letters in Loops

2006-03-23 Thread Ben Miller
In trying to make an alpha list, using the following:

for($i=A;$i<=Z;$i++) {
echo "$i";
}

Produces:
A
B
C...
X
Y
Z
AA
AB
AC...
AX
AY
AZ... all the way to YZ.


What am I doing wrong that it's not stopping at just plain old "Z", without
moving on to "AA" and continuing?

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



[PHP] Failed MySQL queries

2006-04-05 Thread Ben Miller
Rather than using the following, which simply displays a white screen with
the die message, is there a way to add the die message to the body of the
original form page, such as in a variable, so that I can display the message
on the original form page with all the values already filled out, so that
all the user has to do is resubmit?

$result = mysql_query($query)
or die("User Account could not be created.  Please try 
again
later.");

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



[PHP] mysql_connect

2004-11-03 Thread Ben Miller
I am having trouble connecting to a database on another server.  I have the
following for the connection, but it seems to be overriding the value for
the $host variable, and replacing it with localhost.  Anyone got any ideas?

$host="domain.com";
$user="username";
$password="password";
$database="dbname";
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database.");

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



RE: [PHP] mysql_connect

2004-11-03 Thread Ben Miller
Guess that would have been helpful.

Warning: mysql_connect(): Access denied for user:
'[EMAIL PROTECTED]' (Using password: YES) in
/home/virtual/site2/fst/var/www/html/test/global.php on line 74
Couldn't connect to server.

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 04, 2004 7:47 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] mysql_connect


On Thursday 04 November 2004 06:22, Ben Miller wrote:
> I am having trouble connecting to a database on another server.  I have
the
> following for the connection, but it seems to be overriding the value for
> the $host variable, and replacing it with localhost.  Anyone got any
ideas?
>
>  $host="domain.com";
>  $user="username";
>  $password="password";
>  $database="dbname";
>  $connection = mysql_connect($host,$user,$password)
>   or die ("Couldn't connect to server.");
>  $db = mysql_select_db($database,$connection)
>   or die ("Couldn't select database.");

What does mysql_error() say?

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The man on tops walks a lonely street; the "chain" of command is often a
noose.
*/

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

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



RE: [PHP] Arrays

2004-11-08 Thread Ben Miller
edit


I hope this is not a stupid question, but I am learning how to work with
Arrays, and am having trouble figuring out how to move array values [the
whole array and all of it's values] from
page to page and/or store in a db.  Once again, I am new to arrays (and
fairly new to PHP for that matter), so please don't get too technical in
replies.  Thanks so much for help.

ben

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

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



RE: [PHP] Arrays

2004-11-08 Thread Ben Miller
Thank you to all for help with this.  Once I have a general idea of which
path to head down, I can figure it out pretty well from there, and you have
all given me a pretty good road map.  Anyway, thanks again.  It is greatly
appreciated.  I'll let you know hot it all comes out.

Ben

-Original Message-
From: Ligaya Turmelle [mailto:[EMAIL PROTECTED]
Sent: Monday, November 08, 2004 10:03 PM
To: Ben
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Arrays


There are a couple of ways to pass arrays (and their values) between
pages.  I personally would put the array into a session variable
($_SESSION - see reference) and access the various parts as needed.
Another option is sending the whole array or it's parts as hidden fields
in a form (access with the $_GET and $_POST - again see reference), but
that means the user has to click a submit button.

If you are trying to store the array in a Database I would suggest you
make each element of the array into it's own column of the database.
Databases generally should only have 1 piece of information being saved
per cell (think excel).  If you would like a link to database design,
let me know and I will send it.

If all you really were asking was how to iterate through an array - then
  I would recommend looking at the manual's page on arrays (
http://www.php.net/manual/en/language.types.array.php ).

Respectfully,
Ligaya Turmelle

References:
http://www.php.net/language.variables.predefined

Ben wrote:
> I hope this is not a stupid question, but I am learning how to work with
> Arrays, and am having trouble figuring out how to move array values from
> page to page and/or store in a db.  Once again, I am new to arrays (and
> fairly new to PHP for that matter), so please don't get too technical in
> replies.  Thanks so much for help.
>
> ben
>

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



[PHP] Column Totals

2004-11-15 Thread Ben Miller
I am trying to get the total sales revenue for each day of the month, and
having no luck at all.

The following query seems to return an empty string, which should only give
me the total for the entire column anyway.
$query = "SELECT SUM(Revenue) FROM Sales WHERE Date='$Date'";


I also tried, among many, many things, to use a for loop to get the sum for
each date, month to date, such as:

$Today = date("d");

for ($i = 1; $i < $Today; $i++) {

   $query = "SELECT SUM(Revenue) FROM Sales WHERE Date='$i'";

}

In case it helps, sample table data might look like this:

OrderNoOrderDateRevenue
   1  79.95
1112   1  39.95
1113   3  89.95

and I am trying to produce something that would show:



DateRevenue


1119.90


20.00


389.95




PLEASE HELP.   PLEASE!!  And many, many thanks in advance

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



RE: [PHP] Column Totals

2004-11-15 Thread Ben Miller
-Original Message-
From: Robby Russell [mailto:[EMAIL PROTECTED]
Sent: Monday, November 15, 2004 11:12 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Column Totals


On Mon, 2004-11-15 at 11:01 -0700, Ben Miller wrote:
> SELECT SUM(Revenue) FROM Sales WHERE Date='$Date'

What happens when you do:

SELECT Revenue FROM Sales WHERE Date='$Date';

Make sure you're getting values back first..and then you can try to sum
them.

-Robby


--
/***
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | [EMAIL PROTECTED]
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
*--- Now supporting PHP5 ---
/

I am getting values back in this case, if there are values for the given
date, that is.  If I do:


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

extract($row);

echo "$Date$Revenue";
}

for example, it returns a long list of individual sales.

Ben

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



RE: [PHP] Column Totals

2004-11-15 Thread Ben Miller
That did it perfectly.  Why don't any of the stupid books tell you that you
need the AS statement?

-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED]
Sent: Monday, November 15, 2004 11:16 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [PHP] Column Totals


[snip]
The following query seems to return an empty string, which should only
give
me the total for the entire column anyway.
$query = "SELECT SUM(Revenue) FROM Sales WHERE Date='$Date'";
[/snip]

$query = "SELECT SUM(Revenue) AS Revenue FROM Sales WHERE Date='$Date'";
note the AS statement-^

$foo = mysql_query($query, $connection);

$bar = mysql_fetch_array($foo);

echo $bar['Revenue']

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



[PHP] Sending arrays from page to page

2005-11-15 Thread Ben Miller
I am trying to learn how to work with arrays, and have the basic concept
down for working within a single page, but I am having trouble sending an
array from one page to another.  For example, I can send a variable from
page to page using either the URL, such as www.domain.com/?foo=bar, or using
a form, but can I send an array from one page to another using a form so
that all the values in the array will be sent?  Such as:

Page 1:
--
echo "






";


Page 2:  (ProcessArray.php)
--
for ($i=1;$i<=3;$i++) {
echo "
$TestVariable[$i]
";
}

Any help would be greatly appreciated.  Thanks in advance.

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



[PHP] Cookies

2005-11-17 Thread Ben Miller
Is there a way to test if a user has cookies turned on or not so that I can
use cookies if the user allows them and use the URL if the user does not
allow them?

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



RE: [PHP] Cookies

2005-11-17 Thread Ben Miller
Hi Ben,

Thursday, November 17, 2005, 3:26:04 PM, you wrote:

> Is there a way to test if a user has cookies turned on or not so
> that I can use cookies if the user allows them and use the URL if
> the user does not allow them?

Set one? :)

Then check if it exists or not.

This of course will not catch those sneaky buggers who disable cookies
part way through your site just to see what effect it will have.

Cheers,

Rich
--
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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

In order to set one and then check if it exists or not, I have to set it on
one page, and then test it on the next page load - In this case, I don't
figure out how I need to send information from page to page until they have
already gone to another page, at which point, the test is no longer needed.
I was hoping there might be a browser variable or something like that that
would tell right away if cookies are turned on or not.  If there is not,
perhaps this is something we should lobby the browsers to get?

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



[PHP] Arrays

2005-12-06 Thread Ben Miller
If I have an array, such as

$Var[0] = "Dog";
$Var[1] = "Cat";
$Var[2] = "Horse";

Is there a way to quickly check to see if $Var contains "Lion" without
walking through each value?

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



[PHP] Counting in Hex

2006-01-04 Thread Ben Miller
Is there a way in PHP to count using hex instead of numerals so that the
following statement

$var = 237F;
$var++;
echo "$var";

would result in

2380

Thanks a bunch.

Ben

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



RE: [PHP] Counting in Hex

2006-01-04 Thread Ben Miller
Never mind - wasn't adding properly.  Found it after all on php.net, anyway.
Thanks anyway.

-Original Message-
From: Ben Miller [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 04, 2006 5:01 PM
To: php-general@lists.php.net
Subject: [PHP] Counting in Hex


Is there a way in PHP to count using hex instead of numerals so that the
following statement

$var = 237F;
$var++;
echo "$var";

would result in

2380

Thanks a bunch.

Ben

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

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



[PHP] Pages Expiring

2006-01-05 Thread Ben Miller
When using forms with PHP sessions, hitting the back button results in
WARNING: Page has Expired

I am wondering if there is a work around for this so that it (IE, in this
case) resubmits the form information and displays the previous page.

Any ideas?

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



[PHP] Determining number of days in a selected month

2006-01-19 Thread Ben Miller
Is there a way to easily tell PHP how many days there are in a selected
month without writing the following out for each month:

if($Month == "January") {
$NumberOfDays = 31;
}
elseif($Month == "February") {
if($Year == "A Leap Year") {
$NumberOfDays = 29;
}
elseif($Year != "A Leap Year") {
$NumberOfDays = 28;
}
}
elseif($Month == "March") {
$NumberOfDays = 31;
}
and so on, and so on, and so on

I would greatly appreciate any help.  Thanks.



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