laffin
Members-
Posts
1,200 -
Joined
-
Last visited
Everything posted by laffin
-
[SOLVED] SQLite, LIKE vs regular expression?
laffin replied to Axeia's topic in Other RDBMS and SQL dialects
Heh, the tricks ya can pick up here Thanks nrg, shure this will help a lot of ppl out. -
Is there anyway of checking an email address with the email provider?
laffin replied to shadiadiph's topic in PHP Coding Help
U can log into the smtp server, and send a message usually the server will tell u if it exists but this has its own complications as well. as some servers will require authentication then trying to extract and come up with a legit domain for the service as different providers use different naming systems. Its a lot more immediate than checking imap/pop for a particular message, but it has a lot more complications as well. -
heh, sometimes that happens, when yer typing in responses.
-
What errors? web server errors browser errors php errors Thats like calling yer car mechanic and saying "My car dun work, what's wrong with it?" if you dun know the sympotons, how is he gonna give u a diagnisis. and web server/php gives u a log for these errors. so makes yer job a lot eaier.
-
did ur friend run the prescribed script after installing php? <?php phpinfo(); ?> Yer using long tags which is good, but ya fail to mention the errors. we arent mind readers. check yer apache logs for errors check yer php logs for errors
-
Is there anyway of checking an email address with the email provider?
laffin replied to shadiadiph's topic in PHP Coding Help
There is also something called a return reciept email, once an email has been opened, a confirmation reciept is sent back to the sender. Im not shure how the header for this works, but I know a number of email apps do support it. -
<?php $id = (isset($_GET['id']) && is_numeric($_GET['id']) && ($_GET['id'])>0)?0+$_GET['id']:0; if($id) { $where= " WHERE cat=$id"; $result = mysql_query("SELECT * FROM items".$where) or die(mysql_error());; } $start = (isset ($_GET['page'])) ? ($_GET['page'] - 1) * 4 : 0; $page = ($start == 0) ? 1 : $_GET['page']; // $result = mysql_query("SELECT * FROM items WHERE catid='$id'") or die(mysql_error()); weird that int() doesnt work, if it dusn work, use 0+ for conversion
-
something like <?php $id=(isset($_GET['id']) && is_numeric($_GET['id']) && ($_GET['id'])>0))?int($_GET['id'])):0; if($id) $where= " WHERE cat=$id"; $query="SELECT recs FROM table".$where; the big if line does some validation, is it empty, does it have a number, and does it have an absolute value (positive). simple validation like above, can save yer database from injections
-
Shure thing, I hope my explanation was good enough of why it happened the way it happend... LOL
-
Yes, But Groupname shudn be an array as u are showing. groupname should be one of those titles, not an array of those titles groupname should be updated after loading the groups. and thats why u see it as failing. so load $groupname with the users group before the display function.
-
and counter dusn increment, the code looks ok. By any chance have u tried simplifying the code to only the problem in question. than add code in? <?php session_start(); $_SESSION['counter']=isset($_SESSION['counter'])?$_SESSION['counter']++:1; header('Content-type: text/plain'); echo "Counter at : {$counter}\n"; ?> And Bam it dun work... Than it occurs to me, why are we incrementing it by one, than assigning it to itself? [code] <?php session_start(); $_SESSION['counter']=isset($_SESSION['counter'])?$_SESSION['counter']+1:1; header('Content-type: text/plain'); echo "Counter at : {$counter}\n"; ?> And Bam it works why does it work? Increment ++ operator dusn need to be assigned. depending on location, the increment happens before or after the expression $count=$counter++; counter is returned, than 1 is added, $count==$counter-1 $count=++$counter; add 1 to counter, return valur, $count==$counter so what ya was seeing was, that counter never increased. because the counter was incrememted ($_SESSION['counter']++) but the value reset because the redefinition ($_SESSION['counter']=) Mystery Solved
-
Generating default months for year-only Unix Timestamp
laffin replied to kingnutter's topic in PHP Coding Help
U should be giving the variables default values if none are entered example // if ($freq == "daily") // { $day = $_POST[day]; // } // else // {$day = 01;} if day isnt submitted, it ends up being blank so u must check for this circumstance and give it a default value, in our case 1 $day=(isset($_GET['day']) && is_numeric($_GET['day']) && $_GET['day']>0 && $_GET['day']<31)?$_GET['day']:1; if yer able to follow the mess, its just a sequence of if statements if day exist and its numeric and is between 1-31 then use the $_GET information, otherwise set it to 1 -
yes but ya will recieve notices of undefined variables and yer query may not be what u expect. As said, Checkboxes/radio buttons only return a key/value pair if its selected/checked so the other values wont be sent for processing and yer sql statement with '$none OR $tbc OR $wotlk' becomes OR OR 24 or OR 8 OR or 0 OR OR
-
Q: Why have an option of 3 choices, if in the processing yer going to use all three? It kinda defeats the purpose.
-
because the base starts at zero not 1 so if yer count is 25 yer elements are 0 to 24
-
Thats html not php <input type="radio" name="wotlk" value="0"> 0<br> <input type="radio" name="wotlk" value="8"> 8<br> <input type="radio" name="wotlk" value="24"> 24<br> whatever is ticked gets sent to the script.
-
have no clue what yer saying Grab all records, dun add a WHERE clause SELECT * FROM table select 1 record, use a WHERE clause SELECT * FROM table where x=1 if u have more than 1 record, use OR to seperate or in SELECT * FROM table where x=1 OR x=2 OR x=3 SELECT * FROM table where x IN (1,2,3)
-
Why not just use a radio button? checkboxes and radio buttons have the same name, but only the ones checked get sent to get/post.
-
Why ya using ${$counter} if counter = 0 than it becomes $0 so fix that why did u escape the first set of quotes, but not the rest in the display loop? <?php $count = 0; $counter = 0; $break = 0; $dir = @ opendir("images"); while (($file = readdir($dir)) !== false) { if(stristr($file, ".jpg")) { $name[$counter] = $file; $counter++; } } while($count <= $counter) { echo "<a href=\"img.php?file={$name[$count]}\" ><img src=\"images\/P\" width=\"100\" style=\"border:1px solid #e96302;\" alt=\"\"></a>"; $count++; $break++; if($break == 4) { echo '<br>'; $break = 0; } } closedir($dir); ?> This code can be optimized a lot. Other from that didnt see anything else
-
Generating default months for year-only Unix Timestamp
laffin replied to kingnutter's topic in PHP Coding Help
ya removed the validation code which uses a default value -
I found the post with the metatag example. its a small redirect script that shows ya can redirect without javascript or header, and still toss some content into the browser Redirect with Ad
-
Actually there is another method metatags this allows u to display stuff, before redirecting. built right into html. no javascript, no headers required.
-
<?php $_SESSION['COUNTER'] = 1;//here is my problem... and did u ever consider using session_start() before actually using session variables?
-
Why keep track of timeouts, when sessions already handle that. Question is do bots store cookies, as sessions require a cookie. if not you may need yer own unique session management system, and create the timeout/expired system into it as well...
-
The array isnt the problem U dont show the definition of groupname if it shows only the last entry added, than it makes sense that groupname isnt updated to the current users group. so check yer definition of groupname, as the snippet you show only shows the usage of groupname not the definition of it