[PHP] Re: Reading from a COM port in Windows blows up

2009-03-15 Thread Manuel Lemos
Hello,

on 03/15/2009 01:56 AM Matt Neimeyer said the following:
   $ComPort = fopen(COM1, wb+);

I suspect all this does is opening a file named COM1 . Shouldn't that be
 COM1: instead of just COM1?

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



[PHP] how can genrate different URLs but showing same html page

2009-03-15 Thread rahulb

Hi, I am developing forum website as my final year project. I am having
problem in generating different URLs but keeping the same page..

Scenario: I am showing threads for different languages in different page,
but since format of data is same for threads of all the languages, so what i
planned was, to write one single xhtml page, which will be populated by data
at run time using php/mysql. but i want to show different URLs for different
languages thread, even when same html page is called.

i am taking the reference of bytes.com for this design.

i would be really grateful for any help in this.

thanks in advance.

-- 
View this message in context: 
http://www.nabble.com/how-can-genrate-different-URLs-but-showing-same-html-page-tp22520985p22520985.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



[PHP] GeoIP?

2009-03-15 Thread Michelle Konzack
Hello,

I am in creation of a WaveLAN service in Germany  and  my  HTML-Form  is
DoS'ed be idiots outside of Germany.  Can someone tell me how to prevent
peoples, filling out the form without being in Germany?

Note: I do not want to load the whole GeoIP Database in my scripts.

Or is there a Free Online-Service which can do this?

If not, it would be a nice project to start and could work like the RBL.


Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
http://www.tamay-dogan.net/ Michelle Konzack
http://www.can4linux.org/   Apt. 917
http://www.flexray4linux.org/   50, rue de Soultz
Jabber linux4miche...@jabber.ccc.de   67100 Strasbourg/France
IRC #Debian (irc.icq.com) Tel. DE: +49 177 9351947
ICQ #328449886Tel. FR: +33  6  61925193


signature.pgp
Description: Digital signature


[PHP] Re: GeoIP?

2009-03-15 Thread Michelle Konzack
Forgotten one thing:

Am 2009-03-15 13:52:52, schrieb Michelle Konzack:
 Hello,
 
 I am in creation of a WaveLAN service in Germany  and  my  HTML-Form  is
 DoS'ed be idiots outside of Germany.  Can someone tell me how to prevent
 peoples, filling out the form without being in Germany?
 
 Note: I do not want to load the whole GeoIP Database in my scripts.
 
 Or is there a Free Online-Service which can do this?
 
 If not, it would be a nice project to start and could work like the RBL.
 END OF REPLIED MESSAGE 

Yes, I  KNOW  http://search.cpan.org/~borisz/Geo-IP-1.37/lib/Geo/IP.pm
and I have tried to implement it in PHP, but it is very slow...

Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
http://www.tamay-dogan.net/ Michelle Konzack
http://www.can4linux.org/   Apt. 917
http://www.flexray4linux.org/   50, rue de Soultz
Jabber linux4miche...@jabber.ccc.de   67100 Strasbourg/France
IRC #Debian (irc.icq.com) Tel. DE: +49 177 9351947
ICQ #328449886Tel. FR: +33  6  61925193


signature.pgp
Description: Digital signature


Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread tedd

At 6:31 PM -0700 3/14/09, Richard Kurth wrote:

I have a script that is passing a area in a $_POST and it does not pass
the data. When I try to look at the data with $_POST['fieldorder'] it
its empty but when I look at it with $_REQUEST['fieldorder'] the data is
there. This seams very strange to me. It has been working for about 6
months with no problem and then all of a sudden it does not pass the
data anymore. The real funny thing is the rest of the data that is sent
that is not an area gets past in a $_POST works just fine.Would there be
something in the php.ini file that I have changed that would case this.


What method is your form using?

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] left join does not work, why?

2009-03-15 Thread PJ
Daniel Brown wrote:
 On Sat, Mar 14, 2009 at 19:51, PJ af.gour...@videotron.ca wrote:
   
 $sql1 = SELECT b.id, b.title, b.sub_title, b.descr, b.comment,
 b.bk_cover, b.copyright, b.ISBN, b.language, b.sellers, c.publisher, ---
 CONCAT_WS(' ', first_name, last_name) AS Author
 FROM book AS b
 LEFT JOIN book_author AS ab ON b.id = ab.bookID
 LEFT JOIN author AS a ON ab.authID=a.id
 LEFT JOIN book_publisher as abc ON b.id = abc.bookID // ---
 LEFT JOIN publishers AS c ON abc.publishers_id = c.id // ---
 ORDER BY title ASC ;
 $result1 = mysql_query($sql1, $db);
 $bookCount = mysql_num_rows($result1);
 

 For this and future problems of a similar nature, the quickest and
 easiest way to start debugging is to change the mysql_query() line to
 output the error.  Like so:

 ?php
 // 
 $result1 = mysql_query($sql1,$db) or die(SQL: .$sql1.\n.mysql_error());
 // 
 ?

 If the query fails on $sql1, PHP runs the 'or' as a failure
 fallback and dies by printing the SQL query given and MySQL's error
 response.
   
Thank you for that. I had not used that as I thought that
error_reporting(E_ALL);
ini_set('display_errors', 1);
would be enough.   =-O

The error reported now is to check the syntax near the commented out lines.
So, what is going on here? I understood that when the lines are
commented out they are not lprocessed.
When I deleted the commented out lines the errors went away.
This does not make sense and obviously could be very misleading in
debugging.


-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



Re: [PHP] GeoIP?

2009-03-15 Thread tedd

At 1:52 PM +0100 3/15/09, Michelle Konzack wrote:

Hello,

I am in creation of a WaveLAN service in Germany  and  my  HTML-Form  is
DoS'ed be idiots outside of Germany.  Can someone tell me how to prevent
peoples, filling out the form without being in Germany?

Note: I do not want to load the whole GeoIP Database in my scripts.

