one word; chapters

February 5, 2003 under Computers, Programming

******** BEGIN COMMUNICATION ********

Barry (10:51 AM) :
how would i add var values to a header call?

Bullines@Work (10:52 AM) :
If the header in question is a PHP file, perhaps you can pass it some vars in
the URL.

Barry (10:52 AM) :
wait wait wait…. im all fuct now…..how do i send the browser one way and
the data the other?

Bullines@Work (10:53 AM) :
With PHP? Can’t (not that I know of). Period. PHP can’t operate at the system
level and cannot spawn child processes. Perl, on the other hand, can quite easily.

Barry (11:24 AM) :
i could prolly do a fopen on the other script and execute it no?

Bullines@Work (11:24 AM) :
fopen opens text files…doesn’t execute. PHP can’t execute shit.

Bullines@Work (11:28 AM) :
You need the equivalent of fork in Perl (http://www.perldoc.com/perl5.6/pod/func/fork.html)
in PHP…I don’t think PHP has it since it’s for the weeeeb only. I don’t think
fork() work on the Win32 version of Perl. We had fun killing a practice Solaris
server in university with the fork() function in Perl 😉

Barry (11:29 AM) :
http://www.php.net/manual/en/function.popen.php

Bullines@Work (11:30 AM) :
Ah, it does have it. Kewl. So there ya go. Use that and it’ll be mint.

Barry (11:31 AM) :
im not sure i really get this object though…..does it allow me to pass vars
and execute a remote script?

Bullines@Work (11:31 AM) :
Object? You mean function.

Barry (11:31 AM) :
yes func i mean

Barry (11:36 AM) :
do u think its possible?

Bullines@Work (11:37 AM) :
Now that I look at it, the PHP popen() fucntion is kinda shitty. It’s the equivalent
of a ShellExecute (Win16 API) or CreateProcess (Win32 API)….just launches
external shit…The Perl fork() is kinda like multithreading, which is mo betta.

Bullines@Work (11:38 AM) :
Whatcha could do is write a command-line app (hope you’re using Unix) in something
like PHP or even C. Then pass any vars as arguments. I’m pretty sure PHP scripts
can be run from a command line.

Barry (11:39 AM) :
thats sloppy…

Barry (11:40 AM) :
so im fuct.

Bullines@Work (11:45 AM) :
If you don’t wanna do that, yeah, you’re fuct. Use a real language.

Barry (11:47 AM) :
well i ll just put headers to jump back and forth i guess

Bullines@Work (11:49 AM) :
Just make sure no HTML gets written before hand…flicker flicker.

Barry (12:50 AM) :
i got it…. Stef is forwarding requests to my web server anyway…so the only
ip that will be available is our public. Im using 2 headers….works like a
charm the script that executes executes so fast that you cant even see the ip
anyway. but it somehow does….its our public ip 🙂 good system

Bullines@Work (01:33 PM) :
Good system? No. Smoke and mirrors? Yes 🙂

Barry (03:01 PM) :
u see a parse error in this?

if (! $cnx){
        $txtDoc = fopen("eat.txt","a+");
        $fp = fwrite($txtDoc,"$firstName, $lastName, $email");
         fclose($txtDoc);
}

Bullines@Work (03:02 PM) :
Try this:

if (!$cnx)
{
   $txtDoc = fopen("eat.txt","a+");
   $fp = fwrite($txtDoc, $firstName, $lastName, $email);
   fclose($txtDoc);
}

Barry (03:03 PM) :
nope

Bullines@Work (03:04 PM) :
Ok, then try something like:

if (!$cnx)
{
   $txtDoc = fopen("eat.txt","a+");
   $txtDoc = fwrite($txtDoc, $firstName, $lastName, $email);
   fclose($txtDoc);
}

Bullines@Work (03:04 PM) :
Nevermind that one.

Bullines@Work (03:05 PM) :
Is eat.txt there…in the right dir?

Barry (03:05 PM) :
no the a+ para makes the file if not present

Bullines@Work (03:05 PM) :
True enough.

Bullines@Work (03:07 PM) :
What’s in $cnx?

Barry (03:07 PM) :
no cnx is fine….its my odbc connect…im getting a parse error on the fopen
line

Bullines@Work (03:08 PM) :
Try a full path.

Barry (03:09 PM) :
http://www.dreamcatchergames.com/sales/

Barry (03:09 PM) :
oh oh oh

Bullines@Work (03:11 PM) :
In other words:

if ($cnx != 0)
{
   $txtDoc = fopen("/thepath/tothefile/eat.txt","a+");
   $fp = fwrite($txtDoc, $firstName, $lastName, $email);
   fclose($txtDoc);
}

Barry (03:12 PM) :
i got it…but this is kinda funny…..how am i supposed to test if it doesnt
connect?

Bullines@Work (03:12 PM) :
You mean $cnx?

Barry (03:13 PM) :
ya this is in cast cnx doesn tconnect it dumps the data to a txt……btu i
cant test it…

Bullines@Work (03:13 PM) :
Check the snippet I sent above.

Barry (03:13 PM) :
if the dsn is changed or the db name it just dies…

Barry (03:13 PM) :
get what i mean?

Bullines@Work (03:15 PM) :
Right, look up, yo. Here, I’ll ammend it a little:

if ($cnx == 0)
{
   // it didn't connect...do some other shit instead
}
else
{
   // it did conenct...keep on truckin' or pull out the return
   // and test some more
   $txtDoc = fopen("/thepath/tothefile/eat.txt","a+");
   $fp = fwrite($txtDoc, $firstName, $lastName, $email);
   fclose($txtDoc);
}

Barry (03:16 PM) :
oh ok….

Bullines@Work (03:16 PM) :
You were already testin’, man…couldn’t ya tell? 😉

Barry (03:17 PM) :
but the script dies on the odbc connect. and cnx has to be defined before the
if statement

Bullines@Work (03:18 PM) :
A bigger catch-all would be this:

if ($cnx < = 0)
{
   // it didn't connect...do some other shit instead
}
else
{
   // it did conenct...keep on truckin' or pull out the return
   // and test some more
   $txtDoc = fopen("/thepath/tothefile/eat.txt","a+");
   $fp = fwrite($txtDoc, $firstName, $lastName, $email);
   fclose($txtDoc);
}

Should I just demand a pay cheque from your president? 😉

Bullines@Work (03:35 PM) :
Test to see what’s returned in $cnx, man. If it returns a value that’s <=
0, then you gots troubles on your end.

Barry (03:37 PM) :
no it werx great.

Barry (03:38 PM) :

< ?
 
$today = date("F j, Y, g:i a");
 
 
/* Connect to database  */
$cnx = odbc_connect ( 'accessTest','','');
 
 
/* if bad connection dump data to text file */
if ($cnx == 0)
{
 
   $txtDoc = fopen("$today.txt", "a+");
   $fp = fwrite($txtDoc,$firstName, $lastName, $email);
   fclose($txtDoc);
 
}else{
 
/* make var out of SQL cmd  */
$SQL_Exec_String = "Insert Into people (firstName, lastName, email)
                        Values ('$firstName', '$lastName', '$email')";
 
/* Execute sql comd  */
$cur= odbc_exec( $cnx, $SQL_Exec_String );
 
 
/* close db connection  */
odbc_close($cnx);
 
 
/* redirect user  */
header("Location: http://www.dreamcatchergames.com");
 
}
?>

Bullines@Work (03:38 PM) :
Better with the test for 0, eh?

Barry (03:38 PM) :
ya i think so.

Barry (03:39 PM) :
im still a little effed with php operators anyway

Bullines@Work (03:39 PM) :
Kewl. Another crisis averted 🙂

******** END COMMUNICATION ********

[SIGH] Nobody wants to send me to E3 or Paris 🙁

On an another note, when I haven’t been helping Dena keep our two kittens, Sundae
and Belle under control, I’ve been messing around in Microsoft Visual C++ with some OpenGL stuff. I’ll
post some samples when I develop a few decent ones.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 »

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>