Re: [PHP] PHP/MYSQL query error

2002-08-26 Thread Chris Crane

I got it working. It did not like the single quotes around the column names.

"Chris Crane" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Thank you. I will try that.
> "Justin French" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Why don't you do
> >
> > $result = mysql_query($query) or die(mysql_error());
> >
> > or
> >
> > $result = mysql_query($query);
> > echo mysql_error();
> >
> > That way, instead of "Query Failed" you'll get something meaningful...
> > probably something that will solve the problem.
> >
> >
> > Justin French
> >
> >
> > on 26/08/02 11:55 PM, Chris Crane ([EMAIL PROTECTED]) wrote:
> >
> > > Initially there was an error with too many values verses columns. But
I
> > > think it was fixed. I am double checking now.
> > >
> > >
> > > "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
> > > 003201c24d07$b8560470$8102a8c0@000347D72515">news:003201c24d07$b8560470$8102a8c0@000347D72515...
> > >> [snip]
> > >> /* Performing SQL query */
> > >> $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
> > >> 'Address1', 'Address2',
> > >> 'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
> > >> 'IP', 'Status', 'Comments')
> > >> VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
> > >> 'Vernon', 'CT', '06066', '[EMAIL PROTECTED]',
> > >> '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
> > >> Requested', 'Testing')";
> > >> $result = mysql_query($query) or die("Query failed");
> > >> [/snip]
> > >>
> > >> Have you printed the query to make sure that the syntax is right? The
> > > first
> > >> thing that I see is that there are 13 items in your INSERT statement
> and
> > > 15
> > >> items in your VALUES statement ... these must match in order for the
> query
> > >> to work.
> > >>
> > >>
> > >> HTH!
> > >>
> > >> Jay
> > >>
> > >> Ask smart questions:
> > >> http://www.tuxedo.org/~esr/faqs/smart-questions.html
> > >> Top Questions on php-general;
> > >> (Answers can be found by RTFM, STFW, or STFA,
> > >> save for #3 and #6 which can probably be found
> > >> the same way, since they are usually one of the
> > >> other questions on this list.)
> > >> 1. How can I make file uploads work?
> > >> 2. How come my form will not pass variables?
> > >> 3. HELP! HELP! Please HELP!
> > >> 4. Register_Globals ?!?
> > >> 5. Is there a function to ... [insert thought here]?
> > >> 6. Anyone see the error in this code?
> > >>
> > >>
> > >
> > >
> >
>
>



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




Re: [PHP] PHP/MYSQL query error

2002-08-26 Thread Chris Crane

Thank you. I will try that.
"Justin French" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Why don't you do
>
> $result = mysql_query($query) or die(mysql_error());
>
> or
>
> $result = mysql_query($query);
> echo mysql_error();
>
> That way, instead of "Query Failed" you'll get something meaningful...
> probably something that will solve the problem.
>
>
> Justin French
>
>
> on 26/08/02 11:55 PM, Chris Crane ([EMAIL PROTECTED]) wrote:
>
> > Initially there was an error with too many values verses columns. But I
> > think it was fixed. I am double checking now.
> >
> >
> > "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
> > 003201c24d07$b8560470$8102a8c0@000347D72515">news:003201c24d07$b8560470$8102a8c0@000347D72515...
> >> [snip]
> >> /* Performing SQL query */
> >> $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
> >> 'Address1', 'Address2',
> >> 'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
> >> 'IP', 'Status', 'Comments')
> >> VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
> >> 'Vernon', 'CT', '06066', '[EMAIL PROTECTED]',
> >> '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
> >> Requested', 'Testing')";
> >> $result = mysql_query($query) or die("Query failed");
> >> [/snip]
> >>
> >> Have you printed the query to make sure that the syntax is right? The
> > first
> >> thing that I see is that there are 13 items in your INSERT statement
and
> > 15
> >> items in your VALUES statement ... these must match in order for the
query
> >> to work.
> >>
> >>
> >> HTH!
> >>
> >> Jay
> >>
> >> Ask smart questions:
> >> http://www.tuxedo.org/~esr/faqs/smart-questions.html
> >> Top Questions on php-general;
> >> (Answers can be found by RTFM, STFW, or STFA,
> >> save for #3 and #6 which can probably be found
> >> the same way, since they are usually one of the
> >> other questions on this list.)
> >> 1. How can I make file uploads work?
> >> 2. How come my form will not pass variables?
> >> 3. HELP! HELP! Please HELP!
> >> 4. Register_Globals ?!?
> >> 5. Is there a function to ... [insert thought here]?
> >> 6. Anyone see the error in this code?
> >>
> >>
> >
> >
>



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




Re: [PHP] PHP/MYSQL query error

2002-08-26 Thread Chris Crane

There are 15 columns and 15 pieces of data. In my second post I fixed this
error and pasted it into PHPMYADMIN and it worked fine, but not here...


