FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Converting Perl to PHP, testing CLI with $_POST (newbie)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Converting Perl to PHP, testing CLI with $_POST (newbie) [message #172077 is a reply to message #172076] Sun, 30 January 2011 04:41 Go to previous messageGo to previous message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma:
Member
"Jerry Stuckle" wrote in message
news:ii2n55$rhu$1(at)news(dot)eternal-september(dot)org...

> Paul, unfortunately the $_POST array is set up by the php web
> interface, not the CLI (and argv/argc are set up by the CLI and
> not the web interface, by default).

> I normally test on my local web server; you could do a quick test
> of the code by wrapping it in a quick interface which fills in the
> value, but that still won't show you the formatted output (or even
> determine if the $_POST variables are set up properly.

> Best is still to have a local development web site which closely
> mimics that of your production server (i.e. similar versions of
> PHP, MySQL, etc.) and test on it.

I just made a simple HTML file as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>
NEW Test for CLI CGI vars</title>
</head><body>
CGI test
<form id="Form1" action="http://localhost/cgi-bin/EventProcessor.php"
method="POST">

<input type="hidden" name="Full_Name" value="MyName">
<input type="hidden" name="Email" value="MyEmail">
<input type="hidden" name="Reference" value="MyPWD">

<script language = "Javascript">
Form1.submit();
</script></body></html>

But now I have a problem with SQLite3 (from
http://www.php.net/manual/en/sqlite3.open.php):

$dbfile = 'C:/xampp/cgi-bin/SCGBG_Data.db'; //I tried with the file
in place and deleted
class MyDB extends SQLite3
{
function __construct()
{
$this->open($dbfile); //This is line 184
}
}

$db = new MyDB();

I get this error:
Fatal error: Uncaught exception 'Exception' with message 'Unable to expand
filepath' in C:\xampp\cgi-bin\EventProcessor.php:184 Stack trace: #0
C:\xampp\cgi-bin\EventProcessor.php(184): SQLite3->open('') #1
C:\xampp\cgi-bin\EventProcessor.php(188): MyDB->__construct() #2 {main}
thrown in C:\xampp\cgi-bin\EventProcessor.php on line 184

I originally used the older SQLite functions but the database I was using in
Perl was SQLite3, and it worked OK, but with much different syntax.

my $dbfile = "../SCGBG/SCGBG_Data.db";
my $db = DBI->connect( # connect to your database, create if needed
"dbi:SQLite:dbname=$dbfile", # DSN: dbi, driver, database file
...

$db->do("CREATE TABLE tEntries (
eid INTEGER UNIQUE PRIMARY KEY, etype TEXT,
et TEXT, eurl TEXT,
sdt DATETIME KEY, sdow TEXT,
edt DATETIME, edow TEXT,
ed TEXT)");

Any ideas? Or should I switch to MySQL?

Thanks,

Paul
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: passing variable to a nested array
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 17:32:32 GMT 2024

Total time taken to generate the page: 0.04739 seconds