redbullmarky
Staff Alumni-
Posts
2,863 -
Joined
-
Last visited
Never
Everything posted by redbullmarky
-
[!--quoteo(post=357889:date=Mar 24 2006, 11:34 AM:name=jsimmons)--][div class=\'quotetop\']QUOTE(jsimmons @ Mar 24 2006, 11:34 AM) [snapback]357889[/snapback][/div][div class=\'quotemain\'][!--quotec--] I tried to add a function to a class and I get an error sayng the function isn't defined when I call the function from within the same class. The function is most certainly there. Is there something more to adding a function to a class than, ummm, adding it? [/quote] are you referering to it properly? even tho it's in the same class, you still have to refer to it, for example ,like: [code] $this->myfunction(); [/code] [b]EDIT:[/b] to clear up, $this is used to referer to any of a classes objects from within, including variables. it doesnt matter what the class is called, you still use $this when refering to something from within. hope that works
-
there are a couple of ways to replace frames. 1, if you have dreamweaver, use their templating functions. the basic idea is to draw the page, including stuff that will appear on all your pages (logo, menu, nav, etc) and use the same template for all your pages. any changes to the template will make the changes automatically to pages that have been drawn using the template. 2, use includes. so instead of 'hard coding' your menu, logo, etc into your pages, you do them as seperate php files and just 'include' them in the same way as each of your pages. it is possible to make frames look ok, but you can get into all sorts of problems, and things just don't seem as solid as a properly structured page. also, getting the frames to 'talk' to eachother can be alot more hard work for you in the future, not to mention the fact that some people like to bookmark individual pages in a site, which is made trickier using frames as only the parent frame gets bookmarked.
-
[code] session_start(); if (!stristr($_SERVER['HTTP_REFERER'], 'login.php')) { $_SESSION['referer'] = $_SERVER['HTTP_REFERER']; } [/code] that should start you off. cheers
-
Why Can't I Open PHP Files on My New Mac?
redbullmarky replied to Devious Designs's topic in PHP Coding Help
i actually opted for php4. if your mac is new, my guess is that you've got OSX 10.4, so go for this one: [!--quoteo(post=357768:date=Mar 23 2006, 08:45 PM:name=Devious Designs)--][div class=\'quotetop\']QUOTE(Devious Designs @ Mar 23 2006, 08:45 PM) [snapback]357768[/snapback][/div][div class=\'quotemain\'][!--quotec--] PHP 4 on Mac OS X 10.3/10.4 PHP 4.3.11 for Apache 1.3 [/quote] but i don't think php5 was there before when i first installed it. best thing to do is have a look around these forums and elsewhere for the differences between 4 and 5. cheers -
[!--quoteo(post=357763:date=Mar 23 2006, 08:34 PM:name=AbydosGater)--][div class=\'quotetop\']QUOTE(AbydosGater @ Mar 23 2006, 08:34 PM) [snapback]357763[/snapback][/div][div class=\'quotemain\'][!--quotec--] GREAT, right this works, i am going to use it as the very basis for my script, with a few additions and modifications this is Exactly what i need, Thank You SOOOOO Much! You Were A Great Help [/quote] hehe not a problem glad to help. Cheers Mark
-
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] Anything else i can do? [/quote] yep. youre including the check to make sure it's the right page, but youre not using the result to do anything. i'll ignore your HTML and just look at the PHP. sorry if i get carried away with anything: [code] <?php $valid_pages = array('index', 'password', 'value3', 'value4'); $page = $_GET['page']; if (in_array($page, $valid_pages)) { require($page.'.php'); } else { require('index.php'); } [/code] ok, it's not perfect and will still need alot of checking/testing, etc, but it should get you on your way.
-
Can anyone tell me why I am getting this message
redbullmarky replied to the apprentice webmaster's topic in PHP Coding Help
have you checked your server (using FTP or whatever) to make sure the file is definitely there and in the right place? is your document_root set up properly? put a line at the top of your code saying: echo $_SERVER['DOCUMENT_ROOT']; and let me know what the result is. -
[!--quoteo(post=357749:date=Mar 23 2006, 07:53 PM:name=AbydosGater)--][div class=\'quotetop\']QUOTE(AbydosGater @ Mar 23 2006, 07:53 PM) [snapback]357749[/snapback][/div][div class=\'quotemain\'][!--quotec--] Ok, I tryed it and now when i put in a value not listed, i just get an error message not the index!? Any other ideas? [/quote] do me a favour, post your full block of code (all in one piece) including all your changes.
-
[!--quoteo(post=357743:date=Mar 23 2006, 07:31 PM:name=AbydosGater)--][div class=\'quotetop\']QUOTE(AbydosGater @ Mar 23 2006, 07:31 PM) [snapback]357743[/snapback][/div][div class=\'quotemain\'][!--quotec--] I appoligise but that is what i though was the best thing to do! [/quote] fair comment. I ain't God around here so no need for apologies to me, but either way I posted a possible solution on your other topic. I'd cut/copy and paste, but repeating myself in two different places would make me a hypocrite lol (summary: swap your OR (||) for AND (&&) in your check youre having problems with.
-
i think i understand what you're after, but two things spring to mind: a) this belongs in the HTML/CSS forum, as there's no sign of, or no apparent need for, any PHP b) i'm not sure how different browsers fare with this one, but i don't actually think it's possible to do what youre after (ie, display each list box option in their own font). alternatives? have a 'preview' next to the list box, or stick with your first method.
-
[!--quoteo(post=357727:date=Mar 23 2006, 06:57 PM:name=AbydosGater)--][div class=\'quotetop\']QUOTE(AbydosGater @ Mar 23 2006, 06:57 PM) [snapback]357727[/snapback][/div][div class=\'quotemain\'][!--quotec--] IF YOUR HAVING PROBLEMS UNDERSTANDING ME, PLEASE READ [/quote] without being rude, the only problem i have is posting a (possible) solution in your one topic only to find you've started another about exactly the same thing.
-
you need to use AND (&&) not OR: [code] if ($page != 'index' && $myvar != 'password' && $myvar != 'value3' && $myvar != 'value4') { $page = "index"; }; [/code] the way you had it before would pretty much result ANYTHING to index, even the values you're checking
-
can you post your MySQL table structures?
-
Why Can't I Open PHP Files on My New Mac?
redbullmarky replied to Devious Designs's topic in PHP Coding Help
[!--quoteo(post=357705:date=Mar 23 2006, 06:18 PM:name=Devious Designs)--][div class=\'quotetop\']QUOTE(Devious Designs @ Mar 23 2006, 06:18 PM) [snapback]357705[/snapback][/div][div class=\'quotemain\'][!--quotec--] Any reccomendations? [/quote] absolutely - [a href=\"http://www.entropy.ch/software/macosx/php/\" target=\"_blank\"]http://www.entropy.ch/software/macosx/php/[/a] -
either backslash them or use double quotes. both will work: [code] recalc_onclick(\'p1B1\') or recalc_onclick("p1B1") [/code]
-
ultimately, totally replacing $_SESSION with $_COOKIE is floored. not saying it wouldnt work, but for some it wouldnt. imagine if a user had cookies turned off.... the best way to keep a user logged in would be a bit of a mix of both methods. carry on using sessions, but when the user logs on, set the relevent cookies if they choose to (via a 'remember me' box or something). the easiest way then would be to use the cookie info instead of presenting the login page. just make sure that when 'logout' is used that the cookies are also destroyed. at least this way, users who have cookies turned off will still be able to use your site. cheers Mark
-
Simple Variable reference Question
redbullmarky replied to milesperhour1086's topic in PHP Coding Help
[!--quoteo(post=357686:date=Mar 23 2006, 05:51 PM:name=milesperhour1086)--][div class=\'quotetop\']QUOTE(milesperhour1086 @ Mar 23 2006, 05:51 PM) [snapback]357686[/snapback][/div][div class=\'quotemain\'][!--quotec--] When creating a page in PHP, if I have the following: [code] php:$thisVar = $myArray[2]; .. .. .. .. $myArray = array(1,43,64,44); ?> [/code] Will thisVar be assigned 64 or will it be null because when we assigned thisVar, myArray did not exist yet?? I am trying to work with dreamWeaver templates and php and this is one of the things I need to figure out but I Don't have webspace to test it out on yet. Thanks [/quote] it'll be null if you do it in this order. scripting languages do everything in line order, the only exceptions being things such as functions, loops (while, for, foreach, etc). your opening php tag must be <?php too, not php: -
Why Can't I Open PHP Files on My New Mac?
redbullmarky replied to Devious Designs's topic in PHP Coding Help
[!--quoteo(post=357678:date=Mar 23 2006, 05:25 PM:name=Devious Designs)--][div class=\'quotetop\']QUOTE(Devious Designs @ Mar 23 2006, 05:25 PM) [snapback]357678[/snapback][/div][div class=\'quotemain\'][!--quotec--] the computer isn't even connecte to the internet. I'm talking about saved php files. [/quote] whilst the Mac is pre-shipped with a web server set up, it doesnt include a PHP installation initially. A 'Save' dialog' normally means that the server can't parse it, your browser doesn't understand the format, so you get prompted to save it. if you try and open a PHP file with a copy of FF, Safari or IE, or whatever browser, you need some sort of program/installation to parse it. if i open a local php file with Safari, IE or FF on my pc OR my mac, i'm gonna get a problem similar to yours. -
[!--quoteo(post=357674:date=Mar 23 2006, 05:17 PM:name=WillWill)--][div class=\'quotetop\']QUOTE(WillWill @ Mar 23 2006, 05:17 PM) [snapback]357674[/snapback][/div][div class=\'quotemain\'][!--quotec--] can no one help me? [/quote] barand is pretty much spot on with his suggestion. in the time that's gone by since he first suggested it, you could have done it already a few times over.
-
[!--quoteo(post=357654:date=Mar 23 2006, 04:31 PM:name=SecretAgentRege)--][div class=\'quotetop\']QUOTE(SecretAgentRege @ Mar 23 2006, 04:31 PM) [snapback]357654[/snapback][/div][div class=\'quotemain\'][!--quotec--] However, this got me thinking, and though it seems far-fecthed I might as well pose the question: Would it be possible to have a page such as 'http://www.dummy.com/people/person.php?id=345' show as 'http://www.dummy.com/people/George_Washington/' in the address bar? [/quote] in a word, yes and no. yes if you want to bring your server to a halt whilst it tries matching your URLs, otherwise, no. the best way to do the wikipedia type thing, using your example, would be to look outside the box a little. in many cases, people use things like 'id=345' to refer to the key of the record in the database. but if your url accepted, for example, 'topic=George_Washington', then it's just a simple rewrite. [code] RewriteRule ^people/([A-Za-z0-9\_)$ people/person.php?topic=$1 [L] [/code] hope that helps [!--quoteo(post=357671:date=Mar 23 2006, 05:11 PM:name=SecretAgentRege)--][div class=\'quotetop\']QUOTE(SecretAgentRege @ Mar 23 2006, 05:11 PM) [snapback]357671[/snapback][/div][div class=\'quotemain\'][!--quotec--] Thanks for the great post redbullmarky! I think I'm getting the mod_rewrite, but, as it seems, it would be impossible to rewrite the url '[b]http://www.dummy.com/people/person.php?id=345[/b]' to '[b]http://www.dummy.com/people/George_Washington/[/b]' because the string 'George_Washington' doesn't display in the URL in the firstplace. however, with an extra column in the database to index and pull George's info, we could have strings (say titles or names) instead of id number's for links and database indexing; something like '[b]http://www.dummy.com/people/person.php?id=George_Washington[/b]' rewritten to '[b]http://www.dummy.com/people/George_Washington/[/b]' and with php.net's 404-searching technique error-catch variants of 'George_Washington' and redirect to the correct url. That make sense? I think I'm getting the technique process.. [/quote] absolutely spot on. there's also nothing wrong with having a 'suggestion' page with names and a summary if whatever is typed matches more than one person, and then letting the user decide who they're after.
-
what youre on about is Apache's Mod_rewrite, which literally does what it says on the tin - rewrites URL's. In addition, the rewriting is done behind the scenes, so the URL remains intact in its friendly format, but the server is actually reading the right file with the right params. getting the right results has been time consuming and full of 500 internal server errors, so be prepared to get the Regex manual out. it's not horribly difficult though. Here's how my link used to look: [a href=\"http://www.thedinnertimes.com/news/article.php?id=64\" target=\"_blank\"]http://www.thedinnertimes.com/news/article.php?id=64[/a] here's how you can get to it now: [a href=\"http://www.thedinnertimes.com/news/article64.htm\" target=\"_blank\"]http://www.thedinnertimes.com/news/article64.htm[/a] here's the 3 lines in my .htaccess file that does it: [code] Options +FollowSymlinks RewriteEngine on RewriteRule ^news(/[0-9]*/[0-9]*)?/article([0-9]*).htm(l)?$ news/article.php?id=$2 [L] [/code] the rewrite rule is in 2 or 3 parts. the first part is the regex match depending on what URL was entered. the second part is the file and parameters that it relates too. the third (optional) is any additional instructions. it does take a while to get your head around it all, but the examples i gave you should give you an idea. otherwise, just put 'mod_rewrite' into google and you'll find plenty of examples. hope that helps Cheers Mark
-
the best place (and this is not fobbing you off) is the php manual. if the in-depth descriptions of the individual functions don't help, then the examples and the user comments definitely will. start here: [a href=\"http://www.php.net/imagecreate\" target=\"_blank\"]http://www.php.net/imagecreate[/a] once you get used to GD, it's really not all that hard. but as for hoping that GD will be the solution to your 'snapshot' problem, i very much doubt it. going to the trouble of parsing a webpage's code, images, etc - you may as well totally write your own browser for all the work it'll take you. Cheers Mark
-
if youre only after 4 records, use LIMIT in mysql, unless you need the other records for some other use. [code]$query2 = "SELECT * FROM logs, actionid, statusid WHERE logs.statusid = statusid.statusid AND logs.actionid = actionid.actionid AND actionid.logref = {$row['logref']} ORDER BY actiontime DESC LIMIT 4"; [/code] notice also i changed ASC to DESC in your query - DESC will mean that the most recent records will come first. hope that helps!
-
Apologies for starting yet another thread about this, but I've had a (possible) idea about advertising for the site. You see, the problem at the moment with the kontera ads (aside from script hanging) is that sometimes you think someone is making a reference to their website, especially in forums like 'website critique'. it's been mentioned before, but it's very easy to get these links mixed up with user-added links. also, the ads ALSO show up on the 'headings' of forums, and as the headings are white text on a blue background, it can look a bit ugly. so...how about this for a possible idea..A 'Welcome Back' page when a user logs in, they get a 'welcome back' type page, with stuff such as 'like this site? want hosting? posts since my last visit, etc etc'. a button/link at the bottom of the page would simply say 'Proceed to PHPFreaks forum'. for me, i personally keep myself logged in so never have to re-enter my username and password. but a 'welcome back' screen on my return would be fine. if a single 'welcome back' screen would be the trade-off for not having so many of those link ads, i'd be happy with that. may even remind me more to donate. it's also easy to forgot the 'lurkers' who would eventually turn into full registered users. having a 'welcome back' screen for registered users (think about it - these are the main people that will donate, as you have to register to post your problem to get help to it) would avoid a person who has only just found this site thinking it's an ad-farm with a bit of text about php included, not to mention how bad it can look to have the 'script error' on a professional coding site. anyway, just some food for thought from me. Otherwise, keep up the good work, Eric. This site has been as valuable to me as the php manual itself. Cheers Mark
-
absolutely spot on. works a treat. eric, i've made a donation but for some reason i did not get a confirmation email from paypal. can you confirm it came through ok? either way, i'm hoping to make donations a more regular thing from now on, as the help i've recieved here has been invaluable.