![]() | ![]() |
|
Welcome to the HEXUS.community discussion forums forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and other features. By joining our free community you will have access to post topics, respond to polls and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! |
| |||||||
| Software and web development Databases, graphics, programming, scripting and web development. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| my name is neil, hello Join Date: Jan 2005 Location: London
Posts: 4,543
Thanks: 144
Thanked 19 Times in 19 Posts
| quick php problem Can someone explain why this throws up a parse error?? PHP Code: ![]() Thanks, Neil. (\__/) (='.'=) (")_(") |
| | |
| | #3 (permalink) |
| my name is neil, hello Join Date: Jan 2005 Location: London
Posts: 4,543
Thanks: 144
Thanked 19 Times in 19 Posts
| Re: quick php problem thats strange, i swear i tried that before and it didnt work :s - haha strange, thats for your help anyway, it works now! (\__/) (='.'=) (")_(") |
| | |
| | #4 (permalink) |
| my name is neil, hello Join Date: Jan 2005 Location: London
Posts: 4,543
Thanks: 144
Thanked 19 Times in 19 Posts
| Re: quick php problem Ok, next problem PHP Code: ![]() edit: Also how do would i make that link not display if the $pd++ variable was not set in my array? Thanks (\__/) (='.'=) (")_(") |
| | |
| | #5 (permalink) |
| Gentoo Ricer Join Date: Jan 2005 Location: /var/portage
Posts: 6,200
Thanks: 100
Thanked 305 Times in 278 Posts
| Re: quick php problem Do echo(++$pd) instead. $pd++ will return the value of $pd *then* increment by one. ++$pd does it the other way around (which is what you want). As for your other problem, use an if statement, something like if($pd) { printlinkcode... }. Originally Posted by Agent
Server Box -> Asus P5B-E Plus | C2D E6320 | 2x2GB GieL PC2-6400 | 6x500GB (md-raid5) | nVidia 7300LE | Ubuntu Server 9.10 (for now) Test Box -> P4E 3.2Ghz Rev. E0 | Asus P4C800-E Deluxe | 2x1GB PC3200 | 2x160Gb | nVidia TNT 2 | Gentoo (X86) Currently breaking: eINIT |
| | |
| Received thanks from: | nvening (07-10-2009) |
| | #6 (permalink) |
| Alpha Join Date: Jun 2008 Location: London
Posts: 255
Thanks: 25
Thanked 7 Times in 6 Posts
| Re: quick php problem Validate your data! - Including whatever $_GET['pd'] has is a big security issue! There are tutorials, but best method tbh is limit what can be in the URL, so simply adding something like: [code=php]if(!is_numeric($_GET['pd'])){ die(); }[/code] Will stop the page from loading because pd isnt numeric, you can use regular expressions to allow alpha numeric. |
| | |
| Received thanks from: | nvening (07-10-2009) |
| | #7 (permalink) |
| my name is neil, hello Join Date: Jan 2005 Location: London
Posts: 4,543
Thanks: 144
Thanked 19 Times in 19 Posts
| Re: quick php problem Ah, cheers for thatr aidanjt ![]() And i came up with an if statment (i was a bit coded out when i couldnt work out how to do it last night!) but im having a strange issue. The code is as follows: PHP Code: Any ideas what could be causing this? And thanks for the security tip, im working on something along those lines for when the code is more mature (\__/) (='.'=) (")_(") |
| | |
| | #8 (permalink) |
| Gentoo Ricer Join Date: Jan 2005 Location: /var/portage
Posts: 6,200
Thanks: 100
Thanked 305 Times in 278 Posts
| Re: quick php problem $pd is being incremented, so when you decrement with --, then you're returning a number for the current page. Do something like this instead. PHP Code: Originally Posted by Agent
Server Box -> Asus P5B-E Plus | C2D E6320 | 2x2GB GieL PC2-6400 | 6x500GB (md-raid5) | nVidia 7300LE | Ubuntu Server 9.10 (for now) Test Box -> P4E 3.2Ghz Rev. E0 | Asus P4C800-E Deluxe | 2x1GB PC3200 | 2x160Gb | nVidia TNT 2 | Gentoo (X86) Currently breaking: eINIT |
| | |
| | #9 (permalink) |
| my name is neil, hello Join Date: Jan 2005 Location: London
Posts: 4,543
Thanks: 144
Thanked 19 Times in 19 Posts
| Re: quick php problem That worked great thanks! Could you explain why writing it out in long form, ie $pd + 1 is different from ++$pd??? I thought all ++ was was shorthand? (\__/) (='.'=) (")_(") |
| | |
| | #10 (permalink) |
| Gentoo Ricer Join Date: Jan 2005 Location: /var/portage
Posts: 6,200
Thanks: 100
Thanked 305 Times in 278 Posts
| Re: quick php problem ++$pd is shorthand for $pd = $pd + 1;, so what you were doing there was $next = $pd = $pd + 1;. Then, when you did $previous = --$pd what you did was $previous = $pd = $pd - 1; after $pd was already incremented, the value of $pd was changed back to it's original value and assigned to $previous and $pd. Originally Posted by Agent
Server Box -> Asus P5B-E Plus | C2D E6320 | 2x2GB GieL PC2-6400 | 6x500GB (md-raid5) | nVidia 7300LE | Ubuntu Server 9.10 (for now) Test Box -> P4E 3.2Ghz Rev. E0 | Asus P4C800-E Deluxe | 2x1GB PC3200 | 2x160Gb | nVidia TNT 2 | Gentoo (X86) Currently breaking: eINIT |
| | |
| | #11 (permalink) |
| my name is neil, hello Join Date: Jan 2005 Location: London
Posts: 4,543
Thanks: 144
Thanked 19 Times in 19 Posts
| Re: quick php problem urgh, this is getting irritating. Why is this if statment executing the if statment and not the elseif statment? PHP Code: PHP Code: (\__/) (='.'=) (")_(") |
| | |
| | #12 (permalink) |
| Gentoo Ricer Join Date: Jan 2005 Location: /var/portage
Posts: 6,200
Thanks: 100
Thanked 305 Times in 278 Posts
| Re: quick php problem one equal means assignment, two equals means comparison. ![]() $page is always true because you're assigning a string to $page before evaluating it, which will always be true because it's not zero or unset. Originally Posted by Agent
Server Box -> Asus P5B-E Plus | C2D E6320 | 2x2GB GieL PC2-6400 | 6x500GB (md-raid5) | nVidia 7300LE | Ubuntu Server 9.10 (for now) Test Box -> P4E 3.2Ghz Rev. E0 | Asus P4C800-E Deluxe | 2x1GB PC3200 | 2x160Gb | nVidia TNT 2 | Gentoo (X86) Currently breaking: eINIT |
| | |
![]() |
| Breadcrumb | ||||||
| ||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP and file uploads timing out too soon | McClane | Software and web development | 12 | 02-12-2006 04:57 PM |
| Right car peeps, I know a girl with a garage problem... | MD | HEXUS.automotive - Cars & Bikes | 23 | 08-08-2005 11:05 AM |
| Quick and easy PHP help needed chaps | Kezzer | Software and web development | 20 | 23-02-2004 06:45 PM |
| php problem... | Joel | Software and web development | 2 | 12-10-2003 11:39 PM |
| HARDCORE QUESTION: php/mssql/stored procedures problem | dgr | Software and web development | 4 | 19-09-2003 08:25 AM |