in reply to Perl vs. PHP: databases
Then in your Perl program:<?php // This is a hack to get around F2S's limitation of only allowing PHP- +MySQL $connect = mysql_connect("db.account.f2s.com:3306", "account", "passwo +rd") or die(mysql_error()); $result = mysql_db_query("account", $query, $connect); while($row = mysql_fetch_array($result)) { echo "{\n"; while(list ($key, $value) = each($row)) { echo "\t$key => q[$value],\n"; } echo "},\n"; } ?>
Hope this helps..oh and by the way, I believe Spaceports.com supports Perl and MySQL, though you have to request it (I requested a CGI account but they never received one, maybe you'll have more luck.)sub sql_query { my ($query) = @_; my ($data_structure, @data); # Ugly kluge to get SQL to work via Perl instead of PHP $query = url_encode($query); # TODO: use standard function $data_structure = get("http://www.account.f2s.com/sql.php?query=$q +uery"); @data = eval "($data_structure)"; return @data; }
|
|---|