Or is there a Free Online-Service which can do this?

If not, it would be a nice project to start and could work like the RBL.


Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


I'll answer, but I'm not in Germany.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] left join does not work, why?

2009-03-15 Thread 9el
---
Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get
a Free CD of Ubuntu mailed to your door without any cost. Visit :
www.ubuntu.com
--


On Sun, Mar 15, 2009 at 7:02 PM, PJ af.gour...@videotron.ca wrote:

 Daniel Brown wrote:
  On Sat, Mar 14, 2009 at 19:51, PJ af.gour...@videotron.ca wrote:
 
  $sql1 = SELECT b.id, b.title, b.sub_title, b.descr, b.comment,
  b.bk_cover, b.copyright, b.ISBN, b.language, b.sellers, c.publisher,
 ---
  CONCAT_WS(' ', first_name, last_name) AS Author
  FROM book AS b
  LEFT JOIN book_author AS ab ON b.id = ab.bookID
  LEFT JOIN author AS a ON ab.authID=a.id
  LEFT JOIN book_publisher as abc ON b.id = abc.bookID // ---
  LEFT JOIN publishers AS c ON abc.publishers_id = c.id // ---
  ORDER BY title ASC ;
  $result1 = mysql_query($sql1, $db);
  $bookCount = mysql_num_rows($result1);
 
 
  For this and future problems of a similar nature, the quickest and
  easiest way to start debugging is to change the mysql_query() line to
  output the error.  Like so:
 
  ?php
  // 
  $result1 = mysql_query($sql1,$db) or die(SQL:
 .$sql1.\n.mysql_error());
  // 
  ?
 
  If the query fails on $sql1, PHP runs the 'or' as a failure
  fallback and dies by printing the SQL query given and MySQL's error
  response.
 
 Thank you for that. I had not used that as I thought that
 error_reporting(E_ALL);
 ini_set('display_errors', 1);
 would be enough.   =-O

 The error reported now is to check the syntax near the commented out lines.
 So, what is going on here? I understood that when the lines are
 commented out they are not lprocessed.
 When I deleted the commented out lines the errors went away.


:P


 This does not make sense and obviously could be very misleading in
 debugging.


 --
 unheralded genius: A clean desk is the sign of a dull mind. 
 -
 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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




Re: [PHP] GeoIP?

2009-03-15 Thread Nitsan Bin-Nun
Take a look at this:
http://www.maxmind.com/app/geolitecountry

Use indexes, I think the checkup won't take long.

HTH,
Nitsan

On Sun, Mar 15, 2009 at 3:06 PM, tedd tedd.sperl...@gmail.com wrote:

 At 1:52 PM +0100 3/15/09, Michelle Konzack wrote:

 Hello,

 I am in creation of a WaveLAN service in Germany  and  my  HTML-Form  is
 DoS'ed be idiots outside of Germany.  Can someone tell me how to prevent
 peoples, filling out the form without being in Germany?

 Note: I do not want to load the whole GeoIP Database in my scripts.

 Or is there a Free Online-Service which can do this?

 If not, it would be a nice project to start and could work like the RBL.


 Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


 I'll answer, but I'm not in Germany.

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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




Re: [PHP] left join does not work, why?

2009-03-15 Thread Jan G.B.
2009/3/15 PJ af.gour...@videotron.ca:
 Daniel Brown wrote:
 On Sat, Mar 14, 2009 at 19:51, PJ af.gour...@videotron.ca wrote:

 $sql1 = SELECT b.id, b.title, b.sub_title, b.descr, b.comment,
 b.bk_cover, b.copyright, b.ISBN, b.language, b.sellers, c.publisher, ---
 CONCAT_WS(' ', first_name, last_name) AS Author
 FROM book AS b
 LEFT JOIN book_author AS ab ON b.id = ab.bookID
 LEFT JOIN author AS a ON ab.authID=a.id
 LEFT JOIN book_publisher as abc ON b.id = abc.bookID // ---
 LEFT JOIN publishers AS c ON abc.publishers_id = c.id // ---
 ORDER BY title ASC ;
 $result1 = mysql_query($sql1, $db);
 $bookCount = mysql_num_rows($result1);
 The error reported now is to check the syntax near the commented out lines.
 So, what is going on here? I understood that when the lines are
 commented out they are not lprocessed.
 When I deleted the commented out lines the errors went away.
 This does not make sense and obviously could be very misleading in
 debugging.


*How* are you commenting out? Mysql accepts /* such comments */, so if
you want to transform a line in your SQL query string into a comment,
you gotta do it that way.
so this is just wrong:
$x =  select *
// from foo
from bar;
and that query would be valid
SELECT this/*, that*/ from x

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



Re: [PHP] GeoIP?

2009-03-15 Thread Per Jessen
Michelle Konzack wrote:

 Hello,
 
 I am in creation of a WaveLAN service in Germany  and  my  HTML-Form 
 is
 DoS'ed be idiots outside of Germany.  Can someone tell me how to
 prevent peoples, filling out the form without being in Germany?
 
 Note: I do not want to load the whole GeoIP Database in my scripts.

The easiest is to use a DNS service - this is the best one I know:
http://countries.nerd.dk/


/Per

-- 
Per Jessen, Zürich (9.8°C)


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



[PHP] Re: GeoIP?

2009-03-15 Thread Michelle Konzack
Hello Nitsan,

Am 2009-03-15 15:39:26, schrieb Nitsan Bin-Nun:
 Take a look at this:
 http://www.maxmind.com/app/geolitecountry
 
 Use indexes, I think the checkup won't take long.

I have it installed (php5-geoip, 1.0.3-1) , but it is realy slow

OK, now I have greped for DE and the database is  now  only  9607  lines
insteed of 108166 and it is a little bit faster...  However,  it  has  a
heavy Disk-IO and I do not know, if my Hoster like such stuff.  :-/

