Page 2 of 2
Posted: Mon Dec 09, 2002 6:01 pm
by infolock
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..
Posted: Mon Dec 09, 2002 6:37 pm
by kkurkowski
I have a statment to finish off the { it is at the bottom of the all of the code. it is...
Posted: Tue Dec 10, 2002 2:11 am
by volka
- now you've
while ($data == mysql_fetch_array ($result))
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.
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
}
?>
Posted: Tue Dec 10, 2002 1:03 pm
by kkurkowski
I got it working. I forgot I had that extra = sign in the code when you guys told me to add it on there. I got rid of it and now it works. Thanks for lal the help!!

Posted: Tue Dec 10, 2002 1:18 pm
by kkurkowski
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.
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;
}
?>
Posted: Tue Dec 10, 2002 1:36 pm
by volka
$cookie_expire_auth = time()+86400;
makes the cookie valid for one day. But
$cookie_expire_auth=0; should delete the cookie when the user closes the current browser.
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]
Posted: Tue Dec 10, 2002 1:47 pm
by kkurkowski
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...
Warning: Server Error in mail_form.php on line 23
this is "mail($to, $subject, $msg, $mailheaders);"
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);
?>
Posted: Tue Dec 10, 2002 1:53 pm
by volka
- some questions
- which version of php?
- which OS?
- what are the configuration-settings in [mail function] in your php.ini?
- Is
$mailheaders = "From: $sender_email <> \n";
valid for your mail-server and/or ISP?
Posted: Tue Dec 10, 2002 2:03 pm
by kkurkowski
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.
Posted: Tue Dec 10, 2002 2:24 pm
by volka
but the questions remain:
what are the configuration-settings in [mail function] in your php.ini? (esp. sendmail_from=...) (do not post it, just think about the validity of the configuration)
and is an empty email-address (< >) accepted by your mail-server
Posted: Tue Dec 10, 2002 9:32 pm
by kkurkowski
[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.
Posted: Wed Dec 11, 2002 1:14 am
by volka
then I'm clueless

The last two things I suggest are:
Code: Select all
$mailheaders = "From: $sender_email <$sender_email>\n";
$mailheaders .= "Reply-To: $sender_email\n";
and taking a look into the smtp-server's error protocol.
Posted: Wed Dec 11, 2002 1:02 pm
by kkurkowski
Still gives you the same error. I will keep trying to see what is wrong with it. Probably something stupid.
Posted: Wed Dec 11, 2002 1:51 pm
by puckeye
$mailheaders = "From: $sender_email <$sender_email>\n";
Should'nt
From: be
FROM:?
It think I had issues with the case sensitiveness of this part...
Posted: Wed Dec 11, 2002 9:33 pm
by kkurkowski
I figured out what it was. On the server they did not set the username and password for the smtp server on it. So once it is set then it should work. Thanks for the help guys.