"Chris Crane" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Initially there was an error with too many values verses columns. But I
> think it was fixed. I am double checking now.
>
>
> "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
> 003201c24d07$b8560470$8102a8c0@000347D72515">news:003201c24d07$b8560470$8102a8c0@000347D72515...
> > [snip]
> > /* Performing SQL query */
> > $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
> > 'Address1', 'Address2',
> >  'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
> > 'IP', 'Status', 'Comments')
> > VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
> > 'Vernon', 'CT', '06066', '[EMAIL PROTECTED]',
> >  '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
> > Requested', 'Testing')";
> > $result = mysql_query($query) or die("Query failed");
> > [/snip]
> >
> > Have you printed the query to make sure that the syntax is right? The
> first
> > thing that I see is that there are 13 items in your INSERT statement and
> 15
> > items in your VALUES statement ... these must match in order for the
query
> > to work.
> >
> >
> > HTH!
> >
> > Jay
> >
> > Ask smart questions:
> > http://www.tuxedo.org/~esr/faqs/smart-questions.html
> > Top Questions on php-general;
> > (Answers can be found by RTFM, STFW, or STFA,
> > save for #3 and #6 which can probably be found
> > the same way, since they are usually one of the
> > other questions on this list.)
> > 1. How can I make file uploads work?
> > 2. How come my form will not pass variables?
> > 3. HELP! HELP! Please HELP!
> > 4. Register_Globals ?!?
> > 5. Is there a function to ... [insert thought here]?
> > 6. Anyone see the error in this code?
> >
> >
>
>



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




Re: [PHP] PHP/MYSQL query error

2002-08-26 Thread Chris Crane

Initially there was an error with too many values verses columns. But I
think it was fixed. I am double checking now.


"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
003201c24d07$b8560470$8102a8c0@000347D72515">news:003201c24d07$b8560470$8102a8c0@000347D72515...
> [snip]
> /* Performing SQL query */
> $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
> 'Address1', 'Address2',
>  'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
> 'IP', 'Status', 'Comments')
> VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
> 'Vernon', 'CT', '06066', '[EMAIL PROTECTED]',
>  '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
> Requested', 'Testing')";
> $result = mysql_query($query) or die("Query failed");
> [/snip]
>
> Have you printed the query to make sure that the syntax is right? The
first
> thing that I see is that there are 13 items in your INSERT statement and
15
> items in your VALUES statement ... these must match in order for the query
> to work.
>
>
> HTH!
>
> Jay
>
> Ask smart questions:
> http://www.tuxedo.org/~esr/faqs/smart-questions.html
> Top Questions on php-general;
> (Answers can be found by RTFM, STFW, or STFA,
> save for #3 and #6 which can probably be found
> the same way, since they are usually one of the
> other questions on this list.)
> 1. How can I make file uploads work?
> 2. How come my form will not pass variables?
> 3. HELP! HELP! Please HELP!
> 4. Register_Globals ?!?
> 5. Is there a function to ... [insert thought here]?
> 6. Anyone see the error in this code?
>
>



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




[PHP] Re: PHP/MYSQL query error

2002-08-26 Thread Chris Crane

I did some more testing and I found that I forgot the first field in the
columns section of the Statement. So now it looks like this:
I also copy and pasted the statement into PHPMYADMIN and it worked fine. It
just doesn't work here


function AddSignupRequest($Signup_FName, $Signup_LName, $Signup_Address1,
$Signup_Address2, $Signup_City,
$Signup_State, $Signup_Zip, $Signup_Email, $Signup_Phone,
$Signup_ContactMethod,
$Signup_Date, $Signup_IP, $Signup_Status, $Signup_Comments) {
/* Connecting, selecting database */
$dbh=mysql_connect ($MySQL_Host,  $MySQL_User, $MySQL_Password) or die
('I cannot connect to the database.');
 mysql_select_db ("havasuin_Signups");

/* Performing SQL query */
$query = "INSERT INTO SignupRequests ('SignupID', 'FirstName',
'LastName', 'Address1', 'Address2',
 'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
'IP', 'Status', 'Comments')
VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
'Vernon', 'CT', '06066', '[EMAIL PROTECTED]',
 '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
Requested', 'Testing')";
$result = mysql_query($query) or die("Query failed");

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);
 print "$Signup_LName, $Signup_FName\n";

}

"Chris Crane" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I am getting a failed query error message. Could someone take a look and
let
> me know.
>
> //F U N C T I O N S
> //=
> function AddSignupRequest($Signup_FName, $Signup_LName, $Signup_Address1,
> $Signup_Address2, $Signup_City,
> $Signup_State, $Signup_Zip, $Signup_Email, $Signup_Phone,
> $Signup_ContactMethod,
> $Signup_Date, $Signup_IP, $Signup_Status, $Signup_Comments) {
> /* Connecting, selecting database */
> $dbh=mysql_connect ($MySQL_Host,  $MySQL_User, $MySQL_Password) or die
> ('I cannot connect to the database.');
>  mysql_select_db ("havasuin_Signups");
>
> /* Performing SQL query */
> $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
> 'Address1', 'Address2',
>  'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
> 'IP', 'Status', 'Comments')
> VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
> 'Vernon', 'CT', '06066', '[EMAIL PROTECTED]',
>  '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
> Requested', 'Testing')";
> $result = mysql_query($query) or die("Query failed");
>
> /* Free resultset */
> mysql_free_result($result);
>
> /* Closing connection */
> mysql_close($link);
>  print "$Signup_LName, $Signup_FName\n";
>
> }
>
>



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




