Script not echoing out anything..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Trip1
Forum Newbie
Posts: 23
Joined: Sat Jan 25, 2003 7:36 pm

Script not echoing out anything..

Post by Trip1 »

alright, the source of my script is :

Code: Select all

<?php
include "./common.inc";
$link_id = db_connect();
if(!$link_id) die(sql_error());

if(!$topmidsubject) die("Please fill out something for the top mid subject");
if(!$topmidtext) die("Please fill out something for the top-mid text");
if(!$midsubject) die("Please fill out something for the mid subject");
if(!$midtext) die("Please fill out something for the mid text");
if(!$toplefttext) die("Please fill out something for the top left text");




	//toplefttext
	$query = "SELECT * FROM topleft_$tablename";
	$result = mysql_query($query);
	if(!mysql_num_rows($result)) {
		$query = "INSERT INTO topleft_$tablename SET text = '$toplefttext';";
		mysql_query($query);
		
	}
	
	if(mysql_num_rows($result)) {
	$query = "UPDATE topleft_$tablename SET text = '$toplefttext' WHERE text = '$toplefttext_old';";
        mysql_query($query);
        
}

        //topmidsubject
        $query = "SELECT subject FROM topmid_$tablename";
	$result = mysql_query($query);
	if(!mysql_num_rows($result)) {
		$query = "INSERT INTO topmid_$tablename SET subject = '$topmidsubject';";
		mysql_query($query);
		
	}
	
        if(mysql_num_rows($result)) {
        $query = "UPDATE topmid_$tablename SET subject = '$topmidsubject' WHERE subject = '$topmidsubject_old';";
        mysql_query($query);
}
        
        //topmidtext
        
        $query = "SELECT text FROM topmid_$tablename";
	$result = mysql_query($query);
	if(!mysql_num_rows($result)) {
		$query = "INSERT INTO topmid_$tablename SET text = '$topmidtext';";
		mysql_query($query);
		
	}
        
        if(mysql_num_rows($result)) {
        $query = "UPDATE topmid_$tablename SET text = '$topmidtext' WHERE text = '$topmidtext_old';";
        mysql_query($query);
}
        
        //midsubject
        $query = "SELECT subject FROM midsubject_$tablename";
	$result = mysql_query($query);
	if(!mysql_num_rows($result)) {
		$query = "INSERT INTO midsubject_$tablename SET subject = '$topmidsubject';";
		mysql_query($query);
		
	}
        
        if(mysql_num_rows($result)) {
        $query = "UPDATE midsubject_$tablename SET subject = '$midsubject' WHERE subject = '$midsubject_old';";
        mysql_query($query);
        
}
        //midtext
        
        $query = "SELECT text FROM midtext_$tablename";
	$result = mysql_query($query);
	if(!mysql_num_rows($result)) {
		$query = "INSERT INTO midtext_$tablename SET text = '$midtext';";
		mysql_query($query);
		
	}
        
        if(mysql_num_rows($result)) {
        $query = "UPDATE midtext_$tablename SET text = '$midtext' WHERE text = '$midtext_old';";
        mysql_query($query);
}

	 //midpic-home
        
        $query = "SELECT homeurl FROM midpic_$tablename";
	$result = mysql_query($query);
	if(!mysql_num_rows($result)) {
		$query = "INSERT INTO midpic_$tablename SET homeurl = 'images/$homejersey';";
		mysql_query($query);
		echo $query;
		
	}
        
        if(mysql_num_rows($result)) {
        $query = "UPDATE midpic_$tablename SET homeurl = 'images/$homejersey' WHERE text = 'images/$homejersey_old';";
        mysql_query($query);
        echo $query;
}
        
	 //midpic-away
        
        $query = "SELECT awayurl FROM midpic_$tablename";
	$result = mysql_query($query);
	if(!mysql_num_rows($result)) {
		$query = "INSERT INTO midpic_$tablename SET awayurl = 'images/$awayjersey';";
		mysql_query($query);
		echo $query;
		
		
	}
        
        if(mysql_num_rows($result)) {
        $query = "UPDATE midpic_$tablename SET awayurl = 'images/$awayjersey' WHERE text = 'images/$awayjersey_old';";
        mysql_query($query);
        echo $query;
        
        
}

echo "Successfully edited page";

        
        ?>
Anyways, what it's basically doing is running almost perfectly, but with two glitches:
One: the echo's dont do anything, not even the successfully edited page one.

Two: the homeurl and awayurl section of the site is not working correctly, nothing gets added into the database.
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

You have ; in your queries. If you are running a query from a script the semicolon is forbiden.

Like:

Code: Select all

$query = "UPDATE midpic_$tablename SET awayurl = 'images/$awayjersey' WHERE text = 'images/$awayjersey_old'";
not:

Code: Select all

$query = "UPDATE midpic_$tablename SET awayurl = 'images/$awayjersey' WHERE text = 'images/$awayjersey_old';";
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

And maybe something else is wrong.
What happens if you start your script with

Code: Select all

<?php
error_reporting(E_ALL); // no errors/warnings/notices are suppressed
ini_set('display_errors', TRUE); // add error messages to output stream - for debug purposes only
ini_set('mysql.trace_mode', TRUE); // add mysql-errors to output stream - for debug purposes only
include "./common.inc";
$link_id = db_connect();
...
?>
?
Tubbietoeter
Forum Contributor
Posts: 149
Joined: Fri Mar 14, 2003 2:41 am
Location: Germany

Post by Tubbietoeter »

do you have html tags at the start and the end? if not, some browsers will not display anything. note, that php will write all of the echos in one line, since the <br> are missing.
Trip1
Forum Newbie
Posts: 23
Joined: Sat Jan 25, 2003 7:36 pm

re

Post by Trip1 »

i put html tags at the beginning and end, still a blank page.

I put those lines of code about the error checking in, and still a blank page.

and i removed the semicolons and guess what..still a blank page :evil:
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

Is this on a shared host ? Do you have your errors written to a error log (file) ?

Many shared hosts disable the use of ini_set() so that they control the config.

I think one of your queries is causing an issue but you have display_errors set to off (and possibly can't be changed by ini_set) and the errors are being written to a log file.

Regards,
Trip1
Forum Newbie
Posts: 23
Joined: Sat Jan 25, 2003 7:36 pm

Post by Trip1 »

err well its never happened before.. what i mean is, ive always gotten the errors wether its a parse error or something else.
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

Try creating a basic PHP page that echo's something out:

Code: Select all

<?
     echo "Hello World";
?>
If that works, try making the page error and see what happens, back to basics on this on :)

Regards,
Trip1
Forum Newbie
Posts: 23
Joined: Sat Jan 25, 2003 7:36 pm

Post by Trip1 »

yeah that works fine, and if i make it echo "hello world; it returns a parse error like it should, so the problem is not with the server, its with the script... any ideas?
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

Maybe the problem is in the common.inc you're including into your page.

But if I were you, I would start to test this code first. Try to comment these queries and mysql functions and look if it echos anything. If yes, repeat the same action, only commenting one part less, to see where the error is. Get read of those ifs and see what will happen.
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

Well spotted :)

...now where's my glasses.

Regards,
Post Reply