Click to See Complete Forum and Search --> : Echo is not echoing
Kulag
03-15-2006, 07:03 PM
Apparently, the echo command sometimes won't echo, because at times, data that I've seen echo work properly in the script, then under some circumstances, when it should work, it won't work. Sorry if that's confusing, I may need to rephrase.
EDIT: Oops, wrong board. Can one of you mods move this to the PHP section please.
Lerura
03-15-2006, 07:09 PM
echo is not a javascript command.
PHP (and maybe others) have this equivalent to document.write
Kulag
03-16-2006, 05:15 AM
I know it's not a javascript command, I posted in the wrong board.
jogol
03-16-2006, 05:27 AM
post your code pls
pcthug
03-16-2006, 05:27 AM
Post code
LiLcRaZyFuZzY
03-16-2006, 07:27 AM
post code! :p (hey, everyone is saying this!)
Kulag
03-17-2006, 06:25 AM
if(isset($_GET['edit']))
{
$page=mysql_fetch_array(mysql_query("select * from sermons_pages where id='{$_GET['edit']}'"));
echo "<table align='center'>";
echo "<form onsubmit=\"adminGet('pages.php?update={$page['id']}&id='+this.id.value+'&page='+this.page.value);return false;\">";
echo "<tr><td>ID:</td><td><input type='text' name='id' value='{$page['id']}'></td></tr>";
echo "<tr><td colspan='2' style='width:30%'><textarea name='page' style='width:100%' rows='15'>{$page['page']}</textarea></td></tr>";
echo "<tr><td colspan='2' align='right'><input type='submit' value='Update'></td></tr></form></table>";
}
else
{
Oddly enough, it won't echo anything, and I don't get any errors either. Look at the following script:
if(isset($_GET['edit']))
{
echo "<form onsubmit=\"adminGet('links.php?update=&name='+this.name.value+'&link='+this.link.value+'&old_name={$_GET['edit']}');return false;\">";
$link=mysql_fetch_array(mysql_query("select * from sermons_links where name='{$_GET['edit']}'"));
echo "<table align='center'><tr><td>Name:</td><td><input type='text' name='name' value='{$link['name']}'></td></tr>";
echo "<tr><td>Link:</td><td><input type='text' name='link' value='{$link['link']}' style='width:400px;'></td></tr>";
echo "<tr><td colspan='2'><input type='submit' value='Update'></td></tr></table></form>";
}
else
{
The first script is neary a copy/paste from the second, yet the second works, and not the first.
Basically, if the edit index is set in the $_GET array, it shows the editing page, if not, it shows the default page.
LiLcRaZyFuZzY
03-17-2006, 06:57 AM
does the query return something?
try printing the fetched array
Kulag
03-17-2006, 08:59 AM
In each case, the mysql query should return 1 row. In fact, I tested the first block of code a few times and it worked when the page was loaded freestanding. Normally,it gets loaded by an ajax request indentical to the one used for the second block of code. I've tried print without success. Even if no sql rows where returned, it should at least display an error and a page with empty fields...
NogDog
03-17-2006, 01:17 PM
I would debug with a print_r($_GET) before the if statement to make sure that $_GET['edit'] is actually set.
Kulag
03-17-2006, 06:34 PM
I checked, and yes, $_GET['edit'] is set.
Consider the following code:
if(isset($_GET['del']))
{
$dlod=mysql_fetch_array(mysql_query("select link from sermons_db where id='{$_GET['del']}'"));
@unlink("../data/".$dlod['link']);
mysql_query("delete from sermons_db where id='{$_GET['del']}'");
echo "<script>adminGet('sermons.php');</script>";
}
This is part of another script, but, once again, all the code executes, except the echo.
NogDog
03-17-2006, 07:23 PM
The obvious common denominator between the two examples that don't work is that they start with a database query. Could the query be failing somehow and causing the problem? (Seems like you'd still get some output, but I'm grasping at straws here.) Maybe do something like this to help debug:
if(isset($_GET['del']))
{
echo "<p>DEBUG: we made it inside the isset(\$_GET['del'])</p>\n";
$dlod=mysql_fetch_array(mysql_query("select link from sermons_db where id='{$_GET['del']}'"));
echo "<pre>DEBUG: result of query:\n";print_r($dlod);echo "</pre>\n";
@unlink("../data/".$dlod['link']);
mysql_query("delete from sermons_db where id='{$_GET['del']}'");
echo "<script>adminGet('sermons.php');</script>";
}
else {
echo "<p>DEBUG: \$_GET['del'] is not set</p>\n";
}
Kulag
03-18-2006, 07:41 AM
Tried that, everything was fine, but the <script>adminGet('sermons.php');</script> still didn't echo/execute.
NogDog
03-18-2006, 12:30 PM
I presume you're doing a "view source" to verify that the script text has not been output to the browser, and not assuming that the javascript works?
Kulag
03-20-2006, 05:06 AM
Since the page is a "sub page", It's loaded into a span element in another page via AJAX, so I can't view the source for the sub page.
NogDog
03-20-2006, 10:08 AM
So, for all we know the PHP may be working fine and the JavaScript (either that driving the AJAX request or that which is output by the PHP) may be the problem?
Kulag
03-20-2006, 11:28 AM
That's what I've been thinking, but I don't know how... The adminGet() function handles virtually every page load in the admin section, all of which work fine.