premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
It is suggested to do more than 100 for expire time due to timezone issues, I would set the $past to time()-3600*48; (2 days ago). Working with cookies on localhost can also be tricky, checkout this article: http://www.aeonity.com/frost/php-setcookie-localhost-apache
-
How do I get rid of \r\n\r\n when editing text ?
premiso replied to David-fethiye's topic in PHP Coding Help
The issue is you are escaping "safe_sql" before error checking. If you put that after the error checking so it is only escaped before entering it into the DB this issue should not occur. -
if(!ctype_alnum($subdomains[$i])) That is your issue. preg_match would be a wiser to choice to allow more than just alphanumeric, since - is not considered alphanumeric.
-
[SOLVED] Warning: mysqli_query() expects parameter 1 to be mysqli
premiso replied to darkfreaks's topic in PHP Coding Help
Where is $con being defined. You need to show more code to get the issue fixed. The gist $con does not contain a valid mysqli resource. -
Javascript would be the way, not php.
-
Thats alot of categories to have. As far as I know there is no way to really make that more efficient/speed it up...you could switch from mysql_fetch_array to mysql_fetch_assoc since array fetches double the data where as assoc only does 1 set. Other than that change the timeout of your script, or don't do it dynamically and have a cache, when a new category is added, update the cache on the spot then just refer to the cached version for everything else...
-
He is right and wrong. It will make any data that is being imported to 0 or set to the default of the table. Since that column is in the DB it has to be entered or it is defaulted to the value. You could set it to NULL instead of 0 in the default definition, which might be more versatile, but yea.
-
$total += shell_exec("netstat | findstr $port | wc -l"); Not sure on the WC part but Grep Equiv for Windows might help for the grep part
-
[SOLVED] GMAIL messes up my emails with PDF attachements.
premiso replied to webmaster1's topic in PHP Coding Help
No it is not a language. It is more like a framework. PEAR can be installed as an extension of PHP and you can download different modules from pear.php.net which are suppose to help elaborate on certain parts of PHP and have code made that does certain tasks easier without the guess work, such as the MAIL function. Just allows for more functionality of PHP. -
Yes you can.
-
You could instead replace the $_SESSION with $_POST and no other processing would be required.
-
If you want to know how to set/unset the session vars I would need to also see the checkout.php page but here is an example for this page <td align="left"><span class="Required">*</span> First Name:</td><td align="left"><input type="text" class="txt-standard" name="txt-first-name" value="<?php echo isset($_SESSION['txt-first-name'])?$_SESSION['txt-first-name']:''; ?>" id="txt-first-name" /></td> Just rinse and repeat for each value you want to carry over. Then the checkout.php you just need to put each of those elements into session if there is an error, if there is no error then you make sure to wipe those session values if there was an error to avoid this form being populated with last forms data.
-
You would want to store the POST data in SESSIONS then if that session variable isset call it on that page. If the form submits right unset the session data you just put in. Let me know if you need a more thorough description.
-
$query2 = "SELECT distinct fid, * FROM friends WHERE `username` ='$username' OR `username` = '$userq'"; $result2 = mysql_query($query2); while ($row2 = mysql_fetch_assoc($result2)){ $bld = "{$row2['friendname']}"; } That should pull up the common friends
-
There are a bunch of options via google: http://fundisom.com/phparadise/php/databases/mySQL_to_excel http://www.phpclasses.org/browse/package/2038.html http://www.google.com/search?hl=en&q=php+mysql+to+excel&btnG=Google+Search&aq=f&oq=
-
Using phpMyAdmin you can do this rather easy in multiple formats.
-
Wow dude, take a chill pill. Sarcasm...if I really thought helping is fer(notice for spelled wrong) newbs, you would notice I would not have 1,900 posts. Give me some credit for trying to make a joke. Next time I will spell out the sarcasm for you. Edit: And it was more of a joke meant for ngreenwood at any rate. I have helped him out many times on the forum and it is nice seeing him paying it forward. See this post for proof.
-
Helping is fer newbs. If you really appreciate the help here, donate to the site. Without donations the site may one day disappear!!!
-
$UserSL = $UserS['location']; // syntax error need sem-colon $NPCL = $NPC['location']; // syntax error need sem-colon if($NPCL == "Home") {echo "User is at thier house! <br><br>"; exit(); } if($UserSL == "Home") {echo "You must be in the city to fight! <br><br>"; exit(); } echo "Begin the fight!"; Should at least echo begin the fight.
-
The (1) is the tricky part. Not sure of regex to do this but you can use explode to split a string at the spaces. If there was a space before the ( it would work just fine. Not sure if that is the answer you were looking for but it is sort of an answer.
-
User Stopping Script Half Way Through Processing
premiso replied to johnsmith153's topic in PHP Coding Help
Never had this problem. You could always do a JS and lock the page stating "updating" but ultimately the user has control. And if JS is disabled that would not work. But 10seconds is a long amount of time...is that really needed for 1 user to update something? If so I would re-think your logic, or maybe some of the queries could be incorporated into a CRON job and ran every x minutes to prevent he 10 second reload. You could also make note on the page to not click on anything until it is done processing. -
It would return all results. <?php function parse_query($string, $col) { if (strlen($string) < 3) return false; if (strstr($strng, " ") === false) return " $col LIKE '%" . check_input($string) . "%' "; $words = explode(" ", strtolower($string)); $statement = array(); $notAllowed = array("and", "the", "or"); // add more if you like foreach ($words as $word) { if (strlen($word) > 2 && !in_array($word, $notAllowed)) { $statement[] = " $col LIKE '%" . check_input($word) . "%' "; } } if (count($statement) > 0) return implode(" OR ", $statement); else return false; } $where = parse_query($_POST['query'], "band"); if (!$where) die("Invalid search parameters."); $query = mysql_query("SELECT xx FROM tablexx WHERE " . $where . " ORDER BY band"); ?> Should do the error checking properly. To answer the red river, yes. If you want to do exact matches you will need to modify the OR to AND so it will only pull up songs with both keywords in it. You could even add a checkbox option to use AND or OR on that part if you wanted to.
-
foreach That loops through the array assigning each index in that array to $word. So it is populated from the $words array.
-
Yes they will match, mysql is case insensitive. If you want to allow any size letters but disallow certain words, remove the strlen checking portions. I set it all to lowercase for the in_array portion.
-
Sorry, I should have looked better, and yes that is what $col should be. Here is updated code: <?php function parse_query($string, $col) { if (strlen($string) < 3) return false; if (strstr($strng, " ") === false) return " $col LIKE '%" . check_input($string) . "%' "; $words = explode(" ", strtolower($string)); $statement = array(); $notAllowed = array("and", "the", "or"); // add more if you like foreach ($words as $word) { if (strlen($word) > 2 && !in_array($word, $notAllowed)) { $statement[] = " $col LIKE '%" . check_input($word) . "%' "; } } return implode(" OR ", $statement); } $query = mysql_query("SELECT xx FROM tablexx WHERE " . parse_query($_POST['query'], "band") . " ORDER BY band"); ?> Would also be the usage.