OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 12 Jul 2004 03:09:08 -0000 Issue 2871

php-general-digest-helplists.php.net
Date: Sun Jul 11 2004 - 22:09:08 CDT


php-general Digest 12 Jul 2004 03:09:08 -0000 Issue 2871

Topics (messages 190185 through 190214):

parse error: [PHP] usort e & é together
        190185 by: John Taylor-Johnston
        190192 by: Marek Kilimajer
        190197 by: Curt Zirzow
        190208 by: John Taylor-Johnston
        190209 by: Miroslav Hudak (php/ml)

Re: sort() - Where did I go wrong?
        190186 by: John Taylor-Johnston
        190191 by: Marek Kilimajer

Re: mail problem
        190187 by: John Taylor-Johnston

Re: Passing Variables
        190188 by: John Taylor-Johnston

Re: Where should I put my mysql database???
        190189 by: John Taylor-Johnston
        190200 by: Curt Zirzow

Re: displaying database results with forward and back buttons
        190190 by: John Taylor-Johnston
        190193 by: i sidhu
        190198 by: Curt Zirzow

Re: MySQL/PHP Tunneling
        190194 by: Jason Wong
        190195 by: Curt Zirzow

storage of encrypted data
        190196 by: klaus
        190201 by: Curt Zirzow

Re: CMS solution + web sites in CVS.
        190199 by: Ed Lazor

character set of RIJNDAEL?
        190202 by: klaus

[Q] Why does my php file gets displayed instead of executed
        190203 by: Michael T. Peterson
        190204 by: Michal Migurski
        190205 by: Michael T. Peterson
        190206 by: Miroslav Hudak (php/ml)
        190207 by: Tom Rogers
        190213 by: Michael T. Peterson

Re: usort e & é together
        190210 by: John Taylor-Johnston
        190211 by: Miroslav Hudak (php/ml)
        190212 by: Miroslav Hudak (php/ml)
        190214 by: John Taylor-Johnston

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


I went with this, but am getting a parse error.