[PHP] PHP/MYSQL query error

2002-08-26 Thread Chris Crane

I am getting a failed query error message. Could someone take a look and let
me know.

//F U N C T I O N S
//=
function AddSignupRequest($Signup_FName, $Signup_LName, $Signup_Address1,
$Signup_Address2, $Signup_City,
$Signup_State, $Signup_Zip, $Signup_Email, $Signup_Phone,
$Signup_ContactMethod,
$Signup_Date, $Signup_IP, $Signup_Status, $Signup_Comments) {
/* Connecting, selecting database */
$dbh=mysql_connect ($MySQL_Host,  $MySQL_User, $MySQL_Password) or die
('I cannot connect to the database.');
 mysql_select_db ("havasuin_Signups");

/* Performing SQL query */
$query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
'Address1', 'Address2',
 'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
'IP', 'Status', 'Comments')
VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
'Vernon', 'CT', '06066', '[EMAIL PROTECTED]',
 '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
Requested', 'Testing')";
$result = mysql_query($query) or die("Query failed");

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);
 print "$Signup_LName, $Signup_FName\n";

}



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




Re: [PHP] PHP and Date()

2002-07-18 Thread Chris Crane

sorry about last message
I want to get a list of the last 7 business days so I would have to loop
through this and get each day correct?


"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
001701c22e78$4494c970$8102a8c0@niigziuo4ohhdt">news:001701c22e78$4494c970$8102a8c0@niigziuo4ohhdt...
> [snip]
> How can I look back Business Days.
> I would like to go back from a certain date, like 7 business days. Is
there
> a simple way other then looping and checking for the day of the week?
> [/snip]
>
> $sevendaysago = date("Y-m-d", mktime(date("h")-168));
>
> This will give you the date exactly seven days ago, then you can test what
> day (Mon - Fri). If it is Saturday then you could subtract 24 more hours,
if
> Sunday, 48 more hours.
>
> HTH!
>
> Jay
>
> "Of all the things I've lost, I miss my mind the most"
>
> *
> * Want to meet other PHP developers *
> * in your area? Check out:  *
> * http://php.meetup.com/*
> * No developer is an island ... *
> *
>
>



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




[PHP] PHP and Date()

2002-07-18 Thread Chris Crane

How can I look back Business Days.
I would like to go back from a certain date, like 7 business days. Is there
a simple way other then looping and checking for the day of the week?



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




Re: [PHP] Code errors

2002-07-18 Thread Chris Crane