Maybe PostgreSQL or MySQL would be better?

Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
http://www.tamay-dogan.net/ Michelle Konzack
http://www.can4linux.org/   Apt. 917
http://www.flexray4linux.org/   50, rue de Soultz
Jabber linux4miche...@jabber.ccc.de   67100 Strasbourg/France
IRC #Debian (irc.icq.com) Tel. DE: +49 177 9351947
ICQ #328449886Tel. FR: +33  6  61925193


signature.pgp
Description: Digital signature


Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Shawn McKenzie
tedd wrote:
 At 6:31 PM -0700 3/14/09, Richard Kurth wrote:
 I have a script that is passing a area in a $_POST and it does not pass
 the data. When I try to look at the data with $_POST['fieldorder'] it
 its empty but when I look at it with $_REQUEST['fieldorder'] the data is
 there. This seams very strange to me. It has been working for about 6
 months with no problem and then all of a sudden it does not pass the
 data anymore. The real funny thing is the rest of the data that is sent
 that is not an area gets past in a $_POST works just fine.Would there be
 something in the php.ini file that I have changed that would case this.
 
 What method is your form using?
 
 Cheers,
 
 tedd
 

And what is an area?  A textarea?

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Richard Kurth

tedd wrote:

At 6:31 PM -0700 3/14/09, Richard Kurth wrote:

I have a script that is passing a area in a $_POST and it does not pass
the data. When I try to look at the data with $_POST['fieldorder'] it
its empty but when I look at it with $_REQUEST['fieldorder'] the data is
there. This seams very strange to me. It has been working for about 6
months with no problem and then all of a sudden it does not pass the
data anymore. The real funny thing is the rest of the data that is sent
that is not an area gets past in a $_POST works just fine.Would there be
something in the php.ini file that I have changed that would case this.


What method is your form using?

Cheers,

tedd

It  is using POST as it always has but it just stopped working for the 
one post the one with an array in it.


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



Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Richard Kurth

Shawn McKenzie wrote:

tedd wrote:
  

At 6:31 PM -0700 3/14/09, Richard Kurth wrote:


I have a script that is passing a area in a $_POST and it does not pass
the data. When I try to look at the data with $_POST['fieldorder'] it
its empty but when I look at it with $_REQUEST['fieldorder'] the data is
there. This seams very strange to me. It has been working for about 6
months with no problem and then all of a sudden it does not pass the
data anymore. The real funny thing is the rest of the data that is sent
that is not an area gets past in a $_POST works just fine.Would there be
something in the php.ini file that I have changed that would case this.
  

What method is your form using?

Cheers,

tedd




And what is an area?  A textarea?

  
This is the form that is being sent as a post and the fieldorder[] is 
the part that is not sending properly. But it has worked for about  a 
year in the script. It just stopped working. and I did not change 
anything in this script



form action=import.php method=post
!-- form action=testimport.php method=post --
   INPUT TYPE=HIDDEN NAME=members_id VALUE=?php echo 
$_SESSION[members_id];?

   INPUT TYPE=HIDDEN NAME=copy VALUE='?php echo $_POST['copy'];?'
   INPUT TYPE=HIDDEN NAME=format VALUE=?php echo $_POST['format'];?
input type=hidden name=doit value=no

   TABLE
   /TD/TR
   TRTHfont class=fieldlabelOur Fields/font/THTHfont 
class=fieldlabelYour Data/font/TH/TR

   ?php
   /*echo $_POST['format'];
   echobr;
   echo $copy;
   echobr;*/
  
   $fieldnumber = 0;

 while (list(,$field) = each($fields)){
 echo TR\n;
 echo TDSELECT NAME=fieldorder[]\n;
 reset($possiblefields);
 reset($descriptionfields);
 $anyselected = '';

 while (list(,$description) = each($descriptionfields)){
  list(,$possible) = each($possiblefields);

 $selected = @(($fieldorder[$fieldnumber] == $possible) 
? 'SELECTED' : '');

 if ($fieldnumber = count($fieldorder)  !$anyselected){
 $selected = 'SELECTED';
 }
 echo OPTION value=\$possible\ 
$selected$description/OPTION\n;

 }
 echo /SELECT/TD\n;
 echo TD$field/TD\n;
 echo /TR\n;
 $fieldnumber++;
 }
   
  
   ?

   /TABLE
  TABLE 
   TR ALIGN=CENTER

   TDinput type=submit name='recorddelta' value='|'/TD
   TDinput type=submit name='recorddelta' value='10'/TD
   TDinput type=submit name='recorddelta' value=''/TD
   TDinput type=submit name='recorddelta' value=''/TD
   TDinput type=submit name='recorddelta' value='10'/TD
   TDinput type=submit name='recorddelta' value='|'/TD
   /TR
   TR
   TD COLSPAN=6
   Jump To: INPUT NAME=recordnumber SIZE=5 VALUE=?php 
echo $recordnumber;?

   INPUT TYPE=SUBMIT NAME=recorddelta VALUE=Jump
   /TD
   /TR
   /TABLE
   font class=fieldlabelIf the first Row is the Header Row You must 
check this box/FONT input type=checkbox name=firstheader value=

br
font class=fieldlabelPick a Category to import these contacts to/FONT
br
?php
$sqlu=SELECT value,discription FROM category WHERE members_id = 
'$_SESSION[members_id]';

radio($sqlu,'catagory','value','discription',$row[catagory]);
?   
   HR

   font class=instructions
   POnce you're happy with the fields lining up click Import/P
  
   PIDouble-check everything before you IMPORT/I/P/FONT

   INPUT TYPE=SUBMIT NAME=import VALUE=IMPORT
/FORM


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



Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Phpster
I don't think that fieldorder needs to be an array. I don't see you  
using it as a multiselect. Does this field occur multiple times on the  
form?


Bastien

Sent from my iPod

On Mar 15, 2009, at 11:56, Richard Kurth richardku...@centurytel.net  
wrote:



Shawn McKenzie wrote:

tedd wrote:


At 6:31 PM -0700 3/14/09, Richard Kurth wrote:

I have a script that is passing a area in a $_POST and it does  
not pass
the data. When I try to look at the data with  
$_POST['fieldorder'] it
its empty but when I look at it with $_REQUEST['fieldorder'] the  
data is
there. This seams very strange to me. It has been working for  
about 6
months with no problem and then all of a sudden it does not pass  
the
data anymore. The real funny thing is the rest of the data that  
is sent
that is not an area gets past in a $_POST works just fine.Would  
there be
something in the php.ini file that I have changed that would case  
this.



What method is your form using?

Cheers,

tedd




And what is an area?  A textarea?


This is the form that is being sent as a post and the fieldorder[]  
is the part that is not sending properly. But it has worked for  
about  a year in the script. It just stopped working. and I did not  
change anything in this script



form action=import.php method=post
!-- form action=testimport.php method=post --
  INPUT TYPE=HIDDEN NAME=members_id VALUE=?php echo  
$_SESSION[members_id];?

  INPUT TYPE=HIDDEN NAME=copy VALUE='?php echo $_POST['copy'];?'
  INPUT TYPE=HIDDEN NAME=format VALUE=?php echo $_POST['format'];?
   input type=hidden name=doit value=no

  TABLE
  /TD/TR
  TRTHfont class=fieldlabelOur Fields/font/THTHfont  
class=fieldlabelYour Data/font/TH/TR

  ?php
  /*echo $_POST['format'];
  echobr;
  echo $copy;
  echobr;*/
$fieldnumber = 0;
while (list(,$field) = each($fields)){
echo TR\n;
echo TDSELECT NAME=fieldorder[]\n;
reset($possiblefields);
reset($descriptionfields);
$anyselected = '';

while (list(,$description) = each($descriptionfields)){
 list(,$possible) = each($possiblefields);

$selected = @(($fieldorder[$fieldnumber] ==  
$possible) ? 'SELECTED' : '');
if ($fieldnumber = count($fieldorder)  ! 
$anyselected){

$selected = 'SELECTED';
}
echo OPTION value=\$possible\ $selected 
$description/OPTION\n;

}
echo /SELECT/TD\n;
echo TD$field/TD\n;
echo /TR\n;
$fieldnumber++;
}
   ?
  /TABLE
 TABLETR ALIGN=CENTER
  TDinput type=submit name='recorddelta' value='|'/TD
  TDinput type=submit name='recorddelta' value='10'/TD
  TDinput type=submit name='recorddelta' value=''/TD
  TDinput type=submit name='recorddelta' value=''/TD
  TDinput type=submit name='recorddelta' value='10'/TD
  TDinput type=submit name='recorddelta' value='|'/TD
  /TR
  TR
  TD COLSPAN=6
  Jump To: INPUT NAME=recordnumber SIZE=5 VALUE=?php  
echo $recordnumber;?

  INPUT TYPE=SUBMIT NAME=recorddelta VALUE=Jump
  /TD
  /TR
  /TABLE
  font class=fieldlabelIf the first Row is the Header Row You must  
check this box/FONT input type=checkbox name=firstheader  
value=

br
font class=fieldlabelPick a Category to import these contacts to/ 
FONT

br
?php
$sqlu=SELECT value,discription FROM category WHERE members_id =  
'$_SESSION[members_id]';

radio($sqlu,'catagory','value','discription',$row[catagory]);
?  HR
  font class=instructions
  POnce you're happy with the fields lining up click Import/P
PIDouble-check everything before you IMPORT/I/P/FONT
  INPUT TYPE=SUBMIT NAME=import VALUE=IMPORT
/FORM


--
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] left join does not work, why?

2009-03-15 Thread Marc Christopher Hall
Not to mention if this is written for v 5 then you need to wrap your joins
in ()

-Original Message-
From: Jan G.B. [mailto:ro0ot.w...@googlemail.com] 
Sent: Sunday, March 15, 2009 9:47 AM
To: PJ
Cc: Daniel Brown; php-general@lists.php.net
Subject: Re: [PHP] left join does not work, why?

2009/3/15 PJ af.gour...@videotron.ca:
 Daniel Brown wrote:
 On Sat, Mar 14, 2009 at 19:51, PJ af.gour...@videotron.ca wrote:

 $sql1 = SELECT b.id, b.title, b.sub_title, b.descr, b.comment,
 b.bk_cover, b.copyright, b.ISBN, b.language, b.sellers, c.publisher,
---
 CONCAT_WS(' ', first_name, last_name) AS Author
 FROM book AS b
 LEFT JOIN book_author AS ab ON b.id = ab.bookID
 LEFT JOIN author AS a ON ab.authID=a.id
 LEFT JOIN book_publisher as abc ON b.id = abc.bookID // ---
 LEFT JOIN publishers AS c ON abc.publishers_id = c.id // ---
 ORDER BY title ASC ;
 $result1 = mysql_query($sql1, $db);
 $bookCount = mysql_num_rows($result1);
 The error reported now is to check the syntax near the commented out
lines.
 So, what is going on here? I understood that when the lines are
 commented out they are not lprocessed.
 When I deleted the commented out lines the errors went away.
 This does not make sense and obviously could be very misleading in
 debugging.


*How* are you commenting out? Mysql accepts /* such comments */, so if
you want to transform a line in your SQL query string into a comment,
you gotta do it that way.
so this is just wrong:
$x =  select *
// from foo
from bar;
and that query would be valid
SELECT this/*, that*/ from x

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


__ Information from ESET Smart Security, version of virus signature
database 3937 (20090314) __

The message was checked by ESET Smart Security.

http://www.eset.com


 

__ Information from ESET Smart Security, version of virus signature
database 3937 (20090314) __

The message was checked by ESET Smart Security.

http://www.eset.com
 


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



Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Richard Kurth

