premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
By using the s modifier: if (preg_match('~^\A.*5$~s', $string, $matches)) { Should resolve that issue as it treats the string as being on one line. It may do you good to look at the regex resources I posted in my signature, if you plan on using them regularly. I like the cheatsheet the best.
-
Posted 2 days ago - How would I do something similar
premiso replied to TeddyKiller's topic in PHP Coding Help
http://snippets.dzone.com/posts/show/3044 A "Time Since" function is what you are after. -
if (preg_match('~^A.*5$~', $string)) { echo "Match Found."; } Un-tested and pending any silly errors I made should work like you want.
-
Not really sure about this statement. It is all in context. I tend to only ever use <?php echo $var;?> if the file I am working in is a "template" file that is to display data. So when you call it via include('template.php'); the code gets processed. If I am debugging I tend to do the echo. If I want to display the form built via a php file, non templated, I stored the data in a string and would use the similar setup to the echo except something $display .=. But given what the user posted in the original topic it looks like it is setup as a template of sorts and would use the <?php echo $var; ?> Just clarifying
-
Try defining the path and domain (See setcookie for usage examples). And see if giving it more proper parameters will help it work.
-
If you are using apache, you need to use mod_rewrite. If IIS, I am not sure you will have to google. For an article for Apache: http://knol.google.com/k/seo-friendly-url-or-pretty-url-using-apache-mod-rewrite
-
At my wits end - can you help solve this ob_start/ob_end_clean() puzzle?
premiso replied to DLR's topic in PHP Coding Help
I am not sure why, you would have to turn on error reporting and see what errors come. You can also try this instead: function get_header($path, $file) { ob_start(); include($path . $file); return ob_get_clean(); } get_header("../client_info/", $_SESSION['header']); If that does not work, yea turn on error displaying and make sure that error_reporting is set to E_ALL and see what error is coming up. -
not using mysql_real_escape_string(), problem?
premiso replied to daydreamer's topic in PHP Coding Help
addslashes does not escape all the security flaws a string can add, which is why mysql_real_escape_string was created. So yes, you are potentially vulnerable for that reason. -
$sql = "SELECT SUM(hits) AS totalhits FROM table"; Using MySQL's built in SUM function, this is easily possible.
-
Website being hacked! Some one is deleting all posts!
premiso replied to runnerjp's topic in PHP Coding Help
Sometimes, you should just stop. Go buy a book on "Security with PHP" or go read a few tutorials on it. Then come back to your code and really look at it. You are just glazing over it, in my opinion, and are obviously mis-informed about best security practices. Without seeing the full script, given that anyone would want to read through the full script, we cannot actively help you solve this issue. More or less read up on a basic secure "User Registration / Login System" with Sessions and implement that with checks. -
They can if you do not code for SQL Injection and do not Hash the password. It is very bad practice to store passwords in raw text in the database. The general practice is to hash them with md5 or sha1 with a random seed.
-
It tends to be better to store text in the database in it's raw format. But if you must: $text = str_replace("\n", "", nl2br($text)); Should work for what you want.
-
echo $_GET['forumid']; Or simply parse_str if you just have the raw data.
-
WoW - Words of Wisdom
-
RewriteEngine On RewriteCond %{HTTP_HOST} ^rakugumi.com RewriteRule ^(.*)$ http://www.rekugumi.com/$1 [R=permanent,L] RewriteRule file/(.*)/(.*)/(.*)/(.*) file.php?$1=$2&$3=$4 [L] Given that I did not make any mistakes the above should work.
-
The only php functions are for processes that php can start IE: proc_open which you can get status's for that process only. In order to get a list of processes not started by php you would need to use the shell for linux it's ps.
-
retrieving mysql information using yesterdays date
premiso replied to phpmikey's topic in PHP Coding Help
The @ is supressing any useful errors. Try this and see what the error says, (my bet is the DATE being used a column name). $result = mysql_query($query, $connection) or trigger_error("MySQL Query Failed: " . mysql_error()); See what the shows ya. -
The rewrite engine does not know to go on, it sees that rule and it matches so it executes, albiet since you do not have the [L] I would think it would but the rewrite engine is mysterious (even apache says it). I would just redirect it to index.php?v=$1 (no extension) and then do a search on index.php for v and check if file_exists if it does then yea use that extension.
-
http://cassandra.apache.org/ I love Cassandra! But you may be looking for something along the lines of: http://sphinxsearch.com/
-
You may want to look into fputcsv as that seems like it would be right up your alley.
-
One, your quotes (single) needed to be escaped or it put inside of Double Quotes. $dummyURl = sefRelToabs("http://www.oohya.net/index.php?option=com_comprofiler&task=userProfile&user='%USER%'"); Also you had the & amp on separate lines, need to be on the same line. Try the above on one line and see how it goes.
-
You error is that you are using double quotes around variable definitions in MySQL, when Single Quotes need to be used: $res = mysql_query("UPDATE $mytable SET quote='$quote' WHERE id=$id") or trigger_error('MySQL Failed: ' . mysql_error()); The trigger_error is good for debugging as it would have told you the error from the get go, as PFMaBiSmAd was hinting to.
-
The uploads directory is not at the location you think it is at. I find it better to use absolute paths over relative. So instead of ../ do something like: $upload_path = $_SERVER['DOCUMENT_ROOT'] . '/path/to/uploads/'; This way you know where the file is going. If you do not want to do that, then the uploads directory should be in this structure: ----ROOT |_____script_folder | |_______uploadscript.php |_____uploads_folder | So the uploads_folder is not at the structure like that. So you need to modify the code or create the folder in the structure setup.
-
You should really not store month separately. I would use a DATE field or even a DATETIME field to store the data. This way you can easily order by datefield and it will come out in the proper order and you do not have to worry about modifying the display information. Then if you just want the month you use MySQL's DATE_FORMAT to format the datefield when it comes out of the database. Just some food for thought.
-
Not really sure what you were doing defining a function inside of a loop, that will cause a fatal error and is just bad practice. Here is one way you could do it, basically generates an array you can loop through later to display your data. <?php $menu_info_tbl = mysql_query("SELECT food_id, section_name, page_name, food_name, food_price, food_description FROM menu_info WHERE page_name='$menu_name' GROUP BY page_name, section_name"); $menu_array = array(); while($row = mysql_fetch_assoc($menu_info_tbl)) { if (!in_array($row['page_name'], $menu_array)) $menu_array[$row['page_name']] = array(); $menu_array[$row['page_name']][] = $row; } $display = ""; foreach ($menu_array as $page_name => $menu_item) { $display .= 'Page: ' . $page_name . '<br />'; foreach ($menu_item as $item) { $display .= 'Item: ' . $item['food_id'] . '<br />Food Name:' . $item['food_name'] . '<br />Description: ' . $item['food_description'] . '<br /><br />'; } $display .= '<br />'; } echo 'Have a look at our menu!<br /><br />' . $display; ?>