ok here is what I came up with:
How's this?
function HistoricalStock($sym) {
 $row = 1;
 $Data =
fopen("http://table.finance.yahoo.com/table.csv?a=7&b=1&c=2002&d=7&e=17&f=20
02&s=$sym&y=0&g=d&ignore=.csv","r");
 print '';

 while ($Line = fgetcsv ($Data, 1000, ",")) {
  if($row == 1) {
   echo " $Line[0]
$Line[1] $Line[2]
 $Line[3] $Line[4]
$Line[5]";
   }
  else {
   echo " $Line[0] Line[1]
$Line[2]
   $Line[3] $Line[4] $Line[5]";
}
  $row++;
  }

 print '';
 fclose($Data);
}

"Analysis & Solutions" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Thu, Jul 18, 2002 at 10:14:25AM -0400, Chris Crane wrote:
>
> > Warning: Undefined offset: 5 in
>
> Means your array doesn't have that key in it.  I bet you're running into
> blank lines in your file.
>
>
> > $Results = implode('', file("$LookupURL"));
> > $Data = explode("\n", $Results);
>
> Uh, you do realize that you're flip flopping the data around here for no
> reason.  file() already creates an array.  But you go through the
> unnecessary steps of compressing that array into a string and then
> recreating a new array.  Just do this:
>
>$Data = file($LookupURL);
>
> That will eliminate your errors by not adding extra blank lines.
>
>
> >  foreach($Data as $Line) {
> >   list($H_Date, $H_Open, $H_High, $H_Low, $H_Close, $H_Volume) =
split(",",
> > $Line);
> >   print "
> >
$H_Date\n$H_Open\n$H_High\n$H_Low\n$
> > H_Close\n$H_Volume\n";
> >   }
>
> But, your whole approach is wasteful.  As I said yesterday, use fopen()
> and then fgetcsv().  Forget the file() and split() calls.
>
> Then, you're wasting time and memory with the list().  Use the resulting
> array directly.
>
>while ( $Line = fgetcsv($fp, 500) ) {
>   echo " $Line[0] $Line[1] ... etc ...";
>}
>
> Or, since you're pringing everything out, you could just do this:
>
>while ( $Line = fgetcsv($fp, 500) ) {
>   echo '' . implode('', $Line) . ''
>}
>
> --Dan
>
> --
>PHP classes that make web design easier
> SQL Solution  |   Layout Solution   |  Form Solution
> sqlsolution.info  | layoutsolution.info |  formsolution.info
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



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




Re: [PHP] Code errors

2002-07-18 Thread Chris Crane

Hey thank Dan, I will try this.
Does List waste lots of time and memory?

Normally, I create a function and global a bunch of variables to be used
later on the HTML/PHP file. After I global the variables I split the string
using the List function. I do that for stock quotes from YAHOO so I can code
the layout in like Dreamweaver and place the varaibles where I would like
instead of the function writing out the html for me. Is that bad?



"Analysis & Solutions" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Thu, Jul 18, 2002 at 10:14:25AM -0400, Chris Crane wrote:
>
> > Warning: Undefined offset: 5 in
>
> Means your array doesn't have that key in it.  I bet you're running into
> blank lines in your file.
>
>
> > $Results = implode('', file("$LookupURL"));
> > $Data = explode("\n", $Results);
>
> Uh, you do realize that you're flip flopping the data around here for no
> reason.  file() already creates an array.  But you go through the
> unnecessary steps of compressing that array into a string and then
> recreating a new array.  Just do this:
>
>$Data = file($LookupURL);
>
> That will eliminate your errors by not adding extra blank lines.
>
>
> >  foreach($Data as $Line) {
> >   list($H_Date, $H_Open, $H_High, $H_Low, $H_Close, $H_Volume) =
split(",",
> > $Line);
> >   print "
> >
$H_Date\n$H_Open\n$H_High\n$H_Low\n$
> > H_Close\n$H_Volume\n";
> >   }
>
> But, your whole approach is wasteful.  As I said yesterday, use fopen()
> and then fgetcsv().  Forget the file() and split() calls.
>
> Then, you're wasting time and memory with the list().  Use the resulting
> array directly.
>
>while ( $Line = fgetcsv($fp, 500) ) {
>   echo " $Line[0] $Line[1] ... etc ...";
>}
>
> Or, since you're pringing everything out, you could just do this:
>
>while ( $Line = fgetcsv($fp, 500) ) {
>   echo '' . implode('', $Line) . ''
>}
>
> --Dan
>
> --
>PHP classes that make web design easier
> SQL Solution  |   Layout Solution   |  Form Solution
> sqlsolution.info  | layoutsolution.info |  formsolution.info
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



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




Re: [PHP] Someone Help please

2002-07-18 Thread Chris Crane

Well, I posted it the first time and no one responded so I figured the
subject did not interest anyone. I changed it. I am not sure how the third
one started.

But hey thanks for watching and giving you unwanted opinion.

"Analysis & Solutions" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Chris:
>
> Geez, this is your third thread on this today...  Lame.
>
> --Dan
>
> --
>PHP classes that make web design easier
> SQL Solution  |   Layout Solution   |  Form Solution
> sqlsolution.info  | layoutsolution.info |  formsolution.info
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



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




[PHP] Re: Code errors

2002-07-18 Thread Chris Crane

247:   list($H_Date, $H_Open, $H_High, $H_Low, $H_Close, $H_Volume) =
split(",", $Line);

"Scott Fletcher" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Which line in the script you had provided to us is line 247?
>
> "Chris Crane" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > I am trying some code and it works except I get the following errors...
> > Warning: Undefined offset: 5 in
> > c:\www\htdocs\demos\havasuinternet\havasuinternet-lib.php on line 247
> > Warning: Undefined offset: 4 in
> > c:\www\htdocs\demos\havasuinternet\havasuinternet-lib.php on line 247
> > Warning: Undefined offset: 3 in
> > c:\www\htdocs\demos\havasuinternet\havasuinternet-lib.php on line 247
> > Warning: Undefined offset: 2 in
> > c:\www\htdocs\demos\havasuinternet\havasuinternet-lib.php on line 247
> > Warning: Undefined offset: 1 in
> > c:\www\htdocs\demos\havasuinternet\havasuinternet-lib.php on line 247
> >
> >
> > Here is the code, could someone tell me what's wrong. I don't see
anything
> > wrong...
> >
> > function HistoricalStock($sym) {
> >  $LookupURL =
> >
>
"http://table.finance.yahoo.com/table.csv?a=7&b=1&c=2002&d=7&e=17&f=2002&s=$
> > sym&y=0&g=d&ignore=.csv";
> >  $Results = implode('', file("$LookupURL"));
> >  $Data = explode("\n", $Results);
> >  print ' > bgcolor="#6699cc">';
> >  foreach($Data as $Line) {
> >   list($H_Date, $H_Open, $H_High, $H_Low, $H_Close, $H_Volume) =
> split(",",
> > $Line);
> >   print "
> >
> >
>
$H_Date\n$H_Open\n$H_High\n$H_Low\n$
> > H_Close\n$H_Volume\n";
> >   }
> >  print '';
> > }
> >
> >
>
>



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




[PHP] Code errors

2002-07-18 Thread Chris Crane

I am trying some code and it works except I get the following errors...
Warning: Undefined offset: 5 in
c:\www\htdocs\demos\havasuinternet\havasuinternet-lib.php on line 247
Warning: Undefined offset: 4 in
c:\www\htdocs\demos\havasuinternet\havasuinternet-lib.php on line 247
Warning: Undefined offset: 3 in
c:\www\htdocs\demos\havasuinternet\havasuinternet-lib.php on line 247
Warning: Undefined offset: 2 in
c:\www\htdocs\demos\havasuinternet\havasuinternet-lib.php on line 247
Warning: Undefined offset: 1 in
c:\www\htdocs\demos\havasuinternet\havasuinternet-lib.php on line 247


Here is the code, could someone tell me what's wrong. I don't see anything
wrong...

function HistoricalStock($sym) {
 $LookupURL =
"http://table.finance.yahoo.com/table.csv?a=7&b=1&c=2002&d=7&e=17&f=2002&s=$
sym&y=0&g=d&ignore=.csv";
 $Results = implode('', file("$LookupURL"));
 $Data = explode("\n", $Results);
 print '';
 foreach($Data as $Line) {
  list($H_Date, $H_Open, $H_High, $H_Low, $H_Close, $H_Volume) = split(",",
$Line);
  print "

$H_Date\n$H_Open\n$H_High\n$H_Low\n$
H_Close\n$H_Volume\n";
  }
 print '';
}



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




[PHP] Re: Includes vs. Functions

2002-07-17 Thread Chris Crane

I am not sure about efficiency, myself and I often ask this without much if
anything at all for a response. However, I am the opposite of you, in that I
prefer to create a library file containing all the functions. To make
developing the page in something like Dreamweaver or Frontpage easier, I
global all the variables of a given function, like say Function
StockQuote($sym) { }. They I include the library file in my PHP
webpage.Something like this...



~blah




various html
~blah
~blah


~blah
~blah



In the library file, I global the variables;

function StockQuote($sym) {

global $Stock_LastPrice, $Stock_Position;
get the data...
do something with the data...
$Stock_LastPrice = This minus that blah blah;
}

I can use this variable anywhere I would like and it is very WYSIWYG
friendly.

I am not sure how efficient it is though as I mentioned above.



"Monty" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I generally prefer to include various blocks of code in templates using
> include_once() rather than load a functions library and make calls to
those
> functions within the script.
>
> Is there a big difference in efficiency and speed of includes vs. custom
> functions? I like includes because it's easier to drop blocks of code in a
> page design without disrupting the design of the page very much.
>
> Thanks,
>
> Monty
>



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




Re: [PHP] Someone Help please

2002-07-17 Thread Chris Crane

I will try it now...Thank you.
"John Holmes" <[EMAIL PROTECTED]> wrote in message
000301c22dbe$b5caacf0$b402a8c0@mango">news:000301c22dbe$b5caacf0$b402a8c0@mango...
> File() will read the file into an array, each element of the array will
> be a line from the file. Explode() will then split that line by the
> delimiter you choose...
>
> So something like this:
>
> $file = file("filename.txt");
> foreach($file as $line)
> {
>   $part = explode(',',$line);
>   //now you have an array, $part[],
>   //that holds each element of the
>   //current line, do what you will
> }
>
> ---John Holmes...
>
> > -Original Message-
> > From: Chris Crane [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, July 17, 2002 1:17 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] Someone Help please
> >
> > I am getting data froma website for stock information. If I type in
> the
> > brower the URL I get a text file display list this;
> >
> > Date,Open,High,Low,Close,Volume
> > 16-Jul-02,7.92,8.10,7.68,7.82,605500
> > 15-Jul-02,7.98,8.02,7.59,8.02,577200
> > 12-Jul-02,7.80,8.00,7.57,7.95,411100
> > 11-Jul-02,7.82,7.94,7.34,7.80,802400
> >
> > Now I want to break each line and then seperate each line by the
> commas.
> > The
> > amount of linesin the file is never known so I assume I have to use
> > something like a foreach or while statement,but I am not sure the best
> way
> > to do it. This is what I have so far.
> >
> >  $Symbol = "IKN"; $LookupUrl =
> > "http://demos.inxdesign.com/download?sym=$Symbol&format=.txt";;
> $Results =
> > implode('', file("$LookupUrl"));
> >  $Data = array(); split("\n", $Results) = array_push($Data, $line)
> >
> > The end result I am trying to get is each line to be an element in an
> > array.
> > Later I will go back and stepthrough each element of the array and
> then
> > split that by the commas and have it output into an HTML table.At
> least
> > this
> > is the best way I can think to deal with it. I suppose a better way to
> do
> > this would be to make this an associative array and have the data of
> each
> > line be associated with the date then I could producea variable
> something
> > like $StockData[16-Jul-02][value], but I don't know how to do any of
> that.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > 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] Someone Help please