usort($authors, create_function('$a,$b','
        $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
        $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
        return strcasecmp($a,$b);'));

Anyone see it? I've got headaches from squinting at the monitor.

Thanks,
J

Marek Kilimajer wrote:

>usort($authors, create_function('$a,$b','
> $a = str_replace(array('é', 'à', ....), array('e', 'a'), $a);
> $b = str_replace(array('é', 'à', ....), array('e', 'a'), $b);
> return strcasecmp($a,$b);'));

attached mail follows:


I'm sorry, I used unescaped single quotes inside single quoted string,
this is right:

usort($authors, create_function('$a,$b','
         $a = str_replace(array("é", "à"), array("e", "a"), $a);
         $b = str_replace(array("é", "à"), array("e", "a"), $b);
         return strcasecmp($a,$b);'));

John Taylor-Johnston wrote:
> I went with this, but am getting a parse error.
>
> usort($authors, create_function('$a,$b','
> $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
> $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
> return strcasecmp($a,$b);'));
>
> Anyone see it? I've got headaches from squinting at the monitor.
>
> Thanks,
> J
>
> Marek Kilimajer wrote:
>
>
>>usort($authors, create_function('$a,$b','
>> $a = str_replace(array('é', 'à', ....), array('e', 'a'), $a);
>> $b = str_replace(array('é', 'à', ....), array('e', 'a'), $b);
>> return strcasecmp($a,$b);'));
>
>

attached mail follows:


* Thus wrote John Taylor-Johnston:
> I went with this, but am getting a parse error.
>
> usort($authors, create_function('$a,$b','
> $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
> $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
> return strcasecmp($a,$b);'));
>
> Anyone see it? I've got headaches from squinting at the monitor.

For Starters, you're trying to do everything in the world to one
function call.

Break it down and format it into a human readable thing.

$func_args = '$a, $b';
$func_code = '
 static $replace = array('é', 'à');
 static $with = array('e', 'a');

 $a = str_replace($replace, $with, $a);
 $b = str_replace($replace, $with, $b);

 return strcasecmp($a, $b);
';

usort($authors, create_function($func_args, $func_code));

The question does occure to me why you're using a create_function()
call instead of simply defining a function to used for usort().

Oh, and strtr() might be more of an appropriate choice:

  $translate = array('éà', 'ea');

  $a = strtr($a, $translate);
  $b = strtr($b, $translate);

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


Sorry. Still getting a parse error on line 40:

39> usort($authors, create_function('$a,$b','
40> $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
41> $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
42> return strcasecmp($a,$b);'));

Can you have two arrays there? http://ca2.php.net/manual/en/function.str-replace.php

All the brackets are in the right place. Hmmm ...?

Thanks,
John

attached mail follows:


Dunno the original question, but this obviously should be escaped...

So the correct code follows...

usort($authors, create_function('$a,$b','
       $a = str_replace(array(\'é\', \'a\'), array(\'e\', \'a\'), $a);
       $b = str_replace(array(\'é\', \'a\'), array(\'e\', \'a\'), $b);
       return strcasecmp($a,$b);'));

Regards,
m.

John Taylor-Johnston wrote:

> Sorry. Still getting a parse error on line 40:
>
> 39> usort($authors, create_function('$a,$b','
> 40> $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
> 41> $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
> 42> return strcasecmp($a,$b);'));
>
> Can you have two arrays there? http://ca2.php.net/manual/en/function.str-replace.php
>
> All the brackets are in the right place. Hmmm ...?
>
> Thanks,
> John
>

attached mail follows:


Like this?

<td>".preg_replace ('/('.preg_quote($searchenquiry).')/i' , "<b>$1</b>", $mydata->JR)."&nbsp;</td>

Still getting the unknown modifier error.

> > $searchenquiry = "1.0.1 Retrospective bibliographies and checklists / bibliographies et répertoires rétrospectifs";
> >
> > preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>", $mydata->RB)
> >
> > error: Unknown modifier 'b' in <b>/www-html/new1/db/display.table.inc</b> on line <b>103</b>
> the problem is the slash in $searchenquiry, use preg_quote()

attached mail follows:


John Taylor-Johnston wrote:
> Like this?
>
> <td>".preg_replace ('/('.preg_quote($searchenquiry).')/i' , "<b>$1</b>", $mydata->JR)."&nbsp;</td>
>
> Still getting the unknown modifier error.

No, like this:

preg_quote($searchenquiry, '/')

so also the delimiter - /, is quoted

>
>
>
>>>$searchenquiry = "1.0.1 Retrospective bibliographies and checklists / bibliographies et répertoires rétrospectifs";
>>>
>>>preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>", $mydata->RB)
>>>
>>>error: Unknown modifier 'b' in <b>/www-html/new1/db/display.table.inc</b> on line <b>103</b>
>>
>>the problem is the slash in $searchenquiry, use preg_quote()
>
>
>
>

attached mail follows:


You don't need sendmail. In php.ini you need to add something.

SMTP = smtpuol.com.br is not right? You want an address, not an email.

SMTP = smtp.uol.com.br is more likely the correct address.

Joao Gomes wrote:

> Hi,
>
> I am a beginner in php and I am trying to send emails from my machinne, I
> dont have any mail server installed in my computer (e.g. sendmail), btw i am
> running Windows XP, i wrote this script:
> <?
> $name=$HTTP_POST_VARS['name'];
> $email=$HTTP_POST_VARS['email'];
> $feedback=$HTTP_POST_VARS['feedback'];
>
> $toaddress = 'myreceiverlinuxmail.org';
> $subject = 'Feedback from web site';
> $mailcontent = 'Customer name: '.$name."\n"
> 'Customer email: '.$email."\n"
> "Customer comments: \n".$feedback."\n";
> $fromaddress = 'From: myaccountuol.com.br';
>
> mail($toaddress, $subject, $mailcontent, $fromaddress);
> ?>
>
> and changed the php.ini to:
>
> [mail function]
> ; For Win32 only.
> SMTP = smtpuol.com.br
> smtp_port = 25
> ; For Win32 only.
> sendmail_from = myaccountuol.com.br

attached mail follows:


To go back to a previous conversation, I would not put it on the action=. You are using METHOD=post?
I wold use <input name=UserID value==\"$UserID\" type=hidden> or to really hide them use session variables so they are completely hidden. Or use a cookie (but that is not the most secure way).

Harlequin wrote:

> I'm just working on my syntax for passing a variable "UserID" from one page
> to the next and it works a little like this so far:
>
> On my form I have:
> "<form action='updated.php?UserID=\"$UserID\"...
>
> The URL posts:
> http://...load.php?UserID="JDoe"
>
> And when I echo the "$UserID" on this page I get:
> Code:
> <?php echo "for example: ['$UserID']"; ?>
>
> Generates:
> for example: ['\"JDoe\"']
>
> Which part of my syntax is incorrect...?
>
> --
> -----------------------------
> Michael Mason
> Arras People
> www.arraspeople.co.uk
> -----------------------------

--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not open-source, it's Murphy's Law."

  ' ' ' Collège de Sherbrooke:
 ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/
   - Université de Sherbrooke:
          http://compcanlit.ca/
          819-569-2064

attached mail follows:


In my c«ase, it was built into redhat. Installing it in a local user account? Can't do that, but I'm no expert. You would need root-lvel access to change variables on the server too, no? In php.ini for one. Ask your sysadmin for an account.

Levis li wrote:

> Hi friends
> I am now using the college's virtual web space. I have my working directary on that SunOS/apache/PhP/Oracle/MySQL server. The question is that :
> Can i create the Mysql database in my working directary??How?Also if
> I dont want to set the password, who will be helping me?

attached mail follows:


* Thus wrote Levis Li:
> Hi friends
> I am now using the college's virtual web space. I have my working directary on that SunOS/apache/PhP/Oracle/MySQL server. The question is that :
> Can i create the Mysql database in my working directary??How?Also if
> I dont want to set the password, who will be helping me?

A couple of things:

 1. befriend the college's sysadmin
 2. Contact the mysql mailing list.

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


Finally something I can give back, made by my little lonesome with no help :)

> I have a query that returns lots of rows so I want to display the results in blocks of 25 or so on my web page and have forward and back buttons to navigate the results.

include it first:

include("settings_limit.inc");

then set $offset and $limit in your sql

$sql = 'SELECT *,MATCH (field1,field2)
AGAINST (\''.$searchenquiry.'\' IN BOOLEAN MODE)
AS relevancy FROM '.$table.'
WHERE MATCH (field1,field2)
AGAINST (\''.$searchenquiry.'\' IN BOOLEAN MODE)
ORDER BY relevancy DESC
LIMIT '.$offset.','.$limit.';';

------settings_limit.inc--------
<?php

#####################################################
## $mycounter is set by script calling settings_limit.inc ####
#####################################################

#####################################################
############### Set $offset & $limit ################
#####################################################

if((!$offset) || ($offset < 0))
{
$offset = 0;
}
$limit = 25;

#####################################################
############### $nextinsert #########################
#####################################################
$new_offset = $offset + $limit;
$disp = $limit;
if ($new_offset + $limit > $mycounter)
{
  $disp = $mycounter - $new_offset;
}
if ($disp > 0)
{
$nextinsert = "<form ACTION=\"".$SCRIPT_NAME."\" TARGET=\"_top\" METHOD=\"POST\"><td>Next ".$disp." Requests <input type=\"submit\" name=\"submit\" value=\">>\"><input type=\"hidden\" name=\"offset\" value=\"".$new_offset."\"><input type=\"hidden\" name=\"table\" value=\"".$table."\"><input type=\"hidden\" name=\"db\" value=\"".$db."\">";
 if($searchenquiry)
  $nextinsert .= "<input type=\"hidden\" name=\"searchenquiry\" value=\"".stripslashes(htmlspecialchars($searchenquiry))."\">";
 if($scholarsenquiry)
  $nextinsert .= "<input type=\"hidden\" name=\"scholarsenquiry\" value=\"".$scholarsenquiry."\">";
 if($titlesenquiry)
  $nextinsert .= "<input type=\"hidden\" name=\"titlesenquiry\" value=\"".$titlesenquiry."\">";
 $nextinsert .= "</td></form>";
}
#####################################################
############### $previousinsert #####################
#####################################################

$new_offset2 = $offset - $limit;
if ($offset > 0) // can display previous msg
{
 $disp = $limit;
 $previousinsert = " <font face=\"arial\" size=2><A HREF=\"index.html?submit=submit&offset=".$new_offset2."&table=$table&db=$db\">&lt;&lt; Previous ".$disp." Requests</a></font>";

$previousinsert = "<form ACTION=\"".$SCRIPT_NAME."\" TARGET=\"_top\" METHOD=\"POST\"><td><input type=\"submit\" name=\"submit\" value=\"<<\"> Previous ".$disp." Requests<input type=\"hidden\" name=\"offset\" value=\"".$new_offset2."\"><input type=\"hidden\" name=\"table\" value=\"".$table."\"><input type=\"hidden\" name=\"db\" value=\"".$db."\">";
 if($searchenquiry)
  $previousinsert .= "<input type=\"hidden\" name=\"searchenquiry\" value=\"".stripslashes(htmlspecialchars($searchenquiry))."\">";
 if($scholarsenquiry)
  $previousinsert .= "<input type=\"hidden\" name=\"scholarsenquiry\" value=\"".$scholarsenquiry."\">";
 if($titlesenquiry)
  $previousinsert .= "<input type=\"hidden\" name=\"titlesenquiry\" value=\"".$titlesenquiry."\">";
 $previousinsert .= "</td></form>";
}
#####################################################
############### $lastinsert #########################
#####################################################

$new_offset3 = $mycounter - $limit;

if (($new_offset3 > $limit) and ($offset != $mycounter - $limit)) // can display goto end msg
{
$lastinsert = "<form ACTION=\"".$SCRIPT_NAME."\" TARGET=\"_top\" METHOD=\"POST\"><td>Go To End <input type=\"submit\" name=\"submit\" value=\">>|\"><input type=\"hidden\" name=\"offset\" value=\"".$new_offset3."\"><input type=\"hidden\" name=\"table\" value=\"".$table."\"><input type=\"hidden\" name=\"db\" value=\"".$db."\">";
 if($searchenquiry)
  $lastinsert .= "<input type=\"hidden\" name=\"searchenquiry\" value=\"".stripslashes(htmlspecialchars($searchenquiry))."\">";
 if($scholarsenquiry)
  $lastinsert .= "<input type=\"hidden\" name=\"scholarsenquiry\" value=\"".$scholarsenquiry."\">";
 if($titlesenquiry)
  $lastinsert .= "<input type=\"hidden\" name=\"titlesenquiry\" value=\"".$titlesenquiry."\">";
 $lastinsert .= "</td></form>";
}
#####################################################
############### $firstinsert ########################
#####################################################

$new_offset4 = $mycounter - $limit;
if ($new_offset4 > $limit) // can display goto beginning msg
{
$new_offset4 = 0;
$firstinsert = "<form ACTION=\"".$SCRIPT_NAME."\" TARGET=\"_top\" METHOD=\"POST\"><td><input type=\"submit\" name=\"submit\" value=\"|<<\"> Go To Beginning<input type=\"hidden\" name=\"offset\" value=\"".$new_offset4."\"><input type=\"hidden\" name=\"table\" value=\"".$table."\"><input type=\"hidden\" name=\"db\" value=\"".$db."\">";
 if($searchenquiry)
  $firstinsert .= "<input type=\"hidden\" name=\"searchenquiry\" value=\"".stripslashes(htmlspecialchars($searchenquiry))."\">";
 if($scholarsenquiry)
  $firstinsert .= "<input type=\"hidden\" name=\"scholarsenquiry\" value=\"".$scholarsenquiry."\">";
 if($titlesenquiry)
  $firstinsert .= "<input type=\"hidden\" name=\"titlesenquiry\" value=\"".$titlesenquiry."\">";
 $firstinsert .= "</td></form>";
}

#####################################################
############### Display Inserts #####################
#####################################################

#####################################################
if (($previousinsert) or ($nextinsert))
#echo "<center><table border=0 cellspacing=\"5\" cellpadding=\"0\">";
echo "<table border=0 cellspacing=\"5\" cellpadding=\"0\">";

#if (($previousinsert) || ($nextinsert))
#echo "<caption ALIGN=BOTTOM><small>(Sorted by id - $mycounter records found total)</small></caption>";

if (($previousinsert) or ($nextinsert))
echo "<tr>";

if (($firstinsert) and ($offset != 0)) echo "$firstinsert";

if ($previousinsert) echo "$previousinsert";

if (($previousinsert) && ($nextinsert)) echo "<td> | </td>";

if ($nextinsert) echo "$nextinsert";

if ($lastinsert) echo "$lastinsert";

if (($previousinsert) or ($nextinsert))
#echo "</tr></table></center>";
echo "</tr></table>";

?>

attached mail follows:


The main part of code i m using for Forward and Backward is,
 
 
 
if($page > 1)
{
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev&&searchfor=$searchfor&&seek=$seek&&age1=$age1&&age2=$age2&&state=$state&&country=$country\" TARGET=\"_parent\"><<Previous</a>&nbsp;";
}
for($i = 1; $i <= $total_pages; $i++)
{
    if(($page) == $i)
    {
        echo "$i&nbsp;";
    } else
    {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i&&searchfor=$searchfor&&seek=$seek&&age1=$age1&&age2=$age2&&state=$state&&country=$country\" TARGET=\"_parent\">$i</a>&nbsp;";
    }
}
// Build Next Link
if($page < $total_pages)
{
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next&&searchfor=$searchfor&&seek=$seek&&age1=$age1&&age2=$age2&&state=$state&&country=$country\" TARGET=\"_parent\">Next>></a>";
}

 
Change variables accroding to u.
 
 
 
John Taylor-Johnston <taylorjocollegesherbrooke.qc.ca> wrote:
Finally something I can give back, made by my little lonesome with no help :)

> I have a query that returns lots of rows so I want to display the results in blocks of 25 or so on my web page and have forward and back buttons to navigate the results.

include it first:

include("settings_limit.inc");

then set $offset and $limit in your sql

$sql = 'SELECT *,MATCH (field1,field2)
AGAINST (\''.$searchenquiry.'\' IN BOOLEAN MODE)
AS relevancy FROM '.$table.'
WHERE MATCH (field1,field2)
AGAINST (\''.$searchenquiry.'\' IN BOOLEAN MODE)
ORDER BY relevancy DESC
LIMIT '.$offset.','.$limit.';';

------settings_limit.inc--------

#####################################################
## $mycounter is set by script calling settings_limit.inc ####
#####################################################

#####################################################
############### Set $offset & $limit ################
#####################################################

if((!$offset) || ($offset < 0))
{
$offset = 0;
}
$limit = 25;

#####################################################
############### $nextinsert #########################
#####################################################
$new_offset = $offset + $limit;
$disp = $limit;
if ($new_offset + $limit > $mycounter)
{
$disp = $mycounter - $new_offset;
}
if ($disp > 0)
{
$nextinsert = "Next ".$disp." Requests [input] >\"> [input] [input] [input] ";
if($searchenquiry)
$nextinsert .= " [input] ";
if($scholarsenquiry)
$nextinsert .= " [input] ";
if($titlesenquiry)
$nextinsert .= " [input] ";
$nextinsert .= "";
}
#####################################################
############### $previousinsert #####################
#####################################################

$new_offset2 = $offset - $limit;
if ($offset > 0) // can display previous msg
{
$disp = $limit;
$previousinsert = " << Previous ".$disp." Requests";

$previousinsert = " [input] Previous ".$disp." Requests [input] [input] [input] ";
if($searchenquiry)
$previousinsert .= " [input] ";
if($scholarsenquiry)
$previousinsert .= " [input] ";
if($titlesenquiry)
$previousinsert .= " [input] ";
$previousinsert .= "";
}
#####################################################
############### $lastinsert #########################
#####################################################

$new_offset3 = $mycounter - $limit;

if (($new_offset3 > $limit) and ($offset != $mycounter - $limit)) // can display goto end msg
{
$lastinsert = "Go To End [input] >|\"> [input] [input] [input] ";
if($searchenquiry)
$lastinsert .= " [input] ";
if($scholarsenquiry)
$lastinsert .= " [input] ";
if($titlesenquiry)
$lastinsert .= " [input] ";
$lastinsert .= "";
}
#####################################################
############### $firstinsert ########################
#####################################################

$new_offset4 = $mycounter - $limit;
if ($new_offset4 > $limit) // can display goto beginning msg
{
$new_offset4 = 0;
$firstinsert = " [input] Go To Beginning [input] [input] [input] ";
if($searchenquiry)
$firstinsert .= " [input] ";
if($scholarsenquiry)
$firstinsert .= " [input] ";
if($titlesenquiry)
$firstinsert .= " [input] ";
$firstinsert .= "";
}

#####################################################
############### Display Inserts #####################
#####################################################

#####################################################
if (($previousinsert) or ($nextinsert))
#echo "";
echo "";

#if (($previousinsert) || ($nextinsert))
#echo "(Sorted by id - $mycounter records found total)";

if (($previousinsert) or ($nextinsert))
echo "";

if (($firstinsert) and ($offset != 0)) echo "$firstinsert";

if ($previousinsert) echo "$previousinsert";

if (($previousinsert) && ($nextinsert)) echo "| ";

if ($nextinsert) echo "$nextinsert";

if ($lastinsert) echo "$lastinsert";

if (($previousinsert) or ($nextinsert))
#echo "";
echo "";

?>

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

 
                
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

attached mail follows:


* Thus wrote John Taylor-Johnston:
> Finally something I can give back, made by my little lonesome with no help :)

heh.. we all started somewhere.

>
> > I have a query that returns lots of rows so I want to display the results in blocks of 25 or so on my web page and have forward and back buttons to navigate the results.
>
> include it first:

I would strongly discourage posting and scripts you have, there are
serveral reasons why it shouldn't really be done besides that we
would have 1000's of posts that say.. here is my script...

But more importantly, i'd have to go through them all pointing out
all the wrong/bad things they did :D

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


On Sunday 11 July 2004 13:07, Karam Chand wrote:

> Sorry. But I just didnt remember the email addy so I
> took that way :).

Can't resist picking on this one. All posts to the list should/would have the
list address in the To: header. It's not that hard to copy paste the address
into a *new* mail. Anyway just add the list address into your address book.
NOW :)

> Now, many of the ISPs blokc 3306 for security reason
> and you cannot access MySQL from a 3rd party tool and
> have to use phpMyAdmin which is able to access the
> MySQL server as it is running on the same box.
> Sometimes, SSH tunneling is also not the option :)
>
> Most of these tools use MySQL C API() or some sort of
> wrapper for it to connnect to the server and do their
> job. Instead of connecting directly to the server
> using:
>
> mysql_real_connect ( .... ).
>
> They callup the above mentioned PHP file and pass the
> query as a argument. The PHP file then connects to the
> local mysql server,executes the query and returns all
> the required data as XML or a pre-determined format.
> In the client side the app again assembles this data
> and fills up MYSQL_RES* structure, the main structure
> in C API() to work with resultsets.

Just a few points I want to bring up:

1) Any monkey can run queries on your server unless you authenticate the
connection using sessions.

2) Your data will pass through the web in clear text unless you do your own
encryption/decryption or use SSL.

3) Adding an access layer would obviously increase the overhead.

If this is for a mission-critical application then you really are much better
off getting yourself a dedicated server then you can do whatever tunnelling
you want.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
"May the forces of evil become confused on the way to your house."
-- George Carlin
*/

attached mail follows:


* Thus wrote Karam Chand:
> --- Curt Zirzow <php-generalzirzow.dyndns.org> wrote:
>
> Now, many of the ISPs blokc 3306 for security reason
> and you cannot access MySQL from a 3rd party tool and
> have to use phpMyAdmin which is able to access the
> MySQL server as it is running on the same box.
> Sometimes, SSH tunneling is also not the option :)

There usually is a reason why the port 3306 port is blocked or that
mysql simply doesn't listen to outside addresses on that port. By
trying to circumstant that will probably result in a violation of
their TOS.

And as Jason suggested, use an ISP that either supports ssh
tunneling (which is preferred and more likely to occur) or find a
ISP that allows port 3336 to the open world.

What you describe is more in the lines of Proxying, which is
probably why I was confused. And I wouldn't suggest to anyone to
do that kind of proxying, the layers between everything can be
*very* unstable.

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


Hi all,

I want to store PHP-encrypted (Rijndael_256) data in MySQL.

The problem is:
If the encrypted string includes " the MySQL-query is influenced.

Therefore the question:
Is it possible to define characters n o t to be used by the
crypto-function?

Greetings
Klaus

attached mail follows:


* Thus wrote klaus:
> Hi all,
>
> I want to store PHP-encrypted (Rijndael_256) data in MySQL.
>
> The problem is:
> If the encrypted string includes " the MySQL-query is influenced.
>
> Therefore the question:
> Is it possible to define characters n o t to be used by the
> crypto-function?

no.

Simply use mysql_real_escape_string() on the encrypted string.

Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!

attached mail follows:


Hey Lukasz,

I had a similar situation. Documents are now stored in MySQL. Authors can
log in and add or edit their own documents. I control the look and feel of
the main site. You can see an example by creating an account on
AtFantasy.com and logging in. It takes advantage of modules from
Interakt.ro

-Ed

> -----Original Message-----
> I am currently restructuring the web site/web application development
> life cycle of my company. The new model requires the use of CVS (2
> branches) for each web site project. The issue I am facing is the
> maintenance/development of web sites utilizing CVS, while still
> providing content management functionality for the customers. I am
> currently utilizing the Macromedia Contribute software for client web
> site content management. The system however makes direct modifications
> to the live web site html/php pages, which makes it difficult to use
> while still trying to maintain the web site files in CVS.
>
> I have considering the implementation of the server wide CMS written in
> PHP, that would separate the content into a database, and also provide
> the ability to include content management functionality in custom
> developed web sites. I am currently evaluating the eZ publish 3.4
> (http://ez.no/ez_publish).
>
> I would appreciate feedback and recommendations of any other PHP user
> that has experience with the presented issue.
>
> Thanks in advance,
>
> --
> Lukasz Karapuda
> VP Application Development - newline Creations LLC
> http://www.thenewline.com/portfolio.htm
> lkarapudathenewline.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


Hi all,

does anybody know whether RIJNDAEL
uses ASCII as output character set for
encryption?

Greetings
Klaus

attached mail follows:


When a user first comes to my site, the user's session id is checked and
validated. If no session id is present or the validation fails, the user is
vectored to a second page containing a login form. When the user enters the
username and password and then clicks the submit button the info is
forwarded to a third page, a php script, validate_member_login.php, that
checks the username and password against a database. Just for completeness,
note that the php script, validate_member_login.php, is invoked via login
form's action parameter, i.e.,

        <form action="validate_member_login.php" ... />

The problem is that the php script, validate_member_login.php, is displayed
in the browser rather than being executed.

This is my first attempt at designing a dynamic web site so I'm sure I've
missed something really basic, but I have hardly any hair left to pull out.

Thanks, in advance,

Michael

attached mail follows:


> The problem is that the php script, validate_member_login.php, is
> displayed in the browser rather than being executed.

Are you running an Apache server? If so, be sure you have the appropriate
AddType lines in your configuration, as described in
http://www.php.net/manual/en/install.apache.php

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html

attached mail follows:


Here is some additional info:

My other PHP scripts execute just fine, including the php script init.php
which uses header(...) to dispatch to the member_login.htm page. Recall that
the problem arises when validate_member_login.php is invoked from
member_login.htm. When validate_member_login.php is invoked directly, it
executes properly.

I'm running the most recent production release of the Apache server on
winxp. My ISP is running the same version. I've configured PHP identically
with my ISP's Apache config. I use Dreamweaver MX for development and
testing. I've not tested for this problem on my ISP's system, yet

Once again, note that the php script, validate_member_login.php is executed
properly in one case, yet is displayed in the browser in the other. Here is
the code for validate_member_login.php:

<?php
include_once('../init.php');

/**
 * Variables set by member_login.htm are:
 * username -- contains the username of the member.
 * password -- contains the member's password.
 */
$username = trim($HTTP_POST_VARS['username']);
$password = trim($HTTP_POST_VARS['password']);

$result = authenticate_member_login( $username, $password );
if( $result == 0 ) {
     $HTTP_SESSION_VARS['session_id'] = crypt_password( $password );
     $HTTP_SESSION_VARS['username'] = $username;
     header( 'Location: '.MEMBER_HOME_PAGE );
} else {
     header( 'Location: '.MEMBER_LOGIN_PAGE );
}
?>

'init.php' executes session_start(), sets a bunch of constants (e.g.,
MEMBER_HOME_PAGE, etc.), sets an error handler, and includes a bunch of
libraries. All standard stuff.

Again, any help would be appreciated.

Cheers,

Michael

"Michael T. Peterson" <mtp1032comcast.net> wrote in message
news:ccsfe8$liu$1sea.gmane.org...
> When a user first comes to my site, the user's session id is checked and
> validated. If no session id is present or the validation fails, the user
is
> vectored to a second page containing a login form. When the user enters
the
> username and password and then clicks the submit button the info is
> forwarded to a third page, a php script, validate_member_login.php, that
> checks the username and password against a database. Just for
completeness,
> note that the php script, validate_member_login.php, is invoked via login
> form's action parameter, i.e.,
>
> <form action="validate_member_login.php" ... />
>
> The problem is that the php script, validate_member_login.php, is
displayed
> in the browser rather than being executed.
>
> This is my first attempt at designing a dynamic web site so I'm sure I've
> missed something really basic, but I have hardly any hair left to pull
out.
>
> Thanks, in advance,
>
> Michael
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


this all seems just fine to me, aren't you sending some Header:
Content-type -s?
could you post that init.php script source? and is that apache server
working well for other scripts that are called from the forms?
AND ... just to be sure,... are you calling that html which contains the
form thru server? (like http://localhost/myform.html) ... ? because,
when calling it directly from dreamweaver,
it could be called like direct html file (eg.
file://c:/myhtmls/myform.html) and then the script will be called as
file://c:/myhtmls/my_authentication_script.php instead of
http://localhost/my_authentication_script.php

that's all what comes to my mind,
regards,
m.

Michael T. Peterson wrote:

>Here is some additional info:
>
>My other PHP scripts execute just fine, including the php script init.php
>which uses header(...) to dispatch to the member_login.htm page. Recall that
>the problem arises when validate_member_login.php is invoked from
>member_login.htm. When validate_member_login.php is invoked directly, it
>executes properly.
>
>I'm running the most recent production release of the Apache server on
>winxp. My ISP is running the same version. I've configured PHP identically
>with my ISP's Apache config. I use Dreamweaver MX for development and
>testing. I've not tested for this problem on my ISP's system, yet
>
>Once again, note that the php script, validate_member_login.php is executed
>properly in one case, yet is displayed in the browser in the other. Here is
>the code for validate_member_login.php:
>
><?php
>include_once('../init.php');
>
>/**
> * Variables set by member_login.htm are:
> * username -- contains the username of the member.
> * password -- contains the member's password.
> */
>$username = trim($HTTP_POST_VARS['username']);
>$password = trim($HTTP_POST_VARS['password']);
>
>$result = authenticate_member_login( $username, $password );
>if( $result == 0 ) {
> $HTTP_SESSION_VARS['session_id'] = crypt_password( $password );
> $HTTP_SESSION_VARS['username'] = $username;
> header( 'Location: '.MEMBER_HOME_PAGE );
>} else {
> header( 'Location: '.MEMBER_LOGIN_PAGE );
>}
>?>
>
>'init.php' executes session_start(), sets a bunch of constants (e.g.,
>MEMBER_HOME_PAGE, etc.), sets an error handler, and includes a bunch of
>libraries. All standard stuff.
>
>Again, any help would be appreciated.
>
>Cheers,
>
>Michael
>
>"Michael T. Peterson" <mtp1032comcast.net> wrote in message
>news:ccsfe8$liu$1sea.gmane.org...
>
>
>>When a user first comes to my site, the user's session id is checked and
>>validated. If no session id is present or the validation fails, the user
>>
>>
>is
>
>
>>vectored to a second page containing a login form. When the user enters
>>
>>
>the
>
>
>>username and password and then clicks the submit button the info is
>>forwarded to a third page, a php script, validate_member_login.php, that
>>checks the username and password against a database. Just for
>>
>>
>completeness,
>
>
>>note that the php script, validate_member_login.php, is invoked via login
>>form's action parameter, i.e.,
>>
>> <form action="validate_member_login.php" ... />
>>
>>The problem is that the php script, validate_member_login.php, is
>>
>>
>displayed
>
>
>>in the browser rather than being executed.
>>
>>This is my first attempt at designing a dynamic web site so I'm sure I've
>>missed something really basic, but I have hardly any hair left to pull
>>
>>
>out.
>
>
>>Thanks, in advance,
>>
>>Michael
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>
>
>

attached mail follows:


Hi,

Monday, July 12, 2004, 10:28:59 AM, you wrote:
MTP> Here is some additional info:

MTP> My other PHP scripts execute just fine, including the php script init.php
MTP> which uses header(...) to dispatch to the member_login.htm page. Recall that
MTP> the problem arises when validate_member_login.php is invoked from
MTP> member_login.htm. When validate_member_login.php is invoked directly, it
MTP> executes properly.

MTP> I'm running the most recent production release of the Apache server on
MTP> winxp. My ISP is running the same version. I've configured PHP identically
MTP> with my ISP's Apache config. I use Dreamweaver MX for development and
MTP> testing. I've not tested for this problem on my ISP's system, yet

MTP> Once again, note that the php script,
MTP> validate_member_login.php is executed
MTP> properly in one case, yet is displayed in the browser in the other. Here is
MTP> the code for validate_member_login.php:

MTP> <?php
MTP> include_once('../init.php');

MTP> /**
MTP> * Variables set by member_login.htm are:
MTP> * username -- contains the username of the member.
MTP> * password -- contains the member's password.
MTP> */
MTP> $username = trim($HTTP_POST_VARS['username']);
MTP> $password = trim($HTTP_POST_VARS['password']);

MTP> $result = authenticate_member_login( $username, $password );
MTP> if( $result == 0 ) {
MTP> $HTTP_SESSION_VARS['session_id'] = crypt_password( $password );
MTP> $HTTP_SESSION_VARS['username'] = $username;
MTP> header( 'Location: '.MEMBER_HOME_PAGE );
MTP> } else {
MTP> header( 'Location: '.MEMBER_LOGIN_PAGE );
MTP> }
?>>

MTP> 'init.php' executes session_start(), sets a bunch of constants (e.g.,
MTP> MEMBER_HOME_PAGE, etc.), sets an error handler, and includes a bunch of
MTP> libraries. All standard stuff.

MTP> Again, any help would be appreciated.

MTP> Cheers,

MTP> Michael

Sounds like you forgot the <?php in the include script

--
regards,
Tom

attached mail follows:


Per request, here are the two other source files that get executed prior to
the invocation of validate_member_login.php, index.php and init.php.

But first, here's a simple restatement of the problem:

(1) Direct the browser to open index.php
(2) init.php is included by index.php.
(3) index.php dispatches user to member_login.htm. User fills in username
and password fields and then presses the submit button.
(4) <form action="validate_member_login.php" .../> is invoked.
(5) The source code of validate_member_login.php is displayed in the browser
rather then being executed.

However, when the invocation sequence is:

(1) Direct the browser directly to member_login.htm and fill in the username
and password fields.
(2) Press submit.
(3) validate_member_login.php is executed properly.

Here's index.php. Its purpose is to check the session variables to
determine whether the user is logged in. If not, the user is dispatched to
member_login.php via redirct using header().

Now, here are the two php files of interest, index.php and init.php. First,
index.php,

<?php
include_once( 'init.php' );

/**
 * If member is already logged in, his/her username and password values will
be available to us.
 */
 if( isset( $HTTP_SESSION_VARS['session_id'] ) && isset(
$HTTP_SESSION_VARS['username'] ) )
 {
    $session_id = $HTTP_SESSION_VARS['session_id'];
    $username = $HTTP_SESSION_VARS['username'];

    $result = authenticate_session( $username, $session_id );
     if( $result != SUCCESS )
     {
          if( $result == MEMBER_NOT_REGISTERED ) {
               header( 'Location: '.MEMBER_REGISTRATION_PAGE );
          } else if( $result == PASSWORD_MISMATCH ) {
               header( 'Location: '.MEMBER_LOGIN_PAGE );
          } else {
               die( $result );
          }
     }
     header( 'Location: '.MEMBER_HOME_PAGE );
 }
 header( 'Location: '.MEMBER_LOGIN_PAGE );
?>

Here is init.php, the file that index.php includes (see above). This file
just sets up the exectution environment.

<?php
session_start();
/**
 * init.php
 *
 * Script that initializes the execution environment.
 */

//
// Check whether this is running on a UNIX or a Windows operating system.
// We need to know this to set the include_path separator character
// character correctly.
//
$isWindows = false;
$pathDelimiter = ':';
$operatingSystem = PHP_OS;

if( strcmp( $operatingSystem, 'WINNT' ) == 0 )
{
     $isWindows = true;
     $pathDelimiter = ';';
}

// Uncomment and use this symbol when publishing to the internet on
ipowerweb.
// Yields /home/mazamaso/public_html

$WWWROOT = $_SERVER['DOCUMENT_ROOT'];

// Set up the dev directory's environment variables.
$PROJECT_DIR = $WWWROOT.'/northwest_steelheader';
$MEMBERS_DIR = $PROJECT_DIR.'/members';
$SCRIPTS_DIR = $PROJECT_DIR.'/scripts';
$DB_SCRIPTS_DIR = $SCRIPTS_DIR.'/db';
$UTILS_SCRIPTS_DIR = $SCRIPTS_DIR.'/utils';
$SESSION_SCRIPTS_DIR = $SCRIPTS_DIR.'/security';
$GRAPHICS_DIR = $SCRIPTS_DIR.'/jpgraphics';

$MEMBER_HOME_PAGE = $PROJECT_DIR.'/member_homepage.html';
$MEMBER_LOGIN_PAGE = $MEMBERS_DIR.'/member_login.htm';
$MEMBER_REGISTRATION_PAGE = $MEMBERS_DIR.'/member_registration_form.htm';
$MEMBER_LOGOUT_PAGE = $MEMBERS_DIR.'/member_logout.php';

$INCLUDE_PATH =
'.'.$pathDelimiter.$PROJECT_DIR.$pathDelimiter.$DB_SCRIPTS_DIR.$pathDelimite
r.$UTILS_SCRIPTS_DIR.$pathDelimiter.$GRAPHICS_DIR.$pathDelimiter.$SESSION_SC
RIPTS_DIR;

//
// Establish the site's environment variables
//
define( 'PROJECT_DIR', $PROJECT_DIR );
define( 'MEMBERS_DIR', $MEMBERS_DIR );
define( 'SCRIPTS_DIR', $SCRIPTS_DIR );
define( 'DB_DIR', $DB_SCRIPTS_DIR );
define( 'UTILS_DIR', $UTILS_SCRIPTS_DIR );
define( 'SESSION_DIR', $SESSION_SCRIPTS_DIR );
define( 'DEBUG', true );
define( 'MEMBER_HOME_PAGE', $MEMBER_HOME_PAGE );
define( 'MEMBER_LOGIN_PAGE', $MEMBER_LOGIN_PAGE );
define( 'MEMBER_REGISTRATION_PAGE', $MEMBER_REGISTRATION_PAGE );
define( 'MEMBER_LOGOUT_PAGE', $MEMBER_LOGOUT_PAGE );

if( strcmp( $WWWROOT, 'c:/program files/apache group/apache/htdocs' ) == 0 )
{
     define( 'DB_NAME', 'wwwwwwww' );
     define( 'DB_ADMIN', 'aaaaaaaaa' );
     define( 'DB_PASSWORD', 'bbbbbbbbb' );
} else {
     define( 'DB_NAME', 'wwwwwwww' );
     define( 'DB_ADMIN', 'xxxxxxxx' );
     define( 'DB_PASSWORD', 'yyyyyyyy' );
}

ini_set( 'include_path', $INCLUDE_PATH );
ini_set( 'session.save_path', $PROJECT_DIR.'session_stats');

// These are the base includes, i.e., that apply to every php file in the
site
include_once( 'print_utils.php' );
include_once( 'mz_error_handler.php' );
include_once( 'db_utils.php' );
include_once( 'passwords.php' );
include_once( 'date_utils.php' );
include_once( 'session_control_lib.php' );

set_error_handler( 'mz_error_handler' );
assert_options( ASSERT_ACTIVE, TRUE );
assert_options( ASSERT_BAIL, TRUE );

?>

<snip>

attached mail follows:


http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e
http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é

It still sorts "é" and "e" separately, but without a parse error:

$first = array('à', 'é');
$second = array('a', 'e');

usort($authors, create_function('$a,$b','
        $a = str_replace($first, $second, $a);
        $b = str_replace($first, $second, $b);
        return strcasecmp($a,$b);'));

Back to the drawing board? I tried this too:

$first = array('à', 'é', 'À', 'É');
$second = array('a', 'e', 'A', 'É');

Ideas? Thanks,
John

> Parse error on line 40:
>
> 39> usort($authors, create_function('$a,$b','
> 40> $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
> 41> $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
> 42> return strcasecmp($a,$b);'));

<?php

if(!$ausenquiry) $ausenquiry ="a";

echo "<tr><td>
Note: A star, \"*\", indicates that the author uses a pseudonym.<br>Noter : Une étoile, \"*\", indique que cet auteur est connu par un nom de plume.

<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n";

######################################################
$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);

$news = mysql_query("select id,AUS from $table");

######################################################
$authors = array();
$author_list = array();

while ($mydata = mysql_fetch_object($news))
{
  $mydata->AUS = str_replace(" ;", ";", $mydata->AUS);
  $mydata->AUS = str_replace("; ", ";", $mydata->AUS);
  $tempauthors = explode(";", $mydata->AUS);
  foreach ($tempauthors as $singleauthor)
  {
    if ($singleauthor <> "")
    {
      array_push($authors, $singleauthor);
      $author_list[$singleauthor][] = $mydata->id; // use an associative array...
   }
  }
}

#sort($authors);
#usort($authors, create_function('$a,$b','return strcasecmp($a,$b);'));

#usort($authors, create_function('$a,$b','
# $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
# $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
# return strcasecmp($a,$b);'));

$first = array('à', 'é', 'À', 'É');
$second = array('a', 'e', 'A', 'É');

usort($authors, create_function('$a,$b','
        $a = str_replace($first, $second, $a);
        $b = str_replace($first, $second, $b);
        return strcasecmp($a,$b);'));

foreach (array_count_values ($authors) as $author=>$count)
{

 if((strtolower(substr($author, 0, 1)) == $ausenquiry))
 {

  echo "<tr bgcolor=\"#D3DCE3\">";
   echo "<th align=\"left\" colspan=\"2\"><a href=\"".$SCRIPT_NAME."?searchenquiry=".urlencode($author)."\">".$author."</a> <small>[&lt;--Search Entire Database]</small></th>";
   echo "<th align=\"right\" width=\"5%\" nowrap>(".$count." ";
    if($count > 1)
    {echo "records found/trouvés)";}
    else{echo "record found/trouvé)";}
   echo"</th></tr>\n";

   echo "<tr bgcolor=\"#F5F5F5\"><td>&nbsp;</td>";
   echo "<td align=\"left\">";
   $temp = "";
   foreach ($author_list[$author] as $ausid)
   {
   $temp .= "<a target=\"printwindow\" href=\"print.php?id=".urlencode($ausid)."\">".$ausid."</a>, ";
   }
   $temp = substr("$temp", 0, -2);
   echo "$temp</td>";
   echo "<td>&nbsp;</td>";
  echo "</tr>\n";
 }
}

mysql_close($myconnection);
######################################################
echo "</table>
</td>
</tr>\n";

?>

attached mail follows:


this is slightly changed function of yours, written for better
readability...

<?php
$authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'albert',
'alfred', 'amadeus', 'elen');

function usort_callback($a, $b) {
     $a = strtolower($a); $b = strtolower($b);
     $a = str_replace(array('á', 'é'), array('a', 'e'), strtolower($a));
     $b = str_replace(array('á', 'é'), array('a', 'e'), strtolower($b));
     return (strcmp($a, $b));
}

usort($authors, 'usort_callback');

var_dump($authors);
?>

it does diacritics safe and case-insensitive sort of authors... at least
on my workstation... is it what you need? while i don't have your
original problem, i just can guess... hope it helps.

m.

John Taylor-Johnston wrote:

> http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e
> http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é
>
> It still sorts "é" and "e" separately, but without a parse error:
>
> $first = array('à', 'é');
> $second = array('a', 'e');
>
> usort($authors, create_function('$a,$b','
> $a = str_replace($first, $second, $a);
> $b = str_replace($first, $second, $b);
> return strcasecmp($a,$b);'));
>
> Back to the drawing board? I tried this too:
>
> $first = array('à', 'é', 'À', 'É');
> $second = array('a', 'e', 'A', 'É');
>
> Ideas? Thanks,
> John
>
>
>
>>Parse error on line 40:
>>
>>39> usort($authors, create_function('$a,$b','
>>40> $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
>>41> $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
>>42> return strcasecmp($a,$b);'));
>
>
> <?php
>
> if(!$ausenquiry) $ausenquiry ="a";
>
> echo "<tr><td>
> Note: A star, \"*\", indicates that the author uses a pseudonym.<br>Noter : Une étoile, \"*\", indique que cet auteur est connu par un nom de plume.
>
> <table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n";
>
>
> ######################################################
> $myconnection = mysql_connect($server,$user,$pass);
> mysql_select_db($db,$myconnection);
>
> $news = mysql_query("select id,AUS from $table");
>
> ######################################################
> $authors = array();
> $author_list = array();
>
> while ($mydata = mysql_fetch_object($news))
> {
> $mydata->AUS = str_replace(" ;", ";", $mydata->AUS);
> $mydata->AUS = str_replace("; ", ";", $mydata->AUS);
> $tempauthors = explode(";", $mydata->AUS);
> foreach ($tempauthors as $singleauthor)
> {
> if ($singleauthor <> "")
> {
> array_push($authors, $singleauthor);
> $author_list[$singleauthor][] = $mydata->id; // use an associative array...
> }
> }
> }
>
> #sort($authors);
> #usort($authors, create_function('$a,$b','return strcasecmp($a,$b);'));
>
> #usort($authors, create_function('$a,$b','
> # $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
> # $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
> # return strcasecmp($a,$b);'));
>
> $first = array('à', 'é', 'À', 'É');
> $second = array('a', 'e', 'A', 'É');
>
> usort($authors, create_function('$a,$b','
> $a = str_replace($first, $second, $a);
> $b = str_replace($first, $second, $b);
> return strcasecmp($a,$b);'));
>
>
> foreach (array_count_values ($authors) as $author=>$count)
> {
>
> if((strtolower(substr($author, 0, 1)) == $ausenquiry))
> {
>
> echo "<tr bgcolor=\"#D3DCE3\">";
> echo "<th align=\"left\" colspan=\"2\"><a href=\"".$SCRIPT_NAME."?searchenquiry=".urlencode($author)."\">".$author."</a> <small>[&lt;--Search Entire Database]</small></th>";
> echo "<th align=\"right\" width=\"5%\" nowrap>(".$count." ";
> if($count > 1)
> {echo "records found/trouvés)";}
> else{echo "record found/trouvé)";}
> echo"</th></tr>\n";
>
> echo "<tr bgcolor=\"#F5F5F5\"><td>&nbsp;</td>";
> echo "<td align=\"left\">";
> $temp = "";
> foreach ($author_list[$author] as $ausid)
> {
> $temp .= "<a target=\"printwindow\" href=\"print.php?id=".urlencode($ausid)."\">".$ausid."</a>, ";
> }
> $temp = substr("$temp", 0, -2);
> echo "$temp</td>";
> echo "<td>&nbsp;</td>";
> echo "</tr>\n";
> }
> }
>
> mysql_close($myconnection);
> ######################################################
> echo "</table>
> </td>
> </tr>\n";
>
> ?>
>

attached mail follows:


Pardon me for the strtolower line, i've just forgot there... it's 4:30AM
here in Slovakia... :/

correct listing follows...

<?php
$authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'albert',
'alfred', 'amadeus', 'elen');

function usort_callback($a, $b) {
     $a = str_replace(array('á', 'é'), array('a', 'e'), strtolower($a));
     $b = str_replace(array('á', 'é'), array('a', 'e'), strtolower($b));
     return (strcmp($a, $b));
}

usort($authors, 'usort_callback');

var_dump($authors);
?>

regards,
m.

John Taylor-Johnston wrote:

> http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e
> http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é
>
> It still sorts "é" and "e" separately, but without a parse error:
>
> $first = array('à', 'é');
> $second = array('a', 'e');
>
> usort($authors, create_function('$a,$b','
> $a = str_replace($first, $second, $a);
> $b = str_replace($first, $second, $b);
> return strcasecmp($a,$b);'));
>
> Back to the drawing board? I tried this too:
>
> $first = array('à', 'é', 'À', 'É');
> $second = array('a', 'e', 'A', 'É');
>
> Ideas? Thanks,
> John
>
>
>
>>Parse error on line 40:
>>
>>39> usort($authors, create_function('$a,$b','
>>40> $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
>>41> $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
>>42> return strcasecmp($a,$b);'));
>
>
> <?php
>
> if(!$ausenquiry) $ausenquiry ="a";
>
> echo "<tr><td>
> Note: A star, \"*\", indicates that the author uses a pseudonym.<br>Noter : Une étoile, \"*\", indique que cet auteur est connu par un nom de plume.
>
> <table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n";
>
>
> ######################################################
> $myconnection = mysql_connect($server,$user,$pass);
> mysql_select_db($db,$myconnection);
>
> $news = mysql_query("select id,AUS from $table");
>
> ######################################################
> $authors = array();
> $author_list = array();
>
> while ($mydata = mysql_fetch_object($news))
> {
> $mydata->AUS = str_replace(" ;", ";", $mydata->AUS);
> $mydata->AUS = str_replace("; ", ";", $mydata->AUS);
> $tempauthors = explode(";", $mydata->AUS);
> foreach ($tempauthors as $singleauthor)
> {
> if ($singleauthor <> "")
> {
> array_push($authors, $singleauthor);
> $author_list[$singleauthor][] = $mydata->id; // use an associative array...
> }
> }
> }
>
> #sort($authors);
> #usort($authors, create_function('$a,$b','return strcasecmp($a,$b);'));
>
> #usort($authors, create_function('$a,$b','
> # $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
> # $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
> # return strcasecmp($a,$b);'));
>
> $first = array('à', 'é', 'À', 'É');
> $second = array('a', 'e', 'A', 'É');
>
> usort($authors, create_function('$a,$b','
> $a = str_replace($first, $second, $a);
> $b = str_replace($first, $second, $b);
> return strcasecmp($a,$b);'));
>
>
> foreach (array_count_values ($authors) as $author=>$count)
> {
>
> if((strtolower(substr($author, 0, 1)) == $ausenquiry))
> {
>
> echo "<tr bgcolor=\"#D3DCE3\">";
> echo "<th align=\"left\" colspan=\"2\"><a href=\"".$SCRIPT_NAME."?searchenquiry=".urlencode($author)."\">".$author."</a> <small>[&lt;--Search Entire Database]</small></th>";
> echo "<th align=\"right\" width=\"5%\" nowrap>(".$count." ";
> if($count > 1)
> {echo "records found/trouvés)";}
> else{echo "record found/trouvé)";}
> echo"</th></tr>\n";
>
> echo "<tr bgcolor=\"#F5F5F5\"><td>&nbsp;</td>";
> echo "<td align=\"left\">";
> $temp = "";
> foreach ($author_list[$author] as $ausid)
> {
> $temp .= "<a target=\"printwindow\" href=\"print.php?id=".urlencode($ausid)."\">".$ausid."</a>, ";
> }
> $temp = substr("$temp", 0, -2);
> echo "$temp</td>";
> echo "<td>&nbsp;</td>";
> echo "</tr>\n";
> }
> }
>
> mysql_close($myconnection);
> ######################################################
> echo "</table>
> </td>
> </tr>\n";
>
> ?>
>

attached mail follows:


Thanks!
What does var_dump do? (I didn't really understand the manual.)

"Miroslav Hudak (php/ml)" wrote:

> Pardon me for the strtolower line, i've just forgot there... it's 4:30AM
> here in Slovakia... :/
>
> correct listing follows...
>
> <?php
> $authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'albert',
> 'alfred', 'amadeus', 'elen');
>
> function usort_callback($a, $b) {
> $a = str_replace(array('á', 'é'), array('a', 'e'), strtolower($a));
> $b = str_replace(array('á', 'é'), array('a', 'e'), strtolower($b));
> return (strcmp($a, $b));
> }
>
> usort($authors, 'usort_callback');
>
> var_dump($authors);
> ?>
>
> regards,
> m.
>
> John Taylor-Johnston wrote:
>
> > http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e
> > http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é
> >
> > It still sorts "é" and "e" separately, but without a parse error:
> >
> > $first = array('à', 'é');
> > $second = array('a', 'e');
> >
> > usort($authors, create_function('$a,$b','
> > $a = str_replace($first, $second, $a);
> > $b = str_replace($first, $second, $b);
> > return strcasecmp($a,$b);'));
> >
> > Back to the drawing board? I tried this too:
> >
> > $first = array('à', 'é', 'À', 'É');
> > $second = array('a', 'e', 'A', 'É');
> >
> > Ideas? Thanks,
> > John
> >
> >
> >
> >>Parse error on line 40:
> >>
> >>39> usort($authors, create_function('$a,$b','
> >>40> $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
> >>41> $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
> >>42> return strcasecmp($a,$b);'));
> >
> >
> > <?php
> >
> > if(!$ausenquiry) $ausenquiry ="a";
> >
> > echo "<tr><td>
> > Note: A star, \"*\", indicates that the author uses a pseudonym.<br>Noter : Une étoile, \"*\", indique que cet auteur est connu par un nom de plume.
> >
> > <table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n";
> >
> >
> > ######################################################
> > $myconnection = mysql_connect($server,$user,$pass);
> > mysql_select_db($db,$myconnection);
> >
> > $news = mysql_query("select id,AUS from $table");
> >
> > ######################################################
> > $authors = array();
> > $author_list = array();
> >
> > while ($mydata = mysql_fetch_object($news))
> > {
> > $mydata->AUS = str_replace(" ;", ";", $mydata->AUS);
> > $mydata->AUS = str_replace("; ", ";", $mydata->AUS);
> > $tempauthors = explode(";", $mydata->AUS);
> > foreach ($tempauthors as $singleauthor)
> > {
> > if ($singleauthor <> "")
> > {
> > array_push($authors, $singleauthor);
> > $author_list[$singleauthor][] = $mydata->id; // use an associative array...
> > }
> > }
> > }
> >
> > #sort($authors);
> > #usort($authors, create_function('$a,$b','return strcasecmp($a,$b);'));
> >
> > #usort($authors, create_function('$a,$b','
> > # $a = str_replace(array('é', 'à'), array('e', 'a'), $a);
> > # $b = str_replace(array('é', 'à'), array('e', 'a'), $b);
> > # return strcasecmp($a,$b);'));
> >
> > $first = array('à', 'é', 'À', 'É');
> > $second = array('a', 'e', 'A', 'É');
> >
> > usort($authors, create_function('$a,$b','
> > $a = str_replace($first, $second, $a);
> > $b = str_replace($first, $second, $b);
> > return strcasecmp($a,$b);'));
> >
> >
> > foreach (array_count_values ($authors) as $author=>$count)
> > {
> >
> > if((strtolower(substr($author, 0, 1)) == $ausenquiry))
> > {
> >
> > echo "<tr bgcolor=\"#D3DCE3\">";
> > echo "<th align=\"left\" colspan=\"2\"><a href=\"".$SCRIPT_NAME."?searchenquiry=".urlencode($author)."\">".$author."</a> <small>[&lt;--Search Entire Database]</small></th>";
> > echo "<th align=\"right\" width=\"5%\" nowrap>(".$count." ";
> > if($count > 1)
> > {echo "records found/trouvés)";}
> > else{echo "record found/trouvé)";}
> > echo"</th></tr>\n";
> >
> > echo "<tr bgcolor=\"#F5F5F5\"><td>&nbsp;</td>";
> > echo "<td align=\"left\">";
> > $temp = "";
> > foreach ($author_list[$author] as $ausid)
> > {
> > $temp .= "<a target=\"printwindow\" href=\"print.php?id=".urlencode($ausid)."\">".$ausid."</a>, ";
> > }
> > $temp = substr("$temp", 0, -2);
> > echo "$temp</td>";
> > echo "<td>&nbsp;</td>";
> > echo "</tr>\n";
> > }
> > }
> >
> > mysql_close($myconnection);
> > ######################################################
> > echo "</table>
> > </td>
> > </tr>\n";
> >
> > ?>
> >