premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
You can use foreign keys concept, that is not a problem at all. You just have to do the relationships manually and just make sure you cascade the deletes / updates etc. If you want to, you can probably even implement PHP Doctrine which will setup all that for you given the schema's etc. Once you learn how it works that is. The main feature you miss out with the MyISAM vs InnoDB is the Transactions. So yea. The logic should work fine.
-
php 5.3.2 gives *.php files as plain text
premiso replied to FatPuzzo's topic in PHP Installation and Configuration
It's not PHP's problem. It is Apache's or IIS problem (whichever server you have). You will need to add something like this to your apache httpd.conf file: LoadModule php5_module /path/to/modules/libphp5.so AddType application/x-httpd-php .php (The loadModule may already be in there, if it is you just need the addtype. So yea. -
Figure it out for yourself, this nonsense of "it does not work" is just bs. Flipping the $string and $input should make it work, which you could have found out by reading the manual for stristr as well which would have helped you out. How do you think everyone here who answers questions know how to do it? The learned it by reading, trying and failing. If you do not want to code it yourself then don't. Find someone else to code it and pay them. If you do, read and try stuff out for yourself.
-
foreach ($match as $string) { if (stristr($string, $input) !== false) { $input = str_replace($string, "", $input); } } echo $input;
-
RewriteRule ^(.*)/(.*)/?$ page.php?CountryID=$1&CityName=$2 [L] Should work. But may not yeild the exact results you want, as anything even say example.com/sub/realdir/ will get redirected as well.
-
I would say it has something to do with noodles.
-
Date, what is best 00:00:00 DD-MM-YY or Timestamp?
premiso replied to TeddyKiller's topic in PHP Coding Help
I prefer to go with this: YYYY-MM-DD HH:MM:SS As two digit years can be easily confused with months and or confused with milleniums. Timestamps I do not care for as they have a limit of something like 1969 - 2032. So they do not work for birthdates and other historical / furturistic dates. -
The ! before a statement, like above, indicates NOT.
-
This should be default behavior. If, you want it to show on an HTML page, you will need to use nl2br on the field when you display it (do not do it before you insert it into a database, better to keep it as the \n character). IE: $text = isset($_POST['textareaname'])?$_POST['textareaname']:''; echo nl2br($text); Should display the linebreaks properly. EDIT: Just saw that this was posted in the HTML section. Since it is HTML, I think you would need to use JavaScript to conver the \n (linebreak character) to <br />. Since I do not know Javascript I cannot offer much help then to set you on the right direction. If you are using PHP, the above advice will work. EDIT:EDIT: If you want to view it and do not care about formatting, encasing the value in a <pre></pre> tags will display the line breaks properly as well.
-
Given the poorly given advice of the previous two posters, I felt the need to correct them: $sql="INSERT INTO log (logid, username, logdate, type, totaltime_mins, total_distance, notes) VALUES (Null,'{$_SESSION['myusername']}','{$_POST['logdate']}','{$_POST['type']}','{$_POST['totaltime_mins']}', '{$_POST['total_distance']}','{$_POST['notes']}')"; Should work properly. For array elements that are associative indexed you need to use either curly braces, as seen above or concatenate the line IE: $sql="INSERT INTO log (logid, username, logdate, type, totaltime_mins, total_distance, notes) VALUES (Null,'" . $_SESSION['myusername'] . "','" . $_POST['logdate'] . "','" . $_POST['type'] . "','" . $_POST['totaltime_mins'] . "', '" . $_POST['total_distance'] . "','" . $_POST['notes'] . "')"; Either of those is the correct variation and usage. If the session variable still does not work, make sure you have session_start at the top of the page so the session gets initiated for that page. EDIT: Why micah's is "incorrect" or "poor advice" is that using non quoted associative index causes a PHP Notice error, which is not "hugely" important, but it is still better to not cause errors of any kind if you can avoid it. If, however, you were using a numerical indexed array, that would be fine, but I still find it better to seperate variables by either the concatenation or the curly braces for readability sakes as a personal preference. Katsu's advice is wrong in that you do need to single quote string / text values inside of MySQL SQL Statements, and he did not concat or enclose the php variables in curly braces so the actual values would not have appeared properly either. As a side note, you should really sanitize your POST / GET / SESSION variables with mysql_real_escape_string before running a query on them to prevent MySQL errors and possible SQL Injection.
-
preg_match('~<span id="ref_.*">(.*)</span>~isU', $string, $matches); Should get you want you want. Result will be in $matches[1].
-
changing address bar gives access for user to admin page.
premiso replied to scorpio22's topic in PHP Coding Help
Add verification to the admin.php to require a valid administrator. However you are redirecting the user to the correct page, use that logic to validate the user on each admin page. -
The reason it hangs is it is expecting input, without the exit command being issued the command prompt is just going to sit there waiting for input, as that is what it does. So if you were able to pass "exit" to that command prompt, it would un-hang the browser as it would kill the cmd process. Does that make sense?
-
Error, trying to count rows.. HELP PLEASE =]
premiso replied to jigsawsoul's topic in PHP Coding Help
The WHERE clause needs to be after the FROM tablename -
If you are using a Linux OS for your server you will need to encase the directory in single quotes if it has a space in it. On windows, I believe you would have to encase the whole path in single quotes. But I do not see in that code where you are trying to delete / chown / chmod the directory? On another note, why not just replace the spaces with _ or -, as this will be much easier to manage and not require extra / special code to manipulate.
-
<?php $page = isset($_GET['page'])?$_GET['page']:'index'; switch ($page) { case 'add': break; case 'edit': break; default: case 'index': break; } ?> I believe that is the type of logic you are after.
-
Have you tried running the command via the cmd.exe interface? Does it work properly there or does it hang as well? Chances are it is expecting more input or "pause's" after it executes which is why it would hang.
-
PHP is CaSe SenSiTiVe $page = $_GET['page']; GET / POST / SESSION / COOKIES / SERVER all need to be in caps.
-
Use an if statement checking if empty? if (!empty($a3)) { echo $a3; echo "<br>" }
-
Yea... $line['columnname'] or $line[0] depending on what field you are after, etc. You can do a print_r($line) as well to print the entire array structure to see what you want.
-
If you are on a Linux Host, Linux has a few barcode applications, if on Debian, search Aptitude Package Manager for BarCode. Should have a few for reading / creating them and you should be able to call it via command line using system. I have never done this, just expressing a way that a PHP script could (the only way that I know of) do it. But as far as PHP doing it on it's own, I do not know of any way other then accessing a thridparty application via system.
-
It has handled how you code it to be handled. As for the session, if session_start is on the page the session file is created with the automatically generated session_id that php generates and is stored in the session directory. As for MySQL, the time it takes to process a query it is very doubtful that multiple users on the page would matter, especially since it is very unlikely that they would both be working on the exact same data (manipulating it) at the same time. But as stated, it is also how the code is coded and the scope of how many users.
-
I have never used or had to use session_name() as the "colliding" session variables should be very slim, unless you have a ton of users for each application, then I could see the collisons, but setting the save path for each application, as you stated, should fix that and you should not need the session_name. However, if you want it, I do not see anything wrong with using it. You could also check your session garbage collector value and put that to a lower value so it clears out the session garbage more regularly if the session has expired. For the logged in issue, you can simply make a cron script that checks if the lastactivity time is greater then x minutes, say 5, they are not "loggedin" or "active". That would be the only way I know how to do that (granted there are other ways with AJAX etc) but yea.
-
// add error reporting just to make sure errors are sown. error_reporting(E_ALL); ini_set('display_errors', 'on'); $result = system("wget -O tmp1 '$url' "); echo "the system results are: ".$result."<br>"; echo "<br>the shell_exec results are: " ; echo shell_exec("wget -O tmp2 '$url' ")."<br>"; $test = exec("wget -O tmp3 '$url' ",$tmp); print_r($tmp); echo "<br>the exec results are: "; print_r( $test); // $test1 = `wget -O tmp4 "$url" `; $test1 = '`wget -O tmp4 "' . $url . '"`'; // ecased in single quotes. echo "<br>the gershaim results are: "; echo "<pre>$test1</pre>"; $string = system('wget http://www.example.com/index.html ~',$file); echo $string; echo ' "test"'; Not exactly sure what you are expecting to get, but hopefully the error reporting and the $test1 line help get you on your way.