Phpster wrote:
I don't think that fieldorder needs to be an array. I don't see you 
using it as a multiselect. Does this field occur multiple times on the 
form?


Bastien

Sent from my iPod

On Mar 15, 2009, at 11:56, Richard Kurth richardku...@centurytel.net 
wrote:



Shawn McKenzie wrote:

tedd wrote:


At 6:31 PM -0700 3/14/09, Richard Kurth wrote:

I have a script that is passing a area in a $_POST and it does not 
pass

the data. When I try to look at the data with $_POST['fieldorder'] it
its empty but when I look at it with $_REQUEST['fieldorder'] the 
data is

there. This seams very strange to me. It has been working for about 6
months with no problem and then all of a sudden it does not pass the
data anymore. The real funny thing is the rest of the data that is 
sent
that is not an area gets past in a $_POST works just fine.Would 
there be
something in the php.ini file that I have changed that would case 
this.



What method is your form using?

Cheers,

tedd




And what is an area?  A textarea?


This is the form that is being sent as a post and the fieldorder[] is 
the part that is not sending properly. But it has worked for about  a 
year in the script. It just stopped working. and I did not change 
anything in this script



form action=import.php method=post
!-- form action=testimport.php method=post --
  INPUT TYPE=HIDDEN NAME=members_id VALUE=?php echo 
$_SESSION[members_id];?

  INPUT TYPE=HIDDEN NAME=copy VALUE='?php echo $_POST['copy'];?'
  INPUT TYPE=HIDDEN NAME=format VALUE=?php echo $_POST['format'];?
   input type=hidden name=doit value=no

  TABLE
  /TD/TR
  TRTHfont class=fieldlabelOur Fields/font/THTHfont 
class=fieldlabelYour Data/font/TH/TR

  ?php
  /*echo $_POST['format'];
  echobr;
  echo $copy;
  echobr;*/
$fieldnumber = 0;
while (list(,$field) = each($fields)){
echo TR\n;
echo TDSELECT NAME=fieldorder[]\n;
reset($possiblefields);
reset($descriptionfields);
$anyselected = '';

while (list(,$description) = each($descriptionfields)){
 list(,$possible) = each($possiblefields);

$selected = @(($fieldorder[$fieldnumber] == 
$possible) ? 'SELECTED' : '');
if ($fieldnumber = count($fieldorder)  
!$anyselected){

$selected = 'SELECTED';
}
echo OPTION value=\$possible\ 
$selected$description/OPTION\n;

}
echo /SELECT/TD\n;
echo TD$field/TD\n;
echo /TR\n;
$fieldnumber++;
}
   ?
  /TABLE
 TABLETR ALIGN=CENTER
  TDinput type=submit name='recorddelta' value='|'/TD
  TDinput type=submit name='recorddelta' value='10'/TD
  TDinput type=submit name='recorddelta' value=''/TD
  TDinput type=submit name='recorddelta' value=''/TD
  TDinput type=submit name='recorddelta' value='10'/TD
  TDinput type=submit name='recorddelta' value='|'/TD
  /TR
  TR
  TD COLSPAN=6
  Jump To: INPUT NAME=recordnumber SIZE=5 VALUE=?php 
echo $recordnumber;?

  INPUT TYPE=SUBMIT NAME=recorddelta VALUE=Jump
  /TD
  /TR
  /TABLE
  font class=fieldlabelIf the first Row is the Header Row You must 
check this box/FONT input type=checkbox name=firstheader 
value=

br
font class=fieldlabelPick a Category to import these contacts 
to/FONT

br
?php
$sqlu=SELECT value,discription FROM category WHERE members_id = 
'$_SESSION[members_id]';

radio($sqlu,'catagory','value','discription',$row[catagory]);
?  HR
  font class=instructions
  POnce you're happy with the fields lining up click Import/P
PIDouble-check everything before you IMPORT/I/P/FONT
  INPUT TYPE=SUBMIT NAME=import VALUE=IMPORT
/FORM



Yes the field order does have a multiselect it selects the order that 
you what to import a list from a CVS file like first name last name 
address ets. it can have 2 up to 25 diferent selections in it. The 
question was not about that it is way can I not receive the data in that 
field as a $_POST but I can with a $_REQUEST all the other $_POSTs go 
thrue without any problem






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



[PHP] Re: GeoIP?

2009-03-15 Thread Michelle Konzack
Hello Per,

Am 2009-03-15 15:12:47, schrieb Per Jessen:
 The easiest is to use a DNS service - this is the best one I know:
 http://countries.nerd.dk/

This is cool...

OK, I have imported the ISO codes list and it just works how it should.

Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
http://www.tamay-dogan.net/ Michelle Konzack
http://www.can4linux.org/   Apt. 917
http://www.flexray4linux.org/   50, rue de Soultz
Jabber linux4miche...@jabber.ccc.de   67100 Strasbourg/France
IRC #Debian (irc.icq.com) Tel. DE: +49 177 9351947
ICQ #328449886Tel. FR: +33  6  61925193


signature.pgp
Description: Digital signature


Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread tedd

At 8:56 AM -0700 3/15/09, Richard Kurth wrote:
This is the form that is being sent as a post and the fieldorder[] 
is the part that is not sending properly. But it has worked for 
about  a year in the script. It just stopped working. and I did not 
change anything in this script



-snip- code

If it was my problem, I see the script is riddled with 
inconsistencies. As such, I would pass it through validation to 
discover all the errors. Then I would fix those errors and then see 
if the problem continues.


Granted, some people don't think validation is important, but I'm 
positive that I could get your script to work by simply cleaning up 
the code.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Re: GeoIP?

2009-03-15 Thread zerof

Michelle Konzack escreveu:

Hello Nitsan,

Am 2009-03-15 15:39:26, schrieb Nitsan Bin-Nun:

Take a look at this:
http://www.maxmind.com/app/geolitecountry

Use indexes, I think the checkup won't take long.