2002-07-17 Thread Chris Crane

I am getting data froma website for stock information. If I type in the
brower the URL I get a text file display list this;

Date,Open,High,Low,Close,Volume
16-Jul-02,7.92,8.10,7.68,7.82,605500
15-Jul-02,7.98,8.02,7.59,8.02,577200
12-Jul-02,7.80,8.00,7.57,7.95,411100
11-Jul-02,7.82,7.94,7.34,7.80,802400

Now I want to break each line and then seperate each line by the commas. The
amount of linesin the file is never known so I assume I have to use
something like a foreach or while statement,but I am not sure the best way
to do it. This is what I have so far.

 $Symbol = "IKN"; $LookupUrl =
"http://demos.inxdesign.com/download?sym=$Symbol&format=.txt";; $Results =
implode('', file("$LookupUrl"));
 $Data = array(); split("\n", $Results) = array_push($Data, $line)

The end result I am trying to get is each line to be an element in an array.
Later I will go back and stepthrough each element of the array and then
split that by the commas and have it output into an HTML table.At least this
is the best way I can think to deal with it. I suppose a better way to do
this would be to make this an associative array and have the data of each
line be associated with the date then I could producea variable something
like $StockData[16-Jul-02][value], but I don't know how to do any of that.










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




[PHP] ARRAY_PUSH()

