Jump to content


Photo

Warning Errors


  • Please log in to reply
14 replies to this topic

#1 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 02 March 2006 - 08:47 PM

how can i turn off the warning errors, i get them for "headers allready set" but cant find whats wrong, and it works anyway. just need to make it go from it.
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#2 heckenschutze

heckenschutze
  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 02 March 2006 - 08:51 PM

"Headers already sent" means you have sent output to the browser before you have called a function like header() or session_start() ect. Eg you might have a space before your headers are being sent, yes it matters.

Don't ignore errors.

#3 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 02 March 2006 - 09:21 PM

does anyone else know how to turn error reporting off?
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#4 heckenschutze

heckenschutze
  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 03 March 2006 - 09:15 AM

[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--][!--sizeo:7--][span style=\"font-size:36pt;line-height:100%\"][!--/sizeo--][!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]Don't ignore errors.[!--fontc--][/span][!--/fontc--][!--sizec--][/span][!--/sizec--][!--colorc--][/span][!--/colorc--]

PHP was nice enough to tell you about the error, FIX IT. Don't turn it off.

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 03 March 2006 - 01:42 PM

If you are getting "headers already sent" errors, your script is NOT working correctly. Fixing whatever is causeing the problems will make the errors go away.

If you would post your code, we could help you solve the problem.

Ken

#6 dheon09

dheon09
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 08 March 2006 - 03:11 AM

HI,

I'm also having problems with "headers" and did all the possible solution to fix it but to no avail...here's the Warning: "Warning: Cannot add header information - headers already sent by (output started at /home/virtual/site90/fst/var/www/html/connect.php:17) in /home/virtual/site90/fst/var/www/html/connect.php on line 23"

here's my code:

<?php
$user = "user";
$pass = "pass";
$dbase = "localhost";
$uname = $_POST['user'];
$upass = $_POST['pass'];
$connection = mysql_connect("localhost",$user,$pass)
or die ("Error Connecting to DBase");
mysql_select_db($dbase,$connection)
or die ("Error Connecting to table");
$result = mysql_query("SELECT * FROM usertb",$connection)
or die ("Error querying DBase");
$i = 0;
while($result_ar = mysql_fetch_assoc($result)){
mysql_close();
?>
<?php
ob_start();
if ($upass == $result_ar['upass'] && $uname == $result_ar['uname'])
{
header("Location: clients/myoxy/index.html");
}
else
header("Location: index.html");
?>
<?php
$i+=1;
}
?>

can anyone help me fix this...actually this is working on our network..
Thanks!!!

#7 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 08 March 2006 - 03:20 AM

Here is my best guess: I don't know where line 17 is, but I assume it is the line that reads:

while($result_ar = mysql_fetch_assoc($result)){

the problem is you use this a few lines before it:

$result = mysql_query("SELECT * FROM usertb",$connection)
or die ("Error querying DBase");

That causes an error because it doesn't know what $result_ar is, so it can't send headers after that point...


#8 greycap

greycap
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 08 March 2006 - 03:26 AM

[!--quoteo(post=351111:date=Mar 2 2006, 03:21 PM:name=joecooper)--][div class=\'quotetop\']QUOTE(joecooper @ Mar 2 2006, 03:21 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
does anyone else know how to turn error reporting off?
[/quote]

Hecken is right. Thats definately one you should NOT be ignoring. At least not without detecting and logging it. While you don't want your clients to see error messages, you do not want to ignore them completely.

Use error_reporting() to supress warning and error messages.

#9 dheon09

dheon09
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 08 March 2006 - 03:50 AM

[!--quoteo(post=352722:date=Mar 8 2006, 11:20 AM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 8 2006, 11:20 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Here is my best guess: I don't know where line 17 is, but I assume it is the line that reads:

while($result_ar = mysql_fetch_assoc($result)){

the problem is you use this a few lines before it:

$result = mysql_query("SELECT * FROM usertb",$connection)
or die ("Error querying DBase");

That causes an error because it doesn't know what $result_ar is, so it can't send headers after that point...
[/quote]

can you tell me what should i do...i really need to work this out asap....as i've said before the script works on our local netwok

Thanks

#10 greycap

greycap
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 08 March 2006 - 04:00 AM

[!--quoteo(post=352735:date=Mar 7 2006, 09:50 PM:name=dheon09)--][div class=\'quotetop\']QUOTE(dheon09 @ Mar 7 2006, 09:50 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
can you tell me what should i do...i really need to work this out asap....as i've said before the script works on our local netwok

Thanks
[/quote]

That $result_ar is fine. It is being initialized and set to the results of the query. If the query was bad, the die() would have been executed and your script would have halted.

Can you show the entire code? And what is being output? There should be output after that warning.

#11 dheon09

dheon09
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 08 March 2006 - 04:17 AM

[!--quoteo(post=352738:date=Mar 8 2006, 12:00 PM:name=greycap)--][div class=\'quotetop\']QUOTE(greycap @ Mar 8 2006, 12:00 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
That $result_ar is fine. It is being initialized and set to the results of the query. If the query was bad, the die() would have been executed and your script would have halted.

Can you show the entire code? And what is being output? There should be output after that warning.
[/quote]


If you can see the entire code is posted above, also the Warning...after the warning there was no output...i tried setting a worng pass and user for the connection and it did show the die message so I think the query is good...do you need something else?

#12 greycap

greycap
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 08 March 2006 - 04:27 AM

[!--quoteo(post=352747:date=Mar 7 2006, 10:17 PM:name=dheon09)--][div class=\'quotetop\']QUOTE(dheon09 @ Mar 7 2006, 10:17 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
If you can see the entire code is posted above, also the Warning...after the warning there was no output...i tried setting a worng pass and user for the connection and it did show the die message so I think the query is good...do you need something else?
[/quote]


Ok, when I remove the clutter of the <? ?> tags, you get this:


$user = "user";
$pass = "pass";
$dbase = "localhost";
$uname = $_POST['user'];
$upass = $_POST['pass'];

$connection = mysql_connect("localhost",$user,$pass)
or die ("Error Connecting to DBase");

mysql_select_db($dbase,$connection)
or die ("Error Connecting to table");

$result = mysql_query("SELECT * FROM usertb",$connection)
or die ("Error querying DBase");



$i = 0;
while($result_ar = mysql_fetch_assoc($result))
{
   mysql_close();

   ob_start();

   if ($upass == $result_ar['upass'] && $uname == $result_ar['uname'])
   {
      header("Location: clients/myoxy/index.html");
   }
   else
      header("Location: index.html");

   $i+=1;
}


I don't really know why youre using an ob_start() (especially without a ob_flush()) and you are also closing your connection multiple times. I'm not sure of the effect on the ob_start() and multiple header() calls, but there is no way that the results you will get from that are what you are actually looking for.

Try something like this:
$found = false;
while ($result_ar = mysql_fetch_assoc($result))
{
   if (($upass == $result_ar['upass']) && ($uname == $result_ar['uname']))
   {
      $found = true;
      break;
   }
}

if ($found) { //valid login
   header("Location: clients/myoxy/index.html"); 
}
else { //invalid login
   header("Location: index.html");
}


#13 dheon09

dheon09
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 08 March 2006 - 05:39 AM

[!--quoteo(post=352753:date=Mar 8 2006, 12:27 PM:name=greycap)--][div class=\'quotetop\']QUOTE(greycap @ Mar 8 2006, 12:27 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Ok, when I remove the clutter of the <? ?> tags, you get this:


$user = "user";
$pass = "pass";
$dbase = "localhost";
$uname = $_POST['user'];
$upass = $_POST['pass'];

$connection = mysql_connect("localhost",$user,$pass)
or die ("Error Connecting to DBase");

mysql_select_db($dbase,$connection)
or die ("Error Connecting to table");

$result = mysql_query("SELECT * FROM usertb",$connection)
or die ("Error querying DBase");
$i = 0;
while($result_ar = mysql_fetch_assoc($result))
{
   mysql_close();

   ob_start();

   if ($upass == $result_ar['upass'] && $uname == $result_ar['uname'])
   {
      header("Location: clients/myoxy/index.html");
   }
   else
      header("Location: index.html");

   $i+=1;
}


I don't really know why youre using an ob_start() (especially without a ob_flush()) and you are also closing your connection multiple times. I'm not sure of the effect on the ob_start() and multiple header() calls, but there is no way that the results you will get from that are what you are actually looking for.

Try something like this:
$found = false;
while ($result_ar = mysql_fetch_assoc($result))
{
   if (($upass == $result_ar['upass']) && ($uname == $result_ar['uname']))
   {
      $found = true;
      break;
   }
}

if ($found) { //valid login
   header("Location: clients/myoxy/index.html"); 
}
else { //invalid login
   header("Location: index.html");
}
[/quote]

i tried your code and tested it locally but it keeps me directed to "index.html" even if i used the correct username/password....


#14 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 08 March 2006 - 10:12 PM

Grey, All

I stand corrected... I wrote that when I rolled out of bed this morning... Now that I look at it, I was SOOOOO wrong about the $result_ar thing...

Ack!

Looking at what the code actually does, there are far easier ways to accomplish what you are trying to do with that script...

I don't know if a rewrite is an option...

#15 dheon09

dheon09
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 09 March 2006 - 01:46 AM

[!--quoteo(post=353036:date=Mar 9 2006, 06:12 AM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 9 2006, 06:12 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Grey, All

I stand corrected... I wrote that when I rolled out of bed this morning... Now that I look at it, I was SOOOOO wrong about the $result_ar thing...

Ack!

Looking at what the code actually does, there are far easier ways to accomplish what you are trying to do with that script...

I don't know if a rewrite is an option...
[/quote]

Thanks anyway, i did make the code with only 1 <?php .....code......?> and it did work...Thanks for the reminder...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users