...
For a long time I'm using the geolitecountry without no problems.
The procedures that I use, can be seen in the tutorial located at:

http://www.educar.pro.br/i_en/GeoIP/

( An alternative procedure to the one proposed, is to use phpMyAdmin to 
upload the CSV file to MySQL.)



--
zerof
http://www.educar.pro.br/
http://www.geoticks.com/
--
Você deve, sempre, consultar uma segunda opinião!
--
Deixe todos saberem se esta informação foi-lhe útil.
--  
You must hear, always, one second opinion! In all cases.
--
Let the people know if this info was useful for you!
--

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



Re: [PHP] left join does not work, why?

2009-03-15 Thread PJ
Marc Christopher Hall wrote:
 Not to mention if this is written for v 5 then you need to wrap your joins
 in ()

 -Original Message-
 From: Jan G.B. [mailto:ro0ot.w...@googlemail.com] 
 Sent: Sunday, March 15, 2009 9:47 AM
 To: PJ
 Cc: Daniel Brown; php-general@lists.php.net
 Subject: Re: [PHP] left join does not work, why?

 2009/3/15 PJ af.gour...@videotron.ca:
   
 Daniel Brown wrote:
 
 On Sat, Mar 14, 2009 at 19:51, PJ af.gour...@videotron.ca wrote:

   
 $sql1 = SELECT b.id, b.title, b.sub_title, b.descr, b.comment,
 b.bk_cover, b.copyright, b.ISBN, b.language, b.sellers, c.publisher,
 
 ---
   
 CONCAT_WS(' ', first_name, last_name) AS Author
 FROM book AS b
 LEFT JOIN book_author AS ab ON b.id = ab.bookID
 LEFT JOIN author AS a ON ab.authID=a.id
 LEFT JOIN book_publisher as abc ON b.id = abc.bookID // ---
 LEFT JOIN publishers AS c ON abc.publishers_id = c.id // ---
 ORDER BY title ASC ;
 $result1 = mysql_query($sql1, $db);
 $bookCount = mysql_num_rows($result1);
 
 The error reported now is to check the syntax near the commented out
 
 lines.
   
 So, what is going on here? I understood that when the lines are
 commented out they are not lprocessed.
 When I deleted the commented out lines the errors went away.
 This does not make sense and obviously could be very misleading in
 debugging.

 

 *How* are you commenting out? Mysql accepts /* such comments */, so if
 you want to transform a line in your SQL query string into a comment,
 you gotta do it that way.
 so this is just wrong:
 $x =  select *
 // from foo
 from bar;
 and that query would be valid
 SELECT this/*, that*/ from x

   
Quite right...
This has been mulling (?) in my mind for a few hours now and I thought
I'd just see what response I would get on the list. O:-)
It took ma a bit of thinking, I must say, but the answer is simple:
You cannot do comment - out's (for that is what this was really about)
within astatement or declaration! I was commenting out two JOINs within
a $sql = SELECT ..  declaration that was split into several lines
and it didn't occur to me that you cannot just comment out a part of a
declaration or statement that spans several lines. So, if you comment
out one part the rest will still be parsed. There's a reason, then why
the HTML specification requires that  delimited statements cannot be
split over several lines.  Hope I said all that correctly. :-)

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Richard Kurth

tedd wrote:

At 8:56 AM -0700 3/15/09, Richard Kurth wrote:
This is the form that is being sent as a post and the fieldorder[] is 
the part that is not sending properly. But it has worked for about  a 
year in the script. It just stopped working. and I did not change 
anything in this script



-snip- code

If it was my problem, I see the script is riddled with 
inconsistencies. As such, I would pass it through validation to 
discover all the errors. Then I would fix those errors and then see if 
the problem continues.


Granted, some people don't think validation is important, but I'm 
positive that I could get your script to work by simply cleaning up 
the code.


Cheers,

tedd
You are probly right. But I got this script from Rasmus Lerdor about a 
year ago and I changed very little. It has worked just fine sence I 
started using it. Who am I to question Rasmus's coding.  I am now using 
$_Request to capture the array for fieldorder[] and $_POST to get the 
rest of the data.


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



Re: [PHP] left join does not work, why?

2009-03-15 Thread Jan G.B.
2009/3/15 PJ af.gour...@videotron.ca:
 -Original Message-
 From: Jan G.B. [mailto:ro0ot.w...@googlemail.com]
 so this is just wrong:
 $x =  select *
 // from foo
 from bar;
 and that query would be valid
 SELECT this/*, that*/ from x

 It took ma a bit of thinking, I must say, but the answer is simple:
 You cannot do comment - out's (for that is what this was really about)
 within astatement or declaration! I was commenting out two JOINs within
 a $sql = SELECT ..  declaration that was split into several lines
 and it didn't occur to me that you cannot just comment out a part of a
 declaration or statement that spans several lines. So, if you comment
 out one part the rest will still be parsed.

well, actually you could write my example with as much newlines
(whitespace) as you want.
$x = SELECT
/* JOIN x ON a=b
*/
this FROM
that;

... is valid and mysql will parse it correct as select this from that.

 There's a reason, then why
 the HTML specification requires that  delimited statements cannot be
 split over several lines.  Hope I said all that correctly. :-)


not really correct. the above sql statement is correct, because PHP
has no problem with newlines in a string encapsulated in , just like
mysql.
but I think it's not a goog coding style to have newlines, tabs and
alike in a mysql-query; it messes up the logs.
I would do it that way:
$x = foo
//  .  unused
.  bar;


byebye

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



Re: [PHP] Re: GeoIP?

2009-03-15 Thread Nitsan Bin-Nun
Hi Michelle,

Try to use sqlite instead of any other database. It will be better I guess.

Regards,
Nitsan