2002-07-17 Thread Chris Crane

I am getting data froma website for stock information. If I type in the
brower the URL I get a text file display list this;

Date,Open,High,Low,Close,Volume
16-Jul-02,7.92,8.10,7.68,7.82,605500
15-Jul-02,7.98,8.02,7.59,8.02,577200
12-Jul-02,7.80,8.00,7.57,7.95,411100
11-Jul-02,7.82,7.94,7.34,7.80,802400

Now I want to break each line and then seperate each line by the commas. The
amount of linesin the file is never known so I assume I have to use
something like a foreach or while statement,but I am not sure the best way
to do it. This is what I have so far.

 $Symbol = "IKN"; $LookupUrl =
"http://demos.inxdesign.com/download?sym=$Symbol&format=.txt";; $Results =
implode('', file("$LookupUrl"));
 $Data = array(); split("\n", $Results) = array_push($Data, $line)

The end result I am trying to get is each line to be an element in an array.
Later I will go back and stepthrough each element of the array and then
split that by the commas and have it output into an HTML table.At least this
is the best way I can think to deal with it. I suppose a better way to do
this would be to make this an associative array and have the data of each
line be associated with the date then I could producea variable something
like $StockData[16-Jul-02][value], but I don't know how to do any of that.








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




[PHP] File reading help with Syntax

2002-07-17 Thread Chris Crane

I am getting data froma website for stock information. If I type in the
brower the URL I get a text file display list this;

Date,Open,High,Low,Close,Volume
16-Jul-02,7.92,8.10,7.68,7.82,605500
15-Jul-02,7.98,8.02,7.59,8.02,577200
12-Jul-02,7.80,8.00,7.57,7.95,411100
11-Jul-02,7.82,7.94,7.34,7.80,802400

Now I want to break each line and then seperate each line by the commas. The
amount of linesin the file is never known so I assume I have to use
something like a foreach or while statement,but I am not sure the best way
to do it. This is what I have so far.

 $Symbol = "IKN"; $LookupUrl =
"http://demos.inxdesign.com/download?sym=$Symbol&format=.txt";; $Results =
implode('', file("$LookupUrl"));
 $Data = array(); split("\n", $Results) = array_push($Data, $line)

The end result I am trying to get is each line to be an element in an array.
Later I will go back and stepthrough each element of the array and then
split that by the commas and have it output into an HTML table.At least this
is the best way I can think to deal with it. I suppose a better way to do
this would be to make this an associative array and have the data of each
line be associated with the date then I could producea variable something
like $StockData[16-Jul-02][value], but I don't know how to do any of that.






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




Re: [PHP] Is there a way?

2002-07-16 Thread Chris Crane

Ok so let me ask one last question..
Which it faster, to run my function and part of the function would be to get
data from a website and break it into variables then make all the html and
variables one new variable for printing

or

Get my data put into variables made global and then in my HTML page use tags
like .

The last one is easier to design with, but may slow things down each time it
has to parse out the PHP tag, no?




"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
001a01c22cf3$ef2e01c0$8102a8c0@niigziuo4ohhdt">news:001a01c22cf3$ef2e01c0$8102a8c0@niigziuo4ohhdt...
> [snip]
> In Perl you could print a block of information as it was written like
this;
> print <
> This a whole bunch of HTML code!!!
>
> HTML_END
>
> The best part about this, was that you did not have to escape your " and
you
> could mix in your variables making it easy to design and layout the HTML.
Is
> there a similiar way to do this in PHP?
> [/snip]
>
> $variable = <<< HERE
>
> all kinds of stuff
>
> HERE;
>
> print("$variable");
>
> HTH!
>
> Jay
>
> "Two wrongs are only the beginning"
>
> *
> * Want to meet other PHP developers *
> * in your area? Check out:  *
> * http://php.meetup.com/*
> * No developer is an island ... *
> *
>
>



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




