I am working on an ADMIN PAGE of my website. When I transferred hosting service, the admin page no longer work properly. The following error usually appears on almost every page. what does it mean? why most of my pages is not working properly?

The error message appears like this:

Warning: Cannot modify header information - headers already sent by (output started at /home/q/public_html/admin/cn.php:2

:mad:

    It means your script uses the [man]header/man command, but data was already echo'd to the browser, or else other data was sent because it was outside of <?php ?> tags.

    If you're using header(), you can't output anything before the function call.

      It used to work before, now it no longer works... what's wrong? the following error appears on submit:

      Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/quadrill/public_html/admin/ann_edit.php on line 22

      THE SOURCE CODE IS AS FOLLOWS:

      <?php
      $news_id = $_GET["news_id"];
      $row = $_GET["row"];
      
      include("globalfn.php");
      
      //Check if logged-in
      //$adminusername = $_COOKIE['adminusername'];
      //$adminpassword = $_COOKIE['adminpassword'];
      //if(trim(@$adminusername)=="" and trim(@$adminpassword)=="") {
      //	header("Location: login.php");
      //}
      
      if($REQUEST_METHOD == "POST") {
      	$currdate = date("Y-m-d");
      	$content = repl_enter($content);
      	$sql = "UPDATE tbl_news SET title = '$title', content = '$content', dt_created = '$currdate', status = $status, homepage = $homepage WHERE news_id = $news_id";
      	put_result($sql);
      	header("Location: news_list.php");
      }
      
      //Select News
      $sql = "SELECT * FROM tbl_news WHERE news_id = $news_id";
      $result = put_result($sql);
      $row = mysql_fetch_object($result);
      ?>
      <html>
      <head>
      <title>quadrillion admin</title>
      <link rel="stylesheet" type="text/css" href="admin.css">
      <script language="JavaScript" type="text/javascript">
      <!--
      function cmdSubmit() {
      	if (document.frm.title.value == "") {
      		alert("Please key in Title");
      		document.frm.title.focus();
      		document.frm.title.select();
      		return false;
      	}
      	if (document.frm.content.value == "") {
      		alert("Please key in Content");
      		document.frm.content.focus();
      		document.frm.content.select();
      		return false;
      	}
      	document.frm.submit();
      }
      //-->
      </script>
      </head>
      <body>
      <form action="news_edit.php" name="frm" method="post">
      <table border="0" cellspacing="0" cellpadding="0">
      	<? include("header_admin.php"); ?>
      	<tr><td colspan="2"><b>Edit News and Events</b></td></tr>
      	<tr><td colspan="2"><a href="home.php">[home]</a> | <a href="news_list.php">[back]</a></td></tr>
      	<tr><td>&nbsp;</td></tr>
      	<tr>
      		<td>Title: &nbsp; </td>
      		<td><input type="text" name="title" value="<? echo($row->title); ?>" size="60"></td>
      	</tr>
      	<tr>
      		<td valign="top">Content: &nbsp; </td>
      		<td><textarea name="content" rows="20" cols="50"><? echo(repl_br($row->content)); ?></textarea></td>
      	</tr>
      	<tr>
      		<td>Picture 1: &nbsp; </td>
      		<td><input type="text" name="picsmall" maxlength="100" value="<? echo($row->picsmall); ?>" readonly="readonly"> <a href="javascript:;" onClick="window.open('browsefile.php?frm=picsmall&saveto=news/small');">upload picture</a></td>
      	</tr>
      	<tr>
      		<td>Picture 2: &nbsp; </td>
      		<td><input type="text" name="piclarge" maxlength="100" value="<? echo($row->piclarge); ?>" readonly="readonly"> <a href="javascript:;" onClick="window.open('browsefile.php?frm=piclarge&saveto=news/large');">upload picture</a></td>
      	</tr>
      	<tr>
      		<td>Status: &nbsp; </td>
      		<td>
      			<input type="radio" name="status" value="1" <? if ($row->status == 1) { echo("checked"); } ?>> Online &nbsp; &nbsp; 
      			<input type="radio" name="status" value="2" <? if ($row->status == 2) { echo("checked"); } ?>> Offline
      		</td>
      	</tr>
      	<tr>
      		<td>Put to Homepage?: &nbsp; </td>
      		<td>
      			<input type="radio" name="homepage" value="1" <? if ($row->homepage == 1) { echo("checked"); } ?>> Yes &nbsp; &nbsp; 
      			<input type="radio" name="homepage" value="2" <? if ($row->homepage == 2) { echo("checked"); } ?>> No
      		</td>
      	</tr>
      	<tr>
      		<td>&nbsp;</td>
      		<td><br><input type="button" name="btnsave" value="Submit" onClick="cmdSubmit(); return false;"></td>
      	</tr>
      	<input type="hidden" name="news_id" value="<? echo($news_id) ?>">
      </table>
      </form>
      </body>
      </html>

        My guess is that your database details have changed when you moved, so now you need to re-configure that part. The previous error was a false alarm, in that the error was printed to screen, thus became "output" sent before the header.

          The "supplied argument . . ." message normally indicates an invalid query that MySQL was not able to process. Try to get more debug info by doing something like:

          //Select News
          $sql = "SELECT * FROM tbl_news WHERE news_id = $news_id";
          $result = put_result($sql);
          if(!$result)
          {
             die("Invalid query ($sql): " . mysql_error());
          }
          $row = mysql_fetch_object($result);
          

          PS: Please wrap your code samples in

           tags instead of [quote] tags - it makes it both easier to read and debug.

            Thanks a lot. It helped me debug.

            Problem is, upon clicking submit the fields just turned blank and the changes did not affect the database.

              laserlight wrote:

              My guess is that your database details have changed when you moved, so now you need to re-configure that part. The previous error was a false alarm, in that the error was printed to screen, thus became "output" sent before the header.

              I think I was able to transfer the database structure as well as data exactly as the original box. I am thinking isnt it a version issue? how could I know which syntax was no longer accepted?

                taurus5_6 wrote:

                I think I was able to transfer the database structure as well as data exactly as the original box. I am thinking isnt it a version issue? how could I know which syntax was no longer accepted?

                NodDog said it : echo MySQL errors !

                And here's MySQL bible : http://dev.mysql.com/doc/#manual

                  Did you manage to solve it? if it's show blank, it's usually it's your php code error. But if it's database error, it will throw error message.

                  ken

                  edit by admin: no commercial links on the forum, thanks

                    2 months later

                    Well, the header information has been resolved. I got spaces before the <?php and after the ?>

                    But the modification of my admin content still wont work.

                      You might want to post the current code, preferably a small and simple test. In fact, it may be better to start a new thread for this as the "Cannot modify header information?" topic no longer applies and appears resolved.

                        laserlight wrote:

                        In fact, it may be better to start a new thread for this

                        For reference purposes, there is already another thread in progress for this other issue; it can be found here.

                          Write a Reply...