On Sun, Mar 15, 2009 at 9:08 PM, zerof ze...@terra.com.br wrote:

 Michelle Konzack escreveu:

 Hello Nitsan,

 Am 2009-03-15 15:39:26, schrieb Nitsan Bin-Nun:

 Take a look at this:
 http://www.maxmind.com/app/geolitecountry

 Use indexes, I think the checkup won't take long.


  ...
 For a long time I'm using the geolitecountry without no problems.
 The procedures that I use, can be seen in the tutorial located at:

 http://www.educar.pro.br/i_en/GeoIP/

 ( An alternative procedure to the one proposed, is to use phpMyAdmin to
 upload the CSV file to MySQL.)


 --
 zerof
 http://www.educar.pro.br/
 http://www.geoticks.com/
 --
 Você deve, sempre, consultar uma segunda opinião!
 --
 Deixe todos saberem se esta informação foi-lhe útil.
 --
 You must hear, always, one second opinion! In all cases.
 --
 Let the people know if this info was useful for you!
 --


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




Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Jason Pruim

Richard Kurth wrote:

tedd wrote:

At 8:56 AM -0700 3/15/09, Richard Kurth wrote:
This is the form that is being sent as a post and the fieldorder[] 
is the part that is not sending properly. But it has worked for 
about  a year in the script. It just stopped working. and I did not 
change anything in this script



-snip- code

If it was my problem, I see the script is riddled with 
inconsistencies. As such, I would pass it through validation to 
discover all the errors. Then I would fix those errors and then see 
if the problem continues.


Granted, some people don't think validation is important, but I'm 
positive that I could get your script to work by simply cleaning up 
the code.


Cheers,

tedd
You are probly right. But I got this script from Rasmus Lerdor about a 
year ago and I changed very little. It has worked just fine sence I 
started using it. Who am I to question Rasmus's coding.  I am now 
using $_Request to capture the array for fieldorder[] and $_POST to 
get the rest of the data.


Personally... I don't care who's code it is, if it was me, I'd still go 
out and validate it... If someone typed something out real quick and 
missed a period, it wouldn't be their fault :)


As has been said by some big higher up's in this very mailing list... 
Treat all code as pseudo code, don't copy and paste it without 
understanding what it could do to your system or something along those 
lines... :)




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



Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Jan G.B.
2009/3/15 Jason Pruim pru...@gmail.com:
 Personally... I don't care who's code it is, if it was me, I'd still go
 out and validate it... If someone typed something out real quick and
 missed a period, it wouldn't be their fault :)

 As has been said by some big higher up's in this very mailing list... Treat
 all code as pseudo code, don't copy and paste it without understanding what
 it could do to your system or something along those lines... :)

I second that.
Maybe you should start with removing /td/tr after the first
table has been opened, escape the html special chars used as values
(submit buttons) and escape all request data (e.g. $_POST) before
echoing.
well - it might not solve your problem (where's the textarea anyways),
but it wouldn't disturb the functionality. :)

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



[PHP] Which hashing algorithm is best to check file duplicity?

2009-03-15 Thread Martin Zvarík
I want to store the file's hash to the database, so I can check next 
time to see if that file was already uploaded (even if it was renamed).


What would be the best (= fastest + small chance of collision) algorithm 
in this case?


Is crc32 a good choice?

Thank you in advance,
Martin

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



Re: [PHP] Which hashing algorithm is best to check file duplicity?

2009-03-15 Thread Jan G.B.
2009/3/15 Martin Zvarík mzva...@gmail.com:
 I want to store the file's hash to the database, so I can check next time to
 see if that file was already uploaded (even if it was renamed).

 What would be the best (= fastest + small chance of collision) algorithm in
 this case?

 Is crc32 a good choice?
guess not.
maybe unhex(md5()) into a binary(16) field?
What I'm trying to say is, that crc32 is more likely to have
collisions as a better algorithm like sha1, md5, ..
and that the datatype for the db should be considered.

byebye

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



Re: [PHP] Which hashing algorithm is best to check file duplicity?

2009-03-15 Thread Paul M Foster
On Sun, Mar 15, 2009 at 10:25:11PM +0100, Martin Zvarík wrote:

 I want to store the file's hash to the database, so I can check next
 time to see if that file was already uploaded (even if it was renamed).

 What would be the best (= fastest + small chance of collision) algorithm
 in this case?

 Is crc32 a good choice?

 Thank you in advance,
 Martin

According to wikipedia, a CRC is not sufficient to detect intentional
alteration of a file/message, since it's relatively easy to design a
message/file which will have the same CRC. On the other hand, CRC, by
design will reliably detect subtle changes to a message/file.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Which hashing algorithm is best to check file duplicity?

2009-03-15 Thread Chris

Martin Zvarík wrote:
I want to store the file's hash to the database, so I can check next 
time to see if that file was already uploaded (even if it was renamed).


What would be the best (= fastest + small chance of collision) algorithm 
in this case?


Fastest depends mostly on the size of the file, not the algorithm 
used. A 2gig file will take a while using md5 as it will using sha1.


Using md5 will be slightly quicker than sha1 because generates a shorter 
hash so the trade-off is up to you.


$ ls -lh file.gz

724M 2008-07-28 10:02 file.gz

$ time sha1sum file.gz
4ae7bd1e79088a3e3849e17c7be989d4a7c97450  file.gz

real0m3.398s
user0m3.056s
sys 0m0.336s

$ time md5sum file.gz
16cff7b95bcb5971daf1cabee6ca4edd  file.gz

real0m2.091s
user0m1.744s
sys 0m0.328s

$ time sha1sum file.gz
4ae7bd1e79088a3e3849e17c7be989d4a7c97450  file.gz

real0m3.332s
user0m2.988s
sys 0m0.344s

$ time md5sum file.gz
16cff7b95bcb5971daf1cabee6ca4edd  file.gz

real0m2.136s
user0m1.776s
sys 0m0.348s

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] Which hashing algorithm is best to check file duplicity?

2009-03-15 Thread Martin Zvarík


Fastest depends mostly on the size of the file, not the algorithm 
used. A 2gig file will take a while using md5 as it will using sha1.


