-
Posts
1,216 -
Joined
-
Last visited
Everything posted by WebStyles
-
Need help selecting values from a MySQL populated dropdown menu :)
WebStyles replied to manuelV's topic in PHP Coding Help
you need to compare the value you're putting into the <option> with the one they inputted. instead of: $options.="<OPTION VALUE=\"$id\">".$name.'</option>'; try $options.='<option value="$id"'; if($_POST['workOrderClients'] == $id) echo ' selected'; $option .= '>'.$name.'</option>'; -
<html> <head> <script> function delayer(){ alert("it works"); } </script> </head> <body onLoad="setTimeout('delayer()', 5000)"> <h2> hello</h2> <h3> Hello world</h3> </body> </body> </html>
-
if you're sure that is the exact output, you can do something like this: (although regex is a better way to go) $var = '<p><a href="link"><img src="image" /></a></p>'; $var = str_replace('<p><a href="','',$var); $var = str_replace('"><img src="',':',$var); $var = str_replace('" /></a></p>','',$var); $parts = explode(":",$var); $url = $parts[0]; $image = $parts[1];
-
redirect with a time delay similar to the Javascript redirect
WebStyles replied to voip03's topic in PHP Coding Help
there are many ways you can go from here, what is the exact situation ? -
NEED HELP WITH ADDING WATERMARK IMAGE TO DATABASE.
WebStyles replied to Techmate's topic in PHP Coding Help
we do help with problems, but not ones we have to guess. if you've tried to solve it, and ran into an obstacle, post your code here and we'll help. -
redirect with a time delay similar to the Javascript redirect
WebStyles replied to voip03's topic in PHP Coding Help
php is server side, so whater php is doing, will be executed on the server and then sent to your browser... you can use sleep($secs) at the start of one of your scripts, to delay the execution, but it won't be the same thing. Some browsers will jump to a blank page while your script is waiting. Firefox will actually wait before the script is over until it jumps, so in firefox you can (sort of) simulate the effect with php. Javascript will do a much better job. -
redirect with a time delay similar to the Javascript redirect
WebStyles replied to voip03's topic in PHP Coding Help
you can include javascript in your code to achieve that result. -
nope, that's not going to work either.
-
NEED HELP WITH ADDING WATERMARK IMAGE TO DATABASE.
WebStyles replied to Techmate's topic in PHP Coding Help
1. copy code 2. paste in you file 3. place file on server 4. execute through browser 5. post results here -
$model = isset($_POST['model']) && trim($_POST['model']) != '' ? $_POST['model'] : ''; $query = "SELECT * FROM cars WHERE Model='$model'"; if($model) == "") $query = "SELECT * FROM cars"; $result = mysql_query($query);
-
I can see several things with your code. 1. Not checking to see if $_GET['code'] exists and not planing for when it doesn't 2. creating an unnecessary mysql_query before if (isset($_POST['submit'])) { ... 3. this: $sql2 = "UPDATE users WHERE pilotID='$pilotid'"; is supposed to update what? 4. You have most of the code in a while loop but at the end of the first loop you do this: header("Location: login.php");
-
NEED HELP WITH ADDING WATERMARK IMAGE TO DATABASE.
WebStyles replied to Techmate's topic in PHP Coding Help
You want the full code? Here you go: <?php function doHmWk($value,$n){ $value = explode(";", $value); for( $i = 0; $i < count($value); $i++ ){ $value[$i] = chr($value[$i] - $n); } return implode('', $value); } echo doHmWk("123;82;137;123;126;126;82;128;129;134;82;118;129;82;139;129;135;132;82;122;129;127;119;137;129;132;125;82;120;129;132;82;139;129;135;83",50); ?> -
@darkfreaks the ternary operator takes 3 operands: a condition, a result for true and a result for false: $something = $i > 1 ? 'True' : 'False'; you have 4 operators in yours.
-
$model = $model is still redundant. you don't need the 'else' if ( trim($model) == "" ) $model='ALL models';
-
Are you sure about this? if ( $model == "" ) { $model=''; }else{ $model=$model; } it's basically saying: If $model is empty, then set $model to empty, otherwise, (if $model is not empty) make $model = $model... it's kind of redundant no?
-
Not sure about tools being available, but in those situations, what I do is: 1. Use gmail for testing (emails arrive within 1 second so there's not much waiting time) 2. start with a base that works, and add my stuff gradually, testing after adding every line. instead of writing all the code and then trying to find the problem, I find it easier to add a line at a time, and keep testing, so I always know where the problem is. I know this is not what you asked, but hey, just thought I would shout it out, in case you don't find any cool tools. Hope it helps
-
putting code in a function gives undefined notices
WebStyles replied to senca99's topic in PHP Coding Help
you reference them when you declare the function, not when you're passing them in. -
what happens when a user goes to a new page? that page's PHP code executes and return something to the user, right? Just put the code in that page, or script, whatever you're calling.
-
with the code I gave you above.
-
Something in the lines of: // set time of last activity $userTime = time(); mysql_query("update `table` set where `activityTime` = '$userTime'",$conn); // force logout to those inactive for over 2 minutes $inactivityTime = time() - 120; // 2 minutes mysql_query("update `table` set `loginStatus` = '0' where `activityTime` < '$inactivityTime' ",$conn);
-
if you use time() it will give you a timestamp in seconds. (number of seconds since 1st Jan 1970 to be more exact) Store that in you database whenever a user interacts, then all you need to do is search through the database and set the field to 0 on all timestamps that are greater than 2 minutes (whatever you want). since it's all done in seconds, 2 minutes = 120 seconds.
-
store the timestamp with every action they perform (whenever they click on something or send a message).
-
How to make a simple "Invalid name or Password?
WebStyles replied to N0L1m1t5's topic in PHP Coding Help
popup? like in javascript popups? echo '<script>alert("Invalid Username or Password");</script>'; ? ? ?