-
Posts
88 -
Joined
-
Last visited
Never
Everything posted by Ifa
-
echo '<a href="...">...</a>';
-
Displaying date DD-MM-YYYY but updating it as YYYY-MM-DD
Ifa replied to Mutley's topic in PHP Coding Help
I'm too slow for andy :( -
It's actually empty, not is_empty ;)
-
I think AndyBs solution is good, and you should use it, but this so that you can learn more: [code=php:0]switch($team_id){ case 1: echo '1st Team'; break; case 2: echo '2nd Team'; break; case 3: echo '3rd Team'; break; etc }[/code] Right way to use if would be: [code=php:0]if($team_id == 1){ echo '1st Team'; } elseif($team_id == 2){ echo '2st Team'; } elseif($team_id == 3){ echo '3rd Team'; }[/code] etc
-
How to Read a File, Edit and Replace that file with new Changes?
Ifa replied to robohelp's topic in PHP Coding Help
[CODE] <?PHP if(!$_POST["new_html"]){ ?> <form action="" method="post"> <textarea name="new_html"><?PHP echo str_replace("<", "<", file_get_contents('file.html')); ?></textarea> <input type="submit" value=" Save " /> </form> <?PHP } if($_POST["new_html"]){ $file = fopen('file.html', '+w') or die('Could not open file'); fwrite($file, $_POST["new_html"]); fclose($file); echo 'Changes saved'; } ?>[/code] -
I'm somewhat new to mysql, what do you mean by locked?
-
This is getting funny: $var = $var2 + 10; mysql_query("UPDATE table SET var = $var WHERE some=thing ") or die('Query failed: ' . mysql_error()); echo $var; the echo returns 16, but the update makes it 18... And though it seems extremely odd, IE just makes it right, and firefox doesn't. So much for it being a serverside language ;) $var2 = -1 * round(($var3 * $var4) / $var5, 0); Oh and with or without ' ' seems to make no diffrence...
-
mkdir($_POST["dirname"]);
-
[code]<?PHP session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Login</title> </head> <body> <?php if (isset($HTTP_POST_VARS['user_name'])&&(isset($HTTP_POST_VARS['pwd']))) { // getting data from the login form $user_name = $HTTP_POST_VARS['user_name']; $pwd = $HTTP_POST_VARS['pwd']; $connection = mysql_pconnect('localhost', 'root', 'justus') or die ('Unable to connect!'); // select database for use mysql_select_db('sme_cms') or die ('Unable to select database!'); $query = 'select * from auth ' ."where name='$user_name' " ." and pass=password('$pwd')"; $result = mysql_query($query); if (mysql_num_rows($result) >0 ) { // if they are in the database register the user id $HTTP_SESSION_VARS['valid_user'] = $user_name; } } if (isset($HTTP_SESSION_VARS['valid_user'])) { echo 'You are logged in as: '.$HTTP_SESSION_VARS['valid_user'].' <br />'; echo '<a href="logout.php">Log out</a><br />'; } else { if (isset($user_name)) { // if they've tried and failed to log in echo 'Could not log you in'; } else { // they have not tried to log in yet or have logged out echo 'You are not logged in.<br />'; } } ?> </body> </html>[/code]
-
Try adding the session_start(): to the top of the file, or if you are including the file, at the top of the file that is including it....
-
Oops, your right about the from, I use where, I just wrote the code as an example and made a tiny mistake :) No, the data isn't coming from a form, it's a number that is increased in a loop. But thanks, I'll try it without no single quotes. I can test it now though, as I'm at work, and all this comp has is IE... To be more spesific, the number is a calculation actually, $var = round($var2 / $var3, 0);
-
$var = 1; mysql_query("UPDATE table SET var=var+'$var' FROM somewhere"); For some reason only Internet Explorer makes the math correct, other browsers always return a bit higher number than they should (ie 1+1 = 5). I'm quite lost...
-
Ajax is not so much php as it is javascript.
-
easiest way would be to use [url=http://www.w3schools.com/tags/tag_acronym.asp]acronym[/url] It deosn't really follow the mouse (I think), but it's easy to use
-
You could just change the number at midnight (if time = midnight). It won't change it until the first person visits the site though, but then again, what's the need for a chage if there's no one to see it :)
-
Why would I help you on creating a spammail script? >:(
-
!empty is kinda the same as isset...
-
You have to make a similar check for all the fields as you have done for the submit: if(isset($_POST['Submit']))
-
If you don't wan't to echo it, $num = str_pad($num, 5, "0", STR_PAD_LEFT);
-
Don't use elseif in the second statement, use if :)
-
Why varchar(100) on the day, month and year?