Using md5 will be slightly quicker than sha1 because generates a 
shorter hash so the trade-off is up to you.


$ ls -lh file.gz

724M 2008-07-28 10:02 file.gz

$ time sha1sum file.gz
4ae7bd1e79088a3e3849e17c7be989d4a7c97450  file.gz

real0m3.398s
user0m3.056s
sys0m0.336s

$ time md5sum file.gz
16cff7b95bcb5971daf1cabee6ca4edd  file.gz

real0m2.091s
user0m1.744s
sys0m0.328s

$ time sha1sum file.gz
4ae7bd1e79088a3e3849e17c7be989d4a7c97450  file.gz

real0m3.332s
user0m2.988s
sys0m0.344s

$ time md5sum file.gz
16cff7b95bcb5971daf1cabee6ca4edd  file.gz

real0m2.136s
user0m1.776s
sys0m0.348s

Aha, thanks for sharing the benchmark. I'll go with MD5()

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



Re: [PHP] RE: non-auto increment question

2009-03-15 Thread Jim Lucas

PJ wrote:

haliphax wrote:

On Fri, Mar 13, 2009 at 1:24 PM, PJ af.gour...@videotron.ca wrote:

Jim Lucas wrote:

PJ wrote:

am resending as this was erroneously ccd to mysql. sorry!

Ashley Sheridan wrote:

On Thu, 2009-02-26 at 11:27 -0500, PJ wrote:

Jerry Schwartz wrote:


Being rather new to all this, I understood from the MySql manual
that
the auto_increment is to b e used immediately after an
insertion not
intermittently. My application is for administrators (the site
owner 
designates) to update the database from and administration
directory,
accessed by user/password login... so there's really very little
possibility of 2 people accessing at the same time.
By using MAX + 1 I keep the id number in the $idIn and can reuse
it in
other INSERTS


[JS] Are you looking for something like LAST_INSERT_ID()? If you
INSERT a
record that has an auto-increment field, you can retrieve the value
that got
inserted with SELECT LAST_INSERT_ID(). It is
connection-specific, so
you'll always have your own value. You can then save it to reuse,
either
as a session variable or (more easily) as a hidden field on your
form.


Thanks, Jerry,


You hit the nail on the head.:)

To refine my problem (and reduce my ignorance),here's what is
happening
on the form page:

There is a series of INSERTs. The first inserts all the columns of
book table except for the id, which I do not specify as it if
auto-insert.

In subsequent tables I have to reference the book.id (for
transitional
tables like book_author(refers authors to book) etc.

If I understand it correctly, I must retrieve (SELECT
LAST_INSERT_ID()) after the first INSERT and before the following
insert; and save the id as a string ($id)...e.g. $sql = SELECT
LAST_INSERT_ID() AS $id
I need clarification on the AS $id - should this be simply id(does
this have to be turned into a value into $id or does $id contain the
value? And how do I retrieve it to use the returned value for the
next
$sql = INSERT ... - in other words, is the id or $id available for
the
next directive or do I have to do something like $id = id?
I'm trying to figure this out with some trials but my insert does not
work from a php file - but it works from command-line... that's
another
post.


Here's how I mostly do it (albeit simplified):

$query = INSERT INTO `sometable`(`title`,`content`)
VALUES('$title','$content');
$result = mysql_query($query);
$autoId = mysql_insert_id($result);

$query = INSERT INTO `another_table`(`link_id`,`value`)
VALUES($autoId,'$value');
$result = mysql_query($query);

No need to call another query to retrieve the last inserted id, as
it is
tied to the last query executed within this session.


Ash
www.ashleysheridan.co.uk

For some reason or other $autoId = mysql_insert_id($result); just does
not work for me... Yet some of the data is inserted correctly...
I did find that it does not work on tables that are empty... so you
can't start with an empty table. I entered data  it still did not
work.
I tried on another duplicate database... doesn't work.
I have checked  double checked the database, I have added checks
to see
what is returned and the returns are 0 or null - as I get different
responses for slightly different functions.
sessions is on
mysql is 5.1.28
php5

here's what is parsed:
else { $sql1 = INSERT INTO book
                    ( title, sub_title, descr, comment,
bk_cover,
copyright, ISBN, language, sellers )
                VALUES
                    ('$titleIN', '$sub_titleIN', '$descrIN',
                    '$commentIN', '$bk_coverIN',
'$copyrightIN',
'$ISBNIN', '$languageIN', '$sellersIN');
        $result1 = mysql_query($sql1, $db);
    $autoid = mysql_insert_id($result1);
        $sql2 = INSERT INTO author (first_name, last_name) VALUES
('$first_nameIN', '$last_nameIN');
            $result2 = mysql_query($sql2, $db);
    $authorID = mysql_insert_id($result2);
        $sql2a = INSERT INTO book_author (authID, bookID, ordinal)
VALUES ( '$authorID', '$autoid', '1');
            $result2a = mysql_query($sql2a, $db);
        $sql2b = INSERT INTO author (first_name, last_name) VALUES
('$first_name2IN', '$last_name2IN');
            $result2b = mysql_query($sql2b, $db);
    $author2ID = mysql_insert_id($result2b);
        $sql2c = INSERT INTO book_author (authID, bookID, ordinal)
VALUES ( '$author2ID', '$autoid', '2');
            $result2c = mysql_query($sql2c, $db);
        $sql3 = INSERT INTO publishers (publisher) VALUES
('$publisherIN');
            $result3 = mysql_query($sql3, $db);
    $publisherID = mysql_insert_id($result3);
        $sql3a = INSERT INTO book_publisher (bookID,
publishers_id)
VALUES ( '$autoid', '$publisherID' );
            $result3a = mysql_query($sql3a, $db);
        foreach($_POST['categoriesIN'] as $category){
            $sql4 = INSERT INTO book_categories (book_id,
categories_id)
                VALUES