Jump to content

ChemicalBliss

Members
  • Posts

    719
  • Joined

  • Last visited

    Never

Everything posted by ChemicalBliss

  1. It sort of tells you on that page but you would edit the "src" attribute. Wherever you put your video page, must have a relative path to your video from that page. For ex. Video page will be called "index.php" Video will be "test.mpeg" /index.php /some/path/to/test.mpeg If you have a relative path such as: some/path/to/test.mpeg It will work fine. However, If you index was in another folder for ex. /mysubwebsite/index.php /some/path/to/test.mpeg The relative path would need to be: ../some/path/to/test.mpeg --------- To actually insert the path, you would use an echo, with the variable that holds that path: <?php // This code goes BEFORE the player code $mypathtovids = "/some/path/to/"; $myvid = "test.mpeg"; ?> ... player code... src="<?php echo $mypathtovids, $myvid; ?>" .. the rest of the player code...
  2. Notices are informational, they are not errors as such. They can however point towards a logic error you may have overlooked. Anything like: "Notice: Undefined ..." This means that what it says (in this case the "index" named "username") does not exist before that point/line. To get rid of the error, you have two options in all of these cases: 1. Declare the index/variable before hand (create it) 2. Check if that variable/index actually exists using "isset()" I would use the latter in this case as the variable needs to come from a user, so a simlpe check will do: In your IF statements for the username and passwd, check if they are set (isset()) BEFORE you check what their value is, and this can be in the same if statement. This is good practice to do this. I am glad you have notices turned on though and good job for wantnig to get rid of them even though (im assuming..) this code works fine.
  3. Is that when you submit data through the form? (the page it gives you after you click submit) If it is, are you using any other files or forms other than the single code you posted above? if not, and you still have a problem, can you give us the exact error copy+paste?
  4. I would ask this question in an ubuntu specialist forum, maybe someone there can shed some light on this. I know it's not the code, it is definitely something with your system software/configuration.
  5. I don't know but if that is indeed the code I garuntee 110% it is not that script. Perhaps google some info about those browsers and how they store passwords. Btw, i hope by "history" you mean "data", since history in browsers is usually just the page caches and not stored cookies or passwords etc.
  6. There are no value attributes in your html so it is _not_ the html (php output) that is creating those stored values. It must be your browser. You can implement this feature using cookies (more permanent session for example) for every browser using php to save form data or w/e from that user (could be lengthy and mysql reccommended). or if you go the other route you can blank all fields by a) putting value="" in each input text/password element and b) add no-cache headers to the response via php header(). Note* also, the reason it only works on certain "routes" to the website (ip's for example), is because you have only submitted the data via the domain that it works on (in this case you have only logged-in on localhost, or, logged in AND chose to save the user/pass - usually browsers give you this option). To test this, login on a browser you know it works on localhost, go to the ip equivalent (127.0.0.1), and log in, now once you logout and refresh it should save the data for that domain too.
  7. Sorry, just for clarification; Do you mean localhost stores usernames and passwords from forms (like firefox and ie etc on pc's)? Or are you saying that you do not need to specify a user/pass when using mysql_connect() on a localhost request, rather than a direct IP request? Former: Browser dependant, try different browsers. Latter: Specify the user/pass, or alternatively: [*]check your php.ini for the default user/pass it uses and make sure that user/pass exists and has access [*]check that mysql allows the user mentioned in php.ini access mysql via those ip-addresses - (host,user,pass) Usually though for the latter, php would use the default "root" account, for which usually only "localhost" is allowed as a hostname. Perhaps your trying to specify an ip-address in the mysql_connect() call, just use localhost if so and it should be fine. To add hostnames to a mysql user, check google. it is only a few commands but I dont know them off-by-heart.
  8. Read my post more carefully and understand what i told you to do Tell us what the print_r gives. (easier to read in page source)
  9. Hmm.. Well using all of the input from all the users on this topic it works for me: /index.php <?php include "objects/classloader.php"; $obj1 = new object1(); $obj2 = new object2(); $obj3 = new object3(); ?> /objects/classloader.php <?php //DEFINE AUTOLOADER function __autoload($className) { $file = 'objects/' . $className . '.php'; if (file_exists($file)) { require_once $file; return true; } return false; } ?> /objects/object1.php <?php class object1{ public function __construct(){ echo(get_class($this)); } } ?> /objects/object2.php <?php class object2{ public function __construct(){ echo(get_class($this)); } } ?> /objects/object3.php <?php class object3{ public function __construct(){ echo(get_class($this)); } } ?> Does this work for you?
  10. I see no variables in your query, your query therefor never changes and so your data is always the same regardless of what forum. How are you using this? ie. Are you putting it in the actual forum list generation code? or template code? you need to know which forum you want to get the topics from (WHERE clause).
  11. Always debug your code so you know that it is working exactly how you want, ie - all the variables should be exactly what you expect them to be. use combinations of echo and print_r calls. eg: <?php session_start(); print_r($_POST); // This will appear at the top of this page. It will contain every variable passed via a form that used the POST method. if (isset($_REQUEST['logout'])) { session_unset(); } if (isset($_POST['submitUpdate'])) { if (get_magic_quotes_gpc()) { $_POST = array_map('stripslashes',$_POST); } $fc = file_get_contents($_POST['file']); // truncate file $fw = fopen($_POST['file'], 'w+'); $text = explode("<!-- EDITABLE -->",$fc); $newText = $text[0]."<!-- EDITABLE -->".htmlentities($_POST['content'])."<!--EDITABLE ->".$text[2]; if (fwrite($fw, $newText)===FALSE) { die("Cannot write to file."); } fclose($fw); exit("<div><span class='redText'>The file has been updated. Click <a href=\"index.php\">here</a> to go back to admin page.</div>"); } if (isset($_POST['Submit'])) { if (($_POST['username'] == 'admin') && ($_POST['passwd'] == 'xyz')) { $_SESSION['username'] = 'login'; } else { echo "<b>You login details is not correct. Pls login again</b>"; } } if ($_SESSION['username']=='login') { if (isset($_REQUEST['file'])) { $fc = file_get_contents($_REQUEST['file']); $text = explode("<!-- EDITABLE -->",$fc); echo "<form method='post' action=''><textarea name='content'>$text[1]</textarea>"; echo "<p><input type='hidden' name='file' value='".$_REQUEST['file']."' /><input name='submitUpdate' type='submit' value='Update Page'></form>"; } else { // edit to link to your own static html files echo "<p align='center'> <a href='body/recentnewsbody.html'>Recent News</a><br/> <a href=''>Parents</a><br/> <br/> <em>Click on the links above to edit the files.</em><br/> <a href='staff.php'>logout</a></p>"; } } session_destroy(); ?> <form method="post" action=""> <table width="400" border="0" align="center" cellpadding="2" cellspacing="2"> <tr> <td>Username: </td> <td><input type="text" name="username"></td> </tr> <tr> <td>Passwd: </td> <td><input type="password" name="passwd"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="reset" value="Reset"> </td> </tr> </table> </form>
  12. Check your paths. <?php //DEFINE AUTOLOADER function __autoload($className) { if (file_exists('objects/'.$className . '.php')) { require_once 'objects/'.$className . '.php'; return true; } return false; } ?>
  13. In your opinion. I use vim, and all changes are tracked and branched through Git. Yes all opinions of course. Every IDE is slightly different, and you usually have to learn the interface to use it fully, finding features as simple as search/replace can be longer than expected in an otherwise unknown IDE. Notepad++ is a very neat and small package with limited features, it helps new users learn simply because it has less features - coding manually instead of auto-completion will help a lot in the long run. If you're making a guestbook etc, use a lightweight editor, else if your looking to build a sizable project such as a forum or content management system then you should use a more extensive IDE. Most features of advanced IDE's will seem completely unknown to you until you learn more PHP such as OOP concepts and MVC style Frameworks etc. Try them all, and find one your comfortable with, there are plenty of sites on google that has tables of the latest IDE's with a feature-set to compare what you want/need. hope this helps
  14. It depends on exactly how "unique" your code is and how reproducable it is. There is no point in patenting a binary operation for example, or even a guestbook that allows people to mark tgheir location on a map - these things are too "general" and can be implemented uniquely almost infinite ways. Copyrighting code should be enough. If you find someone else has "copied" your idea, you check their binary/code to see if it is similar to your own, tehre are analysts that can do this for you and if you find that certain parts were copied then you can sue for copyright infringement - which will show any other would-be copyier that you mean business. Basically - You can't patent something that inherently cannot be unique. (code/software). You can copyright and protect it. Through enforcement and legal processes. hope this helps
  15. Depends entirely on your project size and complexity. for small simple projects or learning to code: notepad++ for larger projects with maybe 2 or more people involved you'll want a complete IDE package such as eclipse to organise the project and keep it clean.
  16. the "mb_" part of the name denotes it is part of the "Multi-Byte" extension: php.net/mb_string The MultiByte Extension needs to be enabled in the PHP.ini. hope this helps
  17. sort($number_array, SORT_NUMERIC) www.php.net/sort (The same can be applied to rsort,asort,krsort and ksort etc)
  18. This requires some matchematics outside my range, imagine would be dealing with degrees and coordinate matrices. Anyway i found something i think is what you're looking for: http://jspservlettutorial.info/program-id-79-page-17.html hope this helps
  19. The View should be abstracted from the code. The Front controller by the looks of it will be your "runtime", So dependancies in there will be the entire website/object base your using. Passing Every Object to it from your Load class (instantiates/sets up the objects for use) should be fine as it is your base/runtime code. From there you would use the passed view class by getting the result object (which would have an interface to keep things easy to maintain/use) from the page and passing that to the view class. Which would then interact with the Page object passed to it using the interface methods alone, create its templates etc and display etc.
  20. the count, as you said its only counting 2, because its counting the "parent" array, which has 2 "sub-arrays". But those sub-arrays each hold all the matches, so you need to count one of the sub-arrays (all the sub-arrays of preg_match will have the same number of items, but some specific items in some sub-arrays may be blank, depending on your regular expression). hope this helps
  21. (Guessing that page extends front) Well, it gives rise to a "risk" of bad code, for instance; A Developer creates a main class "String_Sort". (This will sort one string, the string will be treated as an object itself) There are 2 child classes "Display" and "Sort". There is an external class required by "Sort" called "String". Display doesn't need to use the string object, and shouldn't as it has one task: to display an object. Imagine that String is the object of a simple string. String_Sort is an object that will actually reverse the string. Display will Display a String. Sort will reverse an object's string. Flow: String_Sort(String){ protected String; // or even protected, same results/implications) Sort() [extends String_Sort]{ parent->String->reverse(parent->String); // No return needed, the string is modified directly } Display() [extends String_Sort]{ parent->String->reverse(parent->String); // Problem, reversed twice, developer may not know about the above reverse code, he knows though that he has access directly to the string, he also knows the original string needs to be reversed. So he reverses, none the wiser that another developer has already implemented the reverse. echo(parent->String); } } This is the problem of protected, not to mention public objects within objects. With a team of web programmers you want to give them specific guidelines on which to code and how to interact with other objects. This way there is uniformity and it can be expressed much more easily with graphs and (other people) finding and fixing bugs. The object is goign to be a dependancy of the child class that uses it no matter what, passing it via the instantiation not only abstracts the name of the parent property but also prevents other developers from mis-using certain objects. I hope this makes sense (and helps)
  22. Yeah no sorry about that, typo, its counting the array, not the subarray, thats why its counting two (as print_r shows there are 2 sub-arrays in the $matches array).
  23. Your looking for anti-leeching? I garuntee there are thousands of snippets/tutorials and bits of info on the subject . But for your htaccess, the easiest method imo, is to use mod_rewrite (rewrite_engine in apache). Like so: Options +FollowSymLinks +Indexes RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(www.)mydomain.com [NC] RewriteRule .(exe|zip|rar)$ - [F] Put this in your top-level .htaccess file, also, change "mydomain.com" to your domain name you want to allow and it should protect any exe/zip or rar file from being directly downloaded. Scripts can something like <?php $file = "sometest.rar"; $filepath = "myfiles/"; if(!file_exists($filepath.$file)){ exit("File not found!"); } header("Content-type: application/x-rar-compressed"); header('Content-Disposition: attachment; filename="'.date("dmy").'_'.$file); readfile($filepath.$file); ?> to transmit the file to the client. hope this helps
  24. Depending on your intended data you will have to sift through this could be quite an resource intensive method, but something like: <?php $matches = ... (from preg_match); $matches_count = count($matches); $replace_array = array( "Tom", "John", "Edward" ); $replacewith_array = array( "Ben", "John2", "EdWaRd....." ); for($i=0;$i<$matches_count;$i++){ $matches[1][$i] = str_replace($replace_array,$replacewith_array,$matches[1][$i]); } print_r($matches[1]); ?> hope this helps
  25. Yes each page the controller (or some ancillary page control object) loads will be passed to that page object/page (depending how you code your pages). To me this is the most efficient way of passing instantiated objects between each other in PHP 5 - And imo more secure (either from clients or developers) than instantiating objects every use or using global objects. hope this helps
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.