View Full Version : Resolved How to make echo work?
elitis 11-05-2010, 08:59 PM I'm trying to get the variable to echo in the video embed script below. There are no errors or anything on the page but the page is completely blank when I load it. And when I look at the source code data has nothing in it.
video embed script:
<?php
$dlink = $_POST["decallink"];
?>
<object
type="video/avi"
data="<?php echo $dlink; ?>"
width="100%"
height="100%"
<param name="video" value="<?php echo $dlink; ?>">
</object>
the form:
<form name="decallink" action="/projects/decal.php" method="post">
<input type="text" name="decal" value="Decal Link" />
<input type="submit" value="Submit" />
</form>
DrDOS 11-05-2010, 09:15 PM Should be
$dlink = $_POST["decal"];
to get the submitted value.
elitis 11-05-2010, 09:22 PM Should be
$dlink = $_POST["decal"];
to get the submitted value.
? tried it and it didn't work. also [""] is the form name, which is decallink, not decal.
poyzn 11-05-2010, 09:47 PM try to output all submitted data
print_r($_REQUEST);
elitis 11-05-2010, 09:55 PM try to output all submitted data
print_r($_REQUEST);
sigh... getting a 404 error with that
DrDOS 11-05-2010, 10:02 PM That's probably the extra slash in front of this
action="/projects/decal.php"
but you'll still need to make the change I suggested. I tried it and it worked.
elitis 11-05-2010, 10:06 PM That's probably the extra slash in front of this
action="/projects/decal.php"
but you'll still need to make the change I suggested. I tried it and it worked.
could you post exactly what (and where) changes I need to make. Cuz I still can't get that to work.
DrDOS 11-05-2010, 10:28 PM These are the two files, not very much different from yours. PS: check your permissions!
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<script type="text/javascript">
//Alerts to errors.
window.onerror=function(msg, url, linenumber){var logerror='Error message: ' + msg + '. Url: ' + url + 'Line Number: ' + linenumber;alert(logerror);return false}
</script>
<title>HTML 4.01 Transitional!</title>
<style type="text/css">
<!--
body
{
margin: 0 auto;
width:900px;
font-family:serif
}
div
{
width:198px;height:58px;
background-color:#f8ffe0;
border:1px solid #ff0000;
padding:20px;
margin-top:10px
}
-->
</style>
<script type="text/javascript"></script>
</head>
<body>
<form name="myform1" action="index1.php" method="post">
<input type="text" name="decal" value="Decal Link" />
<input type="submit" value="Submit" />
</form>
<form name="myform1" action="index1.php" method="post">
<input type="text" name="decal" value="Decal Link" />
<input type="submit" value="Submit" />
</form>
<div></div>
</body>
</html>
**************************************
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<script type="text/javascript">
//Alerts to errors.
window.onerror=function(msg, url, linenumber){var logerror='Error message: ' + msg + '. Url: ' + url + 'Line Number: ' + linenumber;alert(logerror);return false}
</script>
<title>HTML 4.01 Transitional!</title>
<style type="text/css">
<!--
body
{
margin: 0 auto;
width:900px;
font-family:serif
}
div
{
width:198px;height:58px;
background-color:#f8ffe0;
border:1px solid #ff0000;
padding:20px;
margin-top:10px
}
-->
</style>
<script type="text/javascript"></script>
</head>
<body>
<?php
$dlink = $_POST["decal"];
?>
<div>
<object
type="video/avi"
data="<?php echo $dlink; ?>">
<param name="video" value="<?php echo $dlink; ?>">
</object>
</div>
</body>
</html>
poyzn 11-05-2010, 10:30 PM sigh... getting a 404 error with that
so you should check your script url '/projects/decal.php'
if you process data in the same file, try to remove action="/projects/decal.php" from form tag and run script
Keleth 11-05-2010, 10:40 PM ? tried it and it didn't work. also [""] is the form name, which is decallink, not decal.
Actually, $_POST['whatever'] references a passed variable... a form does not pass a variable, elements in the form do. In this case, 'decal', which is your input. The name of the form is irrelevant and not passed.
Also, NEVER use REQUEST. REQUEST guesses from two sets of variables... you should know if you're getting a POST or GET, never let the system decide for you.
Finally, can you post your updated code? We can't really guess what where you're going wrong.
elitis 11-05-2010, 10:45 PM Actually, $_POST['whatever'] references a passed variable... a form does not pass a variable, elements in the form do. In this case, 'decal', which is your input. The name of the form is irrelevant and not passed.
Also, NEVER use REQUEST. REQUEST guesses from two sets of variables... you should know if you're getting a POST or GET, never let the system decide for you.
Finally, can you post your updated code? We can't really guess what where you're going wrong.
after changing the coding around, I changed it back to the original. So, its the same as my first post right now.
EDIT: Changed $dlink = $_POST["decallink"] ; back to $dlink = $_POST["decal"] ; again and its giving me a 404 error. I'm guessing the script is thinking the link is on my site, which is why is 404'ing
The reaper 11-05-2010, 11:05 PM Wait,
so "/projects/decal.php" is not on your site? You would need to put the full address like so: http://sitename.com/projects/decal.php
Keleth 11-05-2010, 11:08 PM Also, changing what variable you pull should not give you a 404... it shouldn't be changing your URL at all...
Delete your object and echo out $dlink on its own, tell us what happens.
elitis 11-05-2010, 11:09 PM Wait,
so "/projects/decal.php" is not on your site? You would need to put the full address like so: http://sitename.com/projects/decal.php
no, /projects/decal.php IS on my site. I'm talking about the link I'm entering into /projects/dce.php (the form)
elitis 11-05-2010, 11:11 PM Also, changing what variable you pull should not give you a 404... it shouldn't be changing your URL at all...
Delete your object and echo out $dlink on its own, tell us what happens.
works perfectly. But with the object it gives me a 404.:confused:
DrDOS 11-05-2010, 11:29 PM works perfectly. But with the object it gives me a 404.:confused:There's an error in you markup for object. After height="100%" there should be a >.
Keleth 11-05-2010, 11:35 PM Then the object is failing... has nothing to do with your PHP anymore, if the url is coming out right, its working. Check the link you're connecting to, and make sure that's right.
elitis 11-05-2010, 11:35 PM There's an error in you markup for object. After height="100%" there should be a >.
added the > in but still gives 404 error... ugh starting to get a headache from this. gonna take a break...
EDIT: OMG... wow... fixed it. the problem was that I had to use http:// when I entered the link into my form... well that and the $_POST["decal"]; ... well thanks for all your help guys and sorry for wasting your time...
|