View Full Version : Blank Page, but no error (i don't think)
norie
November 28th, 2003, 05:06 AM
I'm just learning flash, and i've set up a guest book in PHP. on Submit i use this code:
sendVars = new LoadVars();
sendVars.vname = _root.iname.text;
sendVars.vemail = _root.iemail.text;
sendVars.vaim = _root.iaim.text;
sendVars.vlink = _root.ilink.text;
sendVars.vshout = _root.ishout.text;
sendVars.vdate = (today.getMonth() + 1) + "/" + today.getDate() + "/" + today.getFullYear();
sendVars.send("addEntry.php", "POST");
<?
$vname = $HTTP_POST_VARS['vname'];
$vemail = $HTTP_POST_VARS['vemail'];
$vaim = $HTTP_POST_VARS['vaim'];
$vlink = $HTTP_POST_VARS['vlink'];
$vshout = $HTTP_POST_VARS['vshout'];
$vdate = $HTTP_POST_VARS['vdate'];
$vip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
if($vname != "" || $vemail != "" || $vshout != ""){
$connection = mysql_connect("localhost") or die("Connection Error");
mysql_select_db("guestbook", $connection);
$qString = "INSERT INTO `entries` ( `name` , `email` , `aim` , `link` , `shout` , `date`, `ip` ) VALUES ( '$vname', '$vemail','$vaim','$vlink','$vshout','$vdate', '$vip')";
$result = mysql_query($qString, $connection) or die ("Query Error");
}else{
print "PHP ERROR";
}
?>
it adds the entries into the database fine, but I am left with a blank page with the following code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1"></HEAD>
<BODY></BODY></HTML>
Anyone know why? or how i can automatically close it after the process is done?
btw.. WinXP, Apache 2, PHP 4
thanks :rambo:
Marz
November 28th, 2003, 12:19 PM
So you want the page to automatically close after all your database entries are complete?
Just use this method...
In your if statement in your php line...
$result = mysql_query($qString, $connection) or die ("Query Error");
// Place this code in here then...
print "<SCRIPT LANGUAGE='JavaScript'>";
print "window.close()";
print "</SCRIPT>";
I haven't gotten the chance to check this out yet... It may or may not work.. If I'm correct window.close() is the function that will close a window but for some reason.. I think the only way a window can be closed like this is if a window was opened using JavaScript's window.open() method...
But you can try it and see if it works out for you buddy :)
norie
November 28th, 2003, 12:23 PM
thanks for the response buddha, but i don't think you can close a javascript window with out an object, for example:
win= window.open(params..);
win.close();
Marz
November 28th, 2003, 12:26 PM
See.. That's what I thought too... ****..
Hmm.. lemme see here... I don't think there are any PHP commands to do that either.. But there has to be something out there that will allow you to do it..
Can't you use Javascript commands to open a window in Flash MX? I've seen it somewhere around the forums here... But since I've gotten away from Flash for a little bit.. I'm a tad bit rusty.. *lol*
Jubba
November 28th, 2003, 12:42 PM
sendVars = new LoadVars();
sendVars.vname = _root.iname.text;
sendVars.vemail = _root.iemail.text;
sendVars.vaim = _root.iaim.text;
sendVars.vlink = _root.ilink.text;
sendVars.vshout = _root.ishout.text;
sendVars.vdate = (today.getMonth() + 1) + "/" + today.getDate() + "/" + today.getFullYear();
sendVars.send("addEntry.php");
On your last line in your AS take out the POST parameter. For some reason in Flash if you define the method parameter as "POST" it will open a new page. If you don't specify a parameter it won't open a new page and it defaults to "POST"
that will (should) stop the page from opening altogether.
Marz
November 28th, 2003, 12:47 PM
Nice Vash! :) I might have known that if... I actually did Flash Experiments anymore.. *lmfao*
norie
November 28th, 2003, 12:58 PM
awesome, thanks Vash, you too buddha :beam:
Jubba
November 28th, 2003, 01:11 PM
actually it was ahmed that brought that to my attention. I was having a similar problem with a guestbook and ahmed pointed that out to me.
stupid macromedia!
Marz
November 28th, 2003, 01:12 PM
*lmao*... 10-4 on that big Johhnie-Boy :D
norie
November 28th, 2003, 01:28 PM
haha, that's what im making, almost finished, just a few finishing touches
Jubba
November 28th, 2003, 01:37 PM
awesome. did the fix work then?
norie
November 28th, 2003, 01:44 PM
nope. Well at least i don't get a blank page any more. But now it's not inserting the values into the database.
Jubba
November 28th, 2003, 01:49 PM
are you testing it locally or on the server?
λ
November 28th, 2003, 01:50 PM
you should use $_POST instead of $HTTP_POST_VARS ;)
I think the longer arrays are officially depreciated now.
norie
November 28th, 2003, 01:52 PM
locally
Jubba
November 28th, 2003, 01:59 PM
upload it to your server and it should work. Also do what njs said and use $_POST['varialbe'] (i never actually looked at the code... :()
When you test flash locally and a parameter is not assigned it seems to like to use "GET" as the default, but if you actually publish it on your server and test it from there it should work fine.
norie
November 28th, 2003, 02:02 PM
well i have apache, php, and mySQL installed on my machine and im testing it on 'localhost', i don't have a php host :(
im poooowr
λ
November 28th, 2003, 02:03 PM
oh yeah... Try not testing it in the IDE. Put it in your Apache directory and run it via a web browser.
Voetsjoeba had this problem - from the Standalone Player it always uses GET instead of POST.
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=39426
Also, your script is quite insecure - it is vulnerable to a type of attack called SQL Injection
http://uk.php.net/mysql_real_escape_string
That function fixes it :)
Jubba
November 28th, 2003, 02:04 PM
are you using a textfile to save the info?
norie
November 28th, 2003, 02:09 PM
im using this as the restrict in flash:
"A-Z a-z 0-9 / \\\ : . , \\- @ ( ! ) ? '";
VASH - im using mySQL
norie
November 28th, 2003, 02:14 PM
and now this code:
<HTML>
<?
$vname = mysql_real_escape_string($_POST['vname']));
$vemail = mysql_real_escape_string($_POST['vemail']);
$vaim = mysql_real_escape_string($_POST['vaim']);
$vlink = mysql_real_escape_string($_POST['vlink']);
$vshout = mysql_real_escape_string($_POST['vshout']);
$vdate = mysql_real_escape_string($_POST['vdate']);
$vip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
if($vname != "" || $vemail != "" || $vshout != ""){
$link = mysql_connect("localhost")or die("Could not connect : " . mysql_error());
mysql_select_db("guestbook", $link) or die("Could not select database");
$qString = "INSERT INTO `entries` ( `name` , `email` , `aim` , `link` , `shout` , `date`, `ip` ) VALUES ( '$vname', '$vemail','$vaim','$vlink','$vshout','$vdate', '$vip')";
$result = mysql_query($qString, $link) or die ("Query failed : " . mysql_error());
}else{
print "PHP ERROR";
}
mysql_close($link);
?>
thanks njs
λ
November 28th, 2003, 02:15 PM
$_SERVER is the shortened version of $_HTTP_SERVER_VARS ;)
I can't see any problems with that... is that working alright?
Edit: also, you should make the connection first, then use the conn identifier as the second argument in mysql_real_escape_string. So first go:
<?php
$link = mysql_connect("localhost", "", "");
$vname = mysql_real_escape_string($_POST['vname'], $conn);
//and so on
?>
norie
November 28th, 2003, 02:29 PM
yea, wow thanks! php works now:
$vip = $_SERVER['REMOTE_ADDR'];
$link = mysql_connect("localhost") or die("Could not connect : " . mysql_error());
$vname = mysql_real_escape_string($_POST['vname'], $link);
$vemail = mysql_real_escape_string($_POST['vemail'], $link);
$vaim = mysql_real_escape_string($_POST['vaim'], $link);
$vlink = mysql_real_escape_string($_POST['vlink'], $link);
$vshout = mysql_real_escape_string($_POST['vshout'], $link);
$vdate = mysql_real_escape_string($_POST['vdate'], $link);
mysql_select_db("guestbook", $link) or die("Could not select database");
$qString = "INSERT INTO `entries` ( `name` , `email` , `aim` , `link` , `shout` , `date`, `ip` ) VALUES ( '$vname', '$vemail','$vaim','$vlink','$vshout','$vdate', '$vip')";
$result = mysql_query($qString, $link) or die ("Query failed : " . mysql_error());
mysql_close($link);
but.... this still doesn't:
sendVars.send("addEntry.php");
this does (but i still get a blank page :( :
sendVars.send("addEntry.php", "POST");
Marz
November 29th, 2003, 04:56 PM
Is it possible that your server is trying to handle those variables as GET's instead of POST variables?
norie
November 29th, 2003, 07:49 PM
naw, i doubt it. 1. You can't see the qString in the address. 2.Using $_Post wouldn't work. 3. the script works, but the popup blank page is annoying and confusing, but just mostly annoying.
Marz
November 29th, 2003, 10:12 PM
1. You are right there... But I couldn't see the addie bar myself ;)
2. Using $_POST would work btw... Because you are telling it what method to use.
3. Yeah... I'm guessing it would be...
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.