webwiese
-
Posts
9 -
Joined
-
Last visited
Never
Posts posted by webwiese
-
-
[!--quoteo(post=356884:date=Mar 21 2006, 08:44 AM:name=firedrop)--][div class=\'quotetop\']QUOTE(firedrop @ Mar 21 2006, 08:44 AM) [snapback]356884[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I have another question. when I got for example in a form a submit button I usually use the action in the form and thats in the HTML to allow it to go for the page that I would like.
I am wondering what if I have two buttons that they do two different actions. How I can handle this.
[/quote]
Hi,
don't use any action or use action = "<?echo $PHP_SELF?>" to call the same script. Then use an if ... elseif ... else - construct like
[code]
<?php
# Submit - Button #1
if (isset($_POST[submit_button_1]) {
# action for submit - button #1
} // if
# Submit - Button #2
elseif (isset($_POST[submit_button_2]) {
# action for submit - button #2
} // if
# Standard - form
else {
?>
<form method = "POST">
.......
</form>
<?
} // else
?>
[/code]
-
Hi,
nl2br($yourtext) transaltes linebreaks into <br>.
-
[!--quoteo(post=352903:date=Mar 8 2006, 06:18 PM:name=pixeltrace)--][div class=\'quotetop\']QUOTE(pixeltrace @ Mar 8 2006, 06:18 PM) [snapback]352903[/snapback][/div][div class=\'quotemain\'][!--quotec--]
thanks man! it work.
another question, i need a script that will say that if there are no data on a specific date,
lets say today, mar 9, 2006 there will be a note saying that
"no new updates"
may i know what the script is? because i honestly dont have an idea where to start.
hoping for your help on this.
thanks again!
[/quote]
[code]
# First step: Receiving your 5 last data
$query = "SELECT * FROM ... WHERE ... ORDER BY date DESC LIMIT 5";
$result = mysql_query($query, $databaseconnection);
while (@$row = mysql_fetch_array($result)) {
# Do something with your received data
} // while
# Second step: What is the highest date in db?
$query = "SELECT MAX(date) AS max FROM ... ";
$result = mysql_query($query, $databaseconnection);
$row = mysql_fetch_array($result);
# date - format in db is datetime?
if ($row[max] < date("Y-m-d H:i:s")) {
echo "no new updates";
} // if
[/code]
Code is written without deeper thinking and testing ... sorry, no time ! ;-)
webwiese
-
[!--quoteo(post=354879:date=Mar 14 2006, 03:02 PM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ Mar 14 2006, 03:02 PM) [snapback]354879[/snapback][/div][div class=\'quotemain\'][!--quotec--]
yeah both worked .....
but now further errors relating to the session at the beginning....
Warning: session_start(): open(/tmp\sess_99a3b92d86e67afe762f29c6b156dfe4, O_RDWR) failed: No such file or directory (2) in C:\Program Files\Apache Group\Apache2\htdocs\dvdreviewer\LoginTest.php on line 1
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\dvdreviewer\LoginTest.php:1) in C:\Program Files\Apache Group\Apache2\htdocs\dvdreviewer\LoginTest.php on line 1
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\Program Files\Apache Group\Apache2\htdocs\dvdreviewer\LoginTest.php:1) in C:\Program Files\Apache Group\Apache2\htdocs\dvdreviewer\LoginTest.php on line 1
then it displays it correctly ... saying 'Please Sign in'
then further errors....
Warning: Unknown(): open(/tmp\sess_99a3b92d86e67afe762f29c6b156dfe4, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
[/quote]
Hi from Germany,
the first error message seems to be php.ini - config problem. you're using windows, the standard php.ini (\tmp) for session dir is no usable under windows. you have do create a directory and add this to your php.ini like
session.save_path = C:\Program Files\Apache Group\Apache2\sessions
The second and third error message due to the first error message, this was an output and session_start() must be set before any screen output.
Hope it will work,
webwiese
-
oh, I'm sorry, I've read your article too fast ....
-
[!--quoteo(post=354455:date=Mar 13 2006, 12:04 PM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ Mar 13 2006, 12:04 PM) [snapback]354455[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I want to remember the users username and password
i've been told to look into sessions, from what i've learned would I be right in simply doing the following...
$_SESSION['loginname'] = $_POST['loginname'];
$_SESSION['password'] = $_POST['password'];
and then just
session_start();
at the beginning of each page where it is needed?
Then call $_SESSION['loginname'] when I need to access the database?
then when they log out simply....
$_SESSION['loginname'] = '';
$_SESSION['password'] = '';
i'm NEW!!!!!!!! SORRY!!!!
Thanks
D
[/quote]
Hi,
session_start() must be set before any output of your script. For identifying a logged user just ask
session_start();
if (isset($_SESSION['loginname']) {
..... code .....
} // if
For logout I suggest a unset($_SESSION).
webwiese
-
Hi,
just use the SQL - DATETIME field.
-
[!--quoteo(post=352514:date=Mar 7 2006, 03:11 PM:name=pixeltrace)--][div class=\'quotetop\']QUOTE(pixeltrace @ Mar 7 2006, 03:11 PM) [snapback]352514[/snapback][/div][div class=\'quotemain\'][!--quotec--]
guys,
i need help, i dont know how to do this.
how will you set your sql query in such a way that i will just show the
last 5 data by date.
lets say, today is march 7, it will just show the 5 data from march 7 onwards
and once the date has expired or when there is no more data to show it
will print a comment saying "no current events"
need help.
thanks!
[/quote]
Hi,
$query = "SELECT ...... FROM ..... WHERE .... ORDER BY date LIMIT 5"
Greets
webwiese
Get index of array?
in PHP Coding Help
Posted
hi,
use array_search, not in_array. array_search gives you the key (index) of the search pattern if it exists.
hope this will help.