[PHP] Is there a way?

2002-07-16 Thread Chris Crane

In Perl you could print a block of information as it was written like this;
print 

Re: [PHP] Classes vs. Functions

2002-07-16 Thread Chris Crane
;opendbconnection();
> }
> $this->setsql("BEGIN");
> $this->qry = mysql_query($this->sql);
> if (!$this->qry) {
> return false;
> } else {
> return true;
> }
> }
>
> function rollback( ) {
> if ($this->dbconnection == $FALSE) {
> $this->opendbconnection();
> }
> $this->setsql("ROLLBACK");
> $this->qry = mysql_query($this->sql);
> if (!$this->qry) {
> return false;
> } else {
> return true;
> }
> }
>
> function commit( ) {
> if ($this->dbconnection == $FALSE) {
> $this->opendbconnection();
> }
> $this->setsql("COMMIT");
> $this->qry = mysql_query($this->sql);
> if (!$this->qry) {
> return false;
> } else {
> return true;
> }
> }
>
> function selectquery() {
>
> global $TRUE, $FALSE;
>
> if ($this->dbconnection == $FALSE) {
> $this->opendbconnection();
> }
> $this->qry = mysql_query($this->sql);
> if (!$this->qry) {
> return false;
> } else {
> $this->numberrows = mysql_num_rows($this->qry);
> if ($this->numberrows > 0) {
> for($x = 0; $x < $this->numberrows; $x++) {
> $this->result[$x] = mysql_fetch_row($this->qry);
> }
> } else {
> //echo("[Error:] Retrieving data");
> return false;
> }
> return true;
> }
> }
>
> function insertquery() {
>
> global $TRUE, $FALSE;
>
> if ($this->dbconnection == $FALSE) {
> $this->opendbconnection();
> }
>
>$this->qry = mysql_query($this->sql);
>if (!$this->qry) {
>return false;
>} else {
>return true;
>}
> }
>
> function deletequery() {
>
> global $TRUE, $FALSE;
>
> if ($this->dbconnection == $FALSE) {
> $this->opendbconnection();
> }
>
>$this->qry = mysql_query($this->sql);
>if (!$this->qry) {
>return false;
>} else {
>return true;
>}
> }
>
> function updatequery() {
>
> global $TRUE, $FALSE;
>
> if ($this->dbconnection == $FALSE) {
> $this->opendbconnection();
> }
>
>$this->qry = mysql_query($this->sql);
>if (!$this->qry) {
>return false;
>    } else {
>return true;
>}
> }
>
> }
>
> ?>
>
> And now in any .php file you include this .obj file and use it as follows.
>
> $db1 = new mysqldb(); // create a new instance of the mysql object.
>   // You can create as many as you want and
> the great thing is
>   // that each instances vars will contain
> there own data.
>
> $sql = "Insert into ...";
> $db1->setTransactionSwitch("true");
> $db1->begin();  //this will begin a transaction (InnoDb or BDB tables
> are required for this)
>  $db1->setsql($sql);  //set the objects $sql variable.
>   if (!$db1->insertquery())  //now call the method that
does
> all the work so
> $db1->setTransactionSwitch("false"); //you don't have to recode
it.
> If it fails roolback.
>  if($db1->getTransactionSwitch()=="false");{
> $db1->rollback();
>  }else{
> $db1->commit();
>  }
>
>  Classes allow you to have multple instances of an object containing
> seperate info, makes it easier to keep track of.
> Hope this helps,
> Steve.
>
> -Original Message-
> From: Chris Crane [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 16, 2002 11:07 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Classes vs. Functions
>
>
> It helps a little bit, thank you. Could you provide some code as to what a
> Class looks like. I am just trying to understand it better and if I see
it,
> it might help.
> "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
> 000401c22cd8$54ce9ce0$8102a8c0@niigziuo4ohhdt">news:000401c22cd8$54ce9ce0$8102a8c0@niigziuo4ohhdt...
> > [snip]
>

Re: [PHP] Classes vs. Functions

2002-07-16 Thread Chris Crane

thanks Jay.
"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
000e01c22cdd$0d0c7530$8102a8c0@niigziuo4ohhdt">news:000e01c22cdd$0d0c7530$8102a8c0@niigziuo4ohhdt...
> [snip]
> This helps quite a bit Thank you.
> I am just wondering if I should make classes instead of functions? What
> would be the benefit of that? Do you know?
> [/snip]
>
> You should keep classes and functions seperate in your thought process,
they
> are not the same and not meant to do or be the same thing. Here is a good
> thought process to apply to classes...
>
> 1. Is this an object?
>
> If the answer is no, you do not need a class.
>
> 2. Do I need to do something (have an action or set of actions performed),
> perhaps over and over again?
>
> If the answer is yes, this is a function.
>
> A method is a function that applies to a specific class of objects. If you
> created a class and methods for each item you code would be bloated, slow,
> and hard to maintain.
>
> Do not think of functions and classes in the same light, you will make
> yourself more confused. One is definitely not the other.
>
> Jay
>
> *
> * Want to meet other PHP developers *
> * in your area? Check out:  *
> * http://php.meetup.com/*
> * No developer is an island ... *
> *
>
>



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




Re: [PHP] Classes vs. Functions

2002-07-16 Thread Chris Crane

Is there an advantage to Classes vs. Functions?
"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
000c01c22cdb$11485c10$8102a8c0@niigziuo4ohhdt">news:000c01c22cdb$11485c10$8102a8c0@niigziuo4ohhdt...
> [snip]
> example?
> [/snip]
>
> http://www.devshed.com/Server_Side/PHP/FormValidatorClass/page1.html
>
> Good tutorial
>
> Jay
>
> *
> * Want to meet other PHP developers *
> * in your area? Check out:  *
> * http://php.meetup.com/*
> * No developer is an island ... *
> *
>
>



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




Re: [PHP] Classes vs. Functions

2002-07-16 Thread Chris Crane

This helps quite a bit Thank you.
I am just wondering if I should make classes instead of functions? What
would be the benefit of that? Do you know?

"Martin Clifford" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Here is a sample code (don't take this as gospel... Jay knows more about OOP
than I do, I'm sure!):

class Car {
var $make;
var $model;

function setMake($x) {
$this->make = $x;
}
function setModel($y) {
$this->model = $y;
}
}

$make and $model are the properties of the Car class, and setMake() and
setModel() are the methods of the Car class.  You don't actually get an
object until make a *new* one.  Like this:

$passat = new Car;
$passat->setMake("Volkswagen");
$passat->setModel("Passat");

This assigns the new object, "passat", the properties relating to it's make
and model, using the methods setMake and setModel.  I'm sure this is right,
but I'm sure I'm probably wrong (hehe, confused?).  I'm also sure someone
will correct me if I am! :o)

Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/


>>> "Chris Crane" <[EMAIL PROTECTED]> 07/16/02 11:06AM >>>
It helps a little bit, thank you. Could you provide some code as to what a
Class looks like. I am just trying to understand it better and if I see it,
it might help.
"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
000401c22cd8$54ce9ce0$8102a8c0@niigziuo4ohhdt">news:000401c22cd8$54ce9ce0$8102a8c0@niigziuo4ohhdt...
> [snip]
> Could someone please explain the difference between classes and functions
> and how to use a class. I write alot of PHP, but I never understood this
at
> all. I use an include statement in many of my pages and include a file
with
> a bunch of functions. For instance, I might have a function called
stock();
> In the page I am using I include the file that has this function and I
call
> it like this:
>
> stock($Sym);
>
> I am wondering if I am doing it the wrong way. So I need to better
> understand classes. What is one, and why would you use it?
> [/snip]
>
> A class is the representation of an object, such as a person, place, or
> thing.
> A function is a group of commands that can be called for a specific
purpose.
>
> function addNumbers()
>
> A function can be performed on an object, but an object (the logical
> extension of class) cannot be performed on a function. Does that help?
>
> Jay
>
> "Cleverly disguised as a responsible adult"
>
> *
> * Want to meet other PHP developers *
> * in your area? Check out:  *
> * http://php.meetup.com/*
> * No developer is an island ... *
> *
>
>



--
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] Classes vs. Functions

