Page 1 of 1

Script not echoing out anything..

Posted: Thu Jun 12, 2003 9:16 pm
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.

Posted: Fri Jun 13, 2003 1:44 am
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';";

Posted: Fri Jun 13, 2003 4:11 am
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();
...
?>
?

Posted: Fri Jun 13, 2003 7:38 am
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.

re

Posted: Fri Jun 13, 2003 8:09 am
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:

Posted: Fri Jun 13, 2003 8:20 am
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,

Posted: Fri Jun 13, 2003 8:33 am
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.

Posted: Fri Jun 13, 2003 8:48 am
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,

Posted: Fri Jun 13, 2003 11:16 am
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?

Posted: Fri Jun 13, 2003 3:57 pm
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.

Posted: Fri Jun 13, 2003 4:06 pm
by cactus
Well spotted :)

...now where's my glasses.

Regards,