| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | Strange php error - been bugging me!! Ok this bug is really getting on my coding tits!! Basically this is checking if a forum topic is locked or not. I have this: PHP Code:
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | #2 (permalink) |
| Senior Member Join Date: Aug 2005 Location: United Kindom
Posts: 1,502
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | What are you actually trying to do, Also try: PHP Code: |
| |
| | THREAD STARTER #3 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | All i am trying to do is check a variable, yet it always says it's set to 1 when it's not. What you put won't help no offense.
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | THREAD STARTER #5 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | Well for one there should be a , not a . in the message function as a . links them together while , seperates them as there are two parts to the function. And second quoting what i already have and putting in slashes just does exactly the same thing as what i have in the mysql_query.
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | #6 (permalink) |
| NamePros Member Join Date: May 2006
Posts: 160
![]() | In reality, you shouldn't be using any form of quotes in the SQL around your ID value (not single quotes or double quotes): unless your ID actually isn't a number! ????: NamePros.com http://www.namepros.com/showthread.php?t=197582 I'm guessing that it's more a problem with the query or the population of the array. What happens if you add the lines: print '<pre>'; print_r($locked); print '</pre>'; after the line where you assign the SQL output to the $locked variable? Just a guess, but not knowing anything else about your code it's as good as any... I would guess that the locked variable shows to be an empty array, which would mean there's something wrong with one of the MySQL function calls. If that is the case, call mysql_error() or whatever the function is and see what it says... |
| |
| | THREAD STARTER #7 (permalink) | ||||
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() |
PHP Code:
__________________ Gaming On Linux - Because Linux is Fun! | ||||
| |
| | #8 (permalink) |
| NamePros Member Join Date: May 2006
Posts: 160
![]() | By 'set' I mean defined: either $locked['locked'] is set to 0, or it's not set at all and so the printout defaults to zero. I'm guessing the latter, but hey, if you're so sure about what you're doing that you're not even able to try three lines of code, go ahead... |
| |
| | THREAD STARTER #9 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | I didn't mean it like that buddy, i will try what you put, thanks for your help ![]() ????: NamePros.com http://www.namepros.com/showthread.php?t=197582 I get this: PHP Code:
__________________ Gaming On Linux - Because Linux is Fun!
Last edited by liam_d; 05-16-2006 at 06:45 AM.
|
| |
| | #11 (permalink) |
| NamePros Member Join Date: May 2006
Posts: 160
![]() | Hmmm... MySQL can be picky, but only sometimes What happens if you change your query from:"SELECT `locked` FROM `forum_topics` WHERE `id` = '" . quote_smart($_GET['t']) . "'" to: "SELECT `locked` FROM `forum_topics` WHERE `id` = " . quote_smart($_GET['t']); (notice the removal of quotes around the ID). I'd also add: print mysql_error(); after the query to make sure that it worked, plus... run a print_r on $_GET: just make sure that it was populated correctly, too. Other than that, yeah, we need more code |
| |
| | THREAD STARTER #12 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | I tried all of that, no difference, all the $_GET bits are there. There is no mysql error. This is really getting to me now
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | #13 (permalink) |
| NamePros Member Join Date: May 2006
Posts: 160
![]() | Hmmm... I guess the only other thing I can suggest is that *if* there's a problem with the query, the mysql_error function won't show anything as it only shows the result of the last MySQL function (which is your mysql_fetch_array call). Have you tried spliting: Code: $locked = mysql_fetch_array(mysql_query("SELECT `locked` FROM `forum_topics` WHERE `id` = \" . quote_smart($_GET['t']) .\"")); ????: NamePros.com http://www.namepros.com/showthread.php?t=197582 Code: $temp = mysql_query("SELECT `locked` FROM `forum_topics` WHERE `id` = \" . quote_smart($_GET['t']) .\"");
print 'First function: ' . mysql_error() . '<br>';
$locked = mysql_fetch_array($temp);
print 'Second function: ' . mysql_error() . '<br>'; |
| |
| | THREAD STARTER #14 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | There are no errors being printed out
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | #15 (permalink) |
| NamePros Member Join Date: May 2006
Posts: 160
![]() | Oops. Sorry. Just noticed that I copied your original query which probably wouldn't work anyway! Change: Code: $temp = mysql_query("SELECT `locked` FROM `forum_topics` WHERE `id` = \" . quote_smart($_GET['t']) .\""); Code: $temp = mysql_query("SELECT `locked` FROM `forum_topics` WHERE `id` = " . quote_smart($_GET['t']) ); ![]() I'd probably also add something like: Code: $query = "SELECT `locked` FROM `forum_topics` WHERE `id` = " . quote_smart($_GET['t']); print 'Query is: ' . $query . '<br>'; |
| |
| | THREAD STARTER #16 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | I now get Code: First function: Second function: Query is: SELECT `locked` FROM `forum_topics` WHERE `id` = 60 blah0 Array ( [act] => editpost [t] => 60 [f] => 10 [ist] => 1 ) ![]() This is the whole page if it helps at all PHP Code:
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | #18 (permalink) |
| Account Closed Join Date: Jun 2005 Location: Mozambique
Posts: 607
![]() ![]() | Hello Liam, The first glimpse at the full code that you have posted above shows me that the problem is in the later part of the code. I will just point out the thing I have noticed. $_GET['action'] does not exist. Instead it should be $_GET['act']. $_GET fetches a variable from the URL and if you look at the URL, the action variable is called "act" ex. index.php?act=viewtopic. The output from print_r($_GET); also gave you 'act' as the variable and not 'action'. Try changing all the occurrences of $_GET['action'] to $_GET['act']. I will take a good look at the code maybe tomorrow during my free time. |
| |
| | THREAD STARTER #19 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | Thanks for your reply but act and action are actually different things. Act is the module which is being loaded while action is something within the script that is going on. I will add the other print_r when i get back to my desk later on today. Thanks.
__________________ Gaming On Linux - Because Linux is Fun! |
| |
| | THREAD STARTER #20 (permalink) | ||||
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() |
Code: First function: Second function: Query is: SELECT `locked` FROM `forum_topics` WHERE `id` = 3 blah0 Array ( [act] => editpost [t] => 3 [f] => 10 [ist] => 1 ) Array ( [0] => 0 [locked] => 0 )
__________________ Gaming On Linux - Because Linux is Fun! | ||||
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |