[PHP] Re: problems with looping array

2001-12-03 Thread Jim Musil


First, make sure $item[$index] has anything in it by inserting an 
echo $item[$index].

You also have to prepend item_number with the table name as in ar.item_number.

Try single quotes around $item[$index], too.

If $index is a name, I've had trouble in the past getting associative 
arrays to resolve correctly inside strings. Try using this ...

 $result = mysql_query(SELECT * FROM ar
LEFT JOIN company on ar.company_id=company.company_id
LEFT JOIN scale on ar.scale_id=scale.scale_id
WHERE ar.item_number = '.$item[$index].');


I tried but nothing different happened.  I'm still playing though and I'll
see if I can make it work.  I'm new to all of this...so we'll see how it
goes.  Thanks for your help.

-jordan


Fred [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Strings in your sql query must be quoted.  Try this instead:

  $result = mysql_query(SELECT * FROM ar
  LEFT JOIN company on ar.company_id=company.company_id
  LEFT JOIN scale on ar.scale_id=scale.scale_id
  WHERE item_number = \$item[$index]\);

  Fred

  Jordan [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   here's the situation.  I'm making a shopping cart, when an item is added
   it's item number is added into an array.  I then want this array's items
  to
   be compared agains the database.  Unfortunately I haven't been able to
use
  a
   variable in the query string of MySQL.  something along the lines of
  
  
   ?PHP
  
  include ('connect.php');
  
  $result = mysql_query(SELECT * FROM ar
  LEFT JOIN company on ar.company_id=company.company_id
  LEFT JOIN scale on ar.scale_id=scale.scale_id
  WHERE item_number = . $item[$index]);
  
   ?
  
   where $item is the array of item numbers and $index is an auto
  incrementing
   number that increments at the end of the loop.  Please help if you know
of
   anyway to use this variable.  Also, I can post my whole script if
  needed...I
   just didn't want unneeded info posted.  Thanks in advance.
  
   -Jordan
  
  





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


-- 
Jim Musil
-
Multimedia Programmer
Nettmedia
-
212-629-0004
[EMAIL PROTECTED]

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




Re: [PHP] URGENT-HELP !!!!!!

2001-11-30 Thread Jim Musil


If you mail via pfsockopen, then you specify the sender which must be 
real, but you also specify the From: header which can be anything you 
want.

ex:

$smtp_server = your.smtp.server;
$port = 25;
$mydomain = yourdomain.com;
$sender = [EMAIL PROTECTED];
$recipient = [EMAIL PROTECTED];
$subject = Test;

$text_content = Hi Bar, This is a test.;

$handle = fsockopen($smtp_server,$port);
fputs($handle, HELO $mydomain\n);
fputs($handle, MAIL FROM: $sender \n);
$echo .=  fgets($handle,255).\n;
fputs($handle, RCPT TO: $recipient \n);
$echo .=  fgets($handle,255).\n;
fputs($handle, DATA\n);
$echo .= fgets($handle,255).\n;
fputs($handle, To: $recipient\n);

/* NOTE THAT HERE YOU SET WHAT APPEARS IN THE FROM: PART */

fputs($handle, From: \n);


fputs($handle, Subject: $email_subject\n);
fputs($handle, Content-Type: text/plain; \n);

fputs($handle, $text_content.\n\n);

fputs($handle, .\n);

$echo .= fgets($handle,255).\n;

fputs($handle, QUIT\n);

$echo .= fgets($handle,255).\n;

echo $echo;

Works here, but results may vary.


I am talking about the final SMTP host.. it will do a reverse lookup on the
From: domain and if it dont resolve to the IP of the sending STMP host it
will reject it.

yes I know. But it the final SMTP tries to resolve the host 
(localhost) it will get a response from it self? I haven't tried it, 
but I think it would work.

By the way... the most of the SMTP doesn't check at the FROM header, 
but from the sender SMTP.
So if you got a nonexisting e-mail it would accept it too, but it 
the sender host isn't valid it will reject it.

Regards,

Johan


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


-- 
Jim Musil
-
Multimedia Programmer
Nettmedia
-
212-629-0004
[EMAIL PROTECTED]

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




[PHP] Speed of Images from DB

2001-11-30 Thread Jim Musil


I've been searching for the best way to store images that would be 
used in a dynamic site. In this situation, a site admin would upload 
images via a php script. Obviously this creates several problems.

To prevent naming problems, I have php name all the uploaded images 
and store the name in a mysql db. Then, when needed, php will query 
to get the name and insert the image name into the image tag. This 
has always seemed like an incomplete solution because it's hard to 
manage the files later.

Using mySQL to do the whole thing is appealing. I've never tried 
storing the actual data in my mysql db. It seems like it would be too 
slow to query, transfer, and passthru.

Does anyone have any wisdom on this subject?


-- 
Jim Musil
-
Multimedia Programmer
Nettmedia
-
212-629-0004
[EMAIL PROTECTED]

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




Re: [PHP] Stuck on array, need a little help.

2001-11-30 Thread Jim Musil

Your script is working like you are asking it to ...


Change ...

 while (list($val, $key)=each($bikes[$sub_cat])) {

To ...

 while (list($key, $val)=each($bikes[$sub_cat])) {

and it should work like you WANT it to ...

I'm stuck. $key returns Array how can I get at each
level of this array?

if ($cat == 'bikes'  $sub_cat != 'Road') {
 while (list($val, $key)=each($bikes[$sub_cat])) {
 echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\ HEIGHT=\1\
ALT=\\ BORDER=\0\/TD\n;
 echo TDA HREF=\$key\ CLASS=\menu\$val/A/TD\n;

$bikes = array(
  Road  = array(
   Trek  = array(
 Trek 5200 = road.php?brand=t5200
 ),
   LeMond = array(
 Zurich = road.php?brand=zurich,
 Chambery = road.php?brand=chambery,
 Alpe d'Huez = road.php?brand=alpe,
 BuenosAries = road.php?brand=bueno,
 Tourmalet = road.php?brand=tourmalet
 ),
   Moots = array(
 VaMoots  = road.php?brand=vamoots
 )
  ),
  Mountain  = array(
   Trek  = array(
 Fuel 100 = mountain.php?brand=tfuel90,
 Fuel 90  = mountain.php?brand=schhg
 ),
   Klein = array(
 bike 1 = URL,
 bike 2 = URL
 ),
   Gary Fisher = array(
 bike 1 = URL,
 bike 2 = URL
 ),
   Moots = array(
 bike 1 = URL,
 bike 2 = URL
 )
  ),


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


-- 
Jim Musil
-
Multimedia Programmer
Nettmedia
-
212-629-0004
[EMAIL PROTECTED]

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




RE: [PHP] Stuck on array, need a little help.

2001-11-30 Thread Jim Musil



The script is still working right, you just need to nest another 
while loop into your current while loop.

Like so ...

if ($cat == 'bikes'  $sub_cat != 'Road') {
  while (list($val, $key)=each($bikes[$sub_cat])) {

echo trtd$val/td;

while (list($sub_val, $sub_key) = each($key)) {


  echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\
  HEIGHT=\1\
  ALT=\\ BORDER=\0\/td\n;
  echo TDA HREF=\$sub_key\ CLASS=\menu\$sub_val/a/td\n;


}
}
}

alternatively, if you know specifically what you want you could do this ...

if ($cat == 'bikes'  $sub_cat != 'Road') {
  while (list($val, $key)=each($bikes[$sub_cat][Trek])) {



  echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\
  HEIGHT=\1\
  ALT=\\ BORDER=\0\/td\n;
  echo TDA HREF=\$key\ CLASS=\menu\$val/a/td\n;



}
}



No, all that will do is reverse the placement
of the values. So now it prints out Array
and puts the item in the URL. Still the same problem.


  -Original Message-
  From: Jim Musil [mailto:[EMAIL PROTECTED]]
  Sent: Friday, November 30, 2001 4:54 PM
  To: [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Subject: Re: [PHP] Stuck on array, need a little help.


  Your script is working like you are asking it to ...


  Change ...

   while (list($val, $key)=each($bikes[$sub_cat])) {

  To ...

   while (list($key, $val)=each($bikes[$sub_cat])) {

  and it should work like you WANT it to ...

  I'm stuck. $key returns Array how can I get at each
  level of this array?
  
  if ($cat == 'bikes'  $sub_cat != 'Road') {
   while (list($val, $key)=each($bikes[$sub_cat])) {
   echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\
  HEIGHT=\1\
  ALT=\\ BORDER=\0\/TD\n;
   echo TDA HREF=\$key\ CLASS=\menu\$val/A/TD\n;
  
  $bikes = array(
Road  = array(
 Trek  = array(
   Trek 5200 = road.php?brand=t5200
   ),
 LeMond = array(
   Zurich = road.php?brand=zurich,
   Chambery = road.php?brand=chambery,
   Alpe d'Huez = road.php?brand=alpe,
   BuenosAries = road.php?brand=bueno,
   Tourmalet = road.php?brand=tourmalet
   ),
 Moots = array(
   VaMoots  = road.php?brand=vamoots
   )
),
Mountain  = array(
 Trek  = array(
   Fuel 100 = mountain.php?brand=tfuel90,
   Fuel 90  = mountain.php?brand=schhg
   ),
 Klein = array(
   bike 1 = URL,
   bike 2 = URL
   ),
 Gary Fisher = array(
   bike 1 = URL,
   bike 2 = URL
   ),
 Moots = array(
   bike 1 = URL,
   bike 2 = URL
   )
),
  
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]


  --
  Jim Musil
  -
  Multimedia Programmer
  Nettmedia
  -
  212-629-0004
  [EMAIL PROTECTED]

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


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


-- 
Jim Musil
-
Multimedia Programmer
Nettmedia
-
212-629-0004
[EMAIL PROTECTED]

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




Re: [PHP] database question

2001-11-29 Thread Jim Musil

\S refers to a non whitespace character.


In the following:
select whatever from articles where textlines regexp ^\Sbingo\S$

what does \S means?

py


- Original Message -
From: Jon Farmer [EMAIL PROTECTED]
To: Warren Vail [EMAIL PROTECTED]; Michael Hall
[EMAIL PROTECTED]; PHP List [EMAIL PROTECTED]
Sent: Thursday, November 29, 2001 9:54 AM
Subject: Re: [PHP] database question


  Actually the sql statement you want is

  select whatever from articles where textlines regexp ^\Sbingo\S$

  regards

  Jon
  --
  Jon Farmer
  Systems Programmer, Entanet www.enta.net
  Tel 01952 428969 Mob 07763 620378
  PGP Key available, send email with subject: Send PGP Key


  - Original Message -
  From: Warren Vail [EMAIL PROTECTED]
  To: Michael Hall [EMAIL PROTECTED]; PHP List
  [EMAIL PROTECTED]
  Sent: Thursday, November 29, 2001 2:57 PM
  Subject: RE: [PHP] database question


  Try;

  SELECT whatever FROM articles WHERE textlines LIKE %searchword%

  Two warnings;

  1) This will force a table scan (the contents of each row in the entire
  table because there can be no index to support faster searching of
contents
  that float in the column) which will be very slow on a large database
(even
  a medium size one).
  2) This will also find words that exist inside other words. (ie the word
  ward exists inside toward)  If you try to solve this by imbedding
blanks
  between the wildcard (%) and the text, you will probably not be able to
find
  the word at the end of a line, or just prior to a comma or period.

  I also believe there may be a way to make the search case insensitive,
look
  for something like a  WHERE tolower(textlines) LIKE ... to force the
  column values to be all lower case and make sure your search values are
all
  lower case as well.

  Good luck,

  Warren Vail

  -Original Message-
  From: Michael Hall [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, November 29, 2001 2:21 PM
  To: PHP List
  Subject: [PHP] database question


  How can I search a MySQL database field that contains sentences (VARCHAR
  datatype) or entire texts (TEXT datatype) for single words?

  Let's say I want to search 100 articles stored in a database field as TEXT
  for the word bingo, is there any SQL or PHP way of doing that?

  Mick

  --
  
  Michael Hall
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  http://openlearningcommunity.org



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



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



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



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


-- 
Jim Musil
-
Multimedia Programmer
Nettmedia
-
212-629-0004
[EMAIL PROTECTED]

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