Error problems in PHP
Moderator: General Moderators
In your View_news.php code, you have
while ($data == mysql_fetch_array ($result))
{
?>
What is this "while" statement actually doing? the { indicated you are wanting to start an operation, but nothing follows that you are wanting it to perform if the action is true. Was this intentional? If so, why?
PS, the while ($data == mysql_fetch_array ($result)) should be while ($data = mysql_fetch_array ($result)) as volka stated..
while ($data == mysql_fetch_array ($result))
{
?>
What is this "while" statement actually doing? the { indicated you are wanting to start an operation, but nothing follows that you are wanting it to perform if the action is true. Was this intentional? If so, why?
PS, the while ($data == mysql_fetch_array ($result)) should be while ($data = mysql_fetch_array ($result)) as volka stated..
-
kkurkowski
- Forum Commoner
- Posts: 53
- Joined: Mon Dec 09, 2002 4:44 pm
- Location: Michigan
I have a statment to finish off the { it is at the bottom of the all of the code. it is...
Code: Select all
<?
}
?>- now you've
in your code, too. In this case the loop-conditions checks wether the content of $data is equal to the result of mysql_fetch_array before entring the loop-body, which is highly improbable. So your loop isn't executed a single time.while ($data == mysql_fetch_array ($result))
You will need something like
Code: Select all
<?php
while ($data = mysql_fetch_array ($result))
{ ?>
<fieldset>
<legend>
<h3><?php echo $data['headline']; ?></h3>
by<?php echo $data['user']; ?>
</legend>
<?php echo $data['news']; ?>
</fieldset>
<?php
}
?>-
kkurkowski
- Forum Commoner
- Posts: 53
- Joined: Mon Dec 09, 2002 4:44 pm
- Location: Michigan
-
kkurkowski
- Forum Commoner
- Posts: 53
- Joined: Mon Dec 09, 2002 4:44 pm
- Location: Michigan
Ok, this same script, I have a logout link and that works, but when they exit out of the browser I want it to log them out because when I exit out here it doesn't log me out. It just keeps me logged in when I go back to the site.
This is what I have.
This is what I have.
Code: Select all
<?
if ((!$username) || (!$password)) {
header("Location: invalid_login.php");
exit;
}
$db_name = "table_name";
$table_name = "news_users";
$connection = @mysql_connect("localhost", "username", "password")
or die("Couldn't connect.");
$db = mysql_select_db($db_name, $connection)
or die("Couldn't select database.");
$sql = "SELECT * FROM $table_name
WHERE username = "$username" AND password = password("$password")
";
$result = mysql_query($sql)
or die ("Can't execute query.");
$num = mysql_numrows($result);
if ($num != 0) {
$cookie_name_auth = "status";
$cookie_value_auth = "ok";
$cookie_expire_auth = time()+86400;
$cookie_domain_auth = ".bve.32k.org";
setcookie($cookie_name_auth, $cookie_value_auth, $cookie_expire_auth, "/" , $cookie_domain_auth, 0);
$cookie_name_user = "user";
$cookie_value_user = "$username";
$cookie_expire_user = time()+86400;
$cookie_domain_user = ".bve.32k.org";
setcookie($cookie_name_user, $cookie_value_user, $cookie_expire_user, "/" , $cookie_domain_user, 0);
header("Location: news.php");
} else {
header("Location: invalid_login.php");
exit;
}
?>makes the cookie valid for one day. But $cookie_expire_auth=0; should delete the cookie when the user closes the current browser.$cookie_expire_auth = time()+86400;
http://wp.netscape.com/newsref/std/cook ... pires=DATE
...
expires is an optional attribute. If not specified, the cookie will expire when the user's session ends.[/quote]
-
kkurkowski
- Forum Commoner
- Posts: 53
- Joined: Mon Dec 09, 2002 4:44 pm
- Location: Michigan
Thanks for all the help. That cookie thing works. I know I am being a pain in the a**. Just trying to fix the errrors that I have been trying to fix on my site. This script is the contact script, and it gives me this error...
this is "mail($to, $subject, $msg, $mailheaders);"Warning: Server Error in mail_form.php on line 23
Code: Select all
<?php
if (($sender_name == "") && ($sender_email == "") && ($message == "")) {
header("Location: mail_form.php");
exit;
}
$msg = "Basic.Visual.Experiments. Mailform\n";
$msg .= "Sender's Name: $sender_name\n";
$msg .= "Sender's E-Mail: $sender_email\n";
$msg .= "Message: $message\n\n";
$to = "kkurkowski@wideopenwest.com";
$subject = "Basic.Visual.Experiments. Mailform";
$mailheaders = "From: $sender_email <> \n";
$mailheaders .= "Reply-To: $sender_email\n\n";
mail($to, $subject, $msg, $mailheaders);
?>-
kkurkowski
- Forum Commoner
- Posts: 53
- Joined: Mon Dec 09, 2002 4:44 pm
- Location: Michigan
The server is
Windows.NET
and the PHP I think is
Version 4.1
the contact feedback forms do work on it because I have gotten other scripts working on it, but I am trying to get this one working it. It was working at one time but then I think thye updated the PHP on it and it started erroring out on me.
Windows.NET
and the PHP I think is
Version 4.1
the contact feedback forms do work on it because I have gotten other scripts working on it, but I am trying to get this one working it. It was working at one time but then I think thye updated the PHP on it and it started erroring out on me.
-
kkurkowski
- Forum Commoner
- Posts: 53
- Joined: Mon Dec 09, 2002 4:44 pm
- Location: Michigan
[mail function]
SMTP= localhost ; for Win32 only
sendmail_from= default_email_of_server@whom.com ; for Win32 only
upload_tmp_dir = C:\PHP\uploadtemp ; temporary directory for HTTP uploaded files (will use system default if not specified)
That isn't the real email. There is a email in there though and it is a valid email for the server.
SMTP= localhost ; for Win32 only
sendmail_from= default_email_of_server@whom.com ; for Win32 only
upload_tmp_dir = C:\PHP\uploadtemp ; temporary directory for HTTP uploaded files (will use system default if not specified)
That isn't the real email. There is a email in there though and it is a valid email for the server.
then I'm clueless 
The last two things I suggest are:and taking a look into the smtp-server's error protocol.
The last two things I suggest are:
Code: Select all
$mailheaders = "From: $sender_email <$sender_email>\n";
$mailheaders .= "Reply-To: $sender_email\n";-
kkurkowski
- Forum Commoner
- Posts: 53
- Joined: Mon Dec 09, 2002 4:44 pm
- Location: Michigan
-
kkurkowski
- Forum Commoner
- Posts: 53
- Joined: Mon Dec 09, 2002 4:44 pm
- Location: Michigan