2002-07-16 Thread Chris Crane

It helps a little bit, thank you. Could you provide some code as to what a
Class looks like. I am just trying to understand it better and if I see it,
it might help.
"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
000401c22cd8$54ce9ce0$8102a8c0@niigziuo4ohhdt">news:000401c22cd8$54ce9ce0$8102a8c0@niigziuo4ohhdt...
> [snip]
> Could someone please explain the difference between classes and functions
> and how to use a class. I write alot of PHP, but I never understood this
at
> all. I use an include statement in many of my pages and include a file
with
> a bunch of functions. For instance, I might have a function called
stock();
> In the page I am using I include the file that has this function and I
call
> it like this:
>
> stock($Sym);
>
> I am wondering if I am doing it the wrong way. So I need to better
> understand classes. What is one, and why would you use it?
> [/snip]
>
> A class is the representation of an object, such as a person, place, or
> thing.
> A function is a group of commands that can be called for a specific
purpose.
>
> function addNumbers()
>
> A function can be performed on an object, but an object (the logical
> extension of class) cannot be performed on a function. Does that help?
>
> Jay
>
> "Cleverly disguised as a responsible adult"
>
> *
> * Want to meet other PHP developers *
> * in your area? Check out:  *
> * http://php.meetup.com/*
> * No developer is an island ... *
> *
>
>



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




[PHP] Classes vs. Functions

2002-07-16 Thread Chris Crane

Could someone please explain the difference between classes and functions
and how to use a class. I write alot of PHP, but I never understood this at
all. I use an include statement in many of my pages and include a file with
a bunch of functions. For instance, I might have a function called stock();
In the page I am using I include the file that has this function and I call
it like this:

stock($Sym);

I am wondering if I am doing it the wrong way. So I need to better
understand classes. What is one, and why would you use it?

Thanks.



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