SQL query not working anymore

This is a discussion on "SQL query not working anymore" within the Databases section. This forum, and the thread "SQL query not working anymore are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jun 29th, 2008, 17:59
Junior Member
Join Date: Aug 2007
Location: London
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
SQL query not working anymore

Dear all,
Was wondering if someone could help. I have recently transferred to a new server that runs an upgraded version on sql. My previous sql was hosted on Cpanel:
Server version: 5.0.51a-community
MySQL client version: 5.0.51a

My new server is hosted by Heart Internet's extend:
Server version: 4.1.22-standard
MySQL client version: 4.1.22

With a few tweaks I managed to get my site working on the new server, all apart from one query and I cant solve it. I have also had another coder try and he counldnt either! I have a copy of the site still running on the old server so that you can see the difference. Could anyone help?

More info: Its an estate agents website, and the query is retreving information from a search.

Last edited by markusdavid; Jun 29th, 2008 at 18:01. Reason: add more info
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jun 29th, 2008, 18:14
Marc's Avatar
Staff Manager

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 1,777
Thanks: 0
Thanked 15 Times in 15 Posts
Re: SQL query not working anymore

Do you have the SQL for the query? Can you show us?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jun 29th, 2008, 18:28
Junior Member
Join Date: Aug 2007
Location: London
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: SQL query not working anymore

Thank you for replying marc. Literally the guy who was working on it has just solved it! I have no idea how but its working! I really appreciate you replying though.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jun 29th, 2008, 18:33
Marc's Avatar
Staff Manager

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 1,777
Thanks: 0
Thanked 15 Times in 15 Posts
Re: SQL query not working anymore

No problem mate. Just for future reference of different members, what was the solution (if you can share of course!)

Cheers and glad you got it sorted!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jun 29th, 2008, 18:41
Junior Member
Join Date: Aug 2007
Location: London
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: SQL query not working anymore

Hi marc, would loved to have shared, but I have no idea what they guy has done! He done stuff to the database and my query and other stuff in my sql/php. I wouldnt know where to begin! Sorry about that.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Jul 14th, 2008, 21:56
New Member
Join Date: Jul 2008
Location: UK
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: SQL query not working anymore

Hi all,
I don't know the difference between the old mysql Server version: 4.1.22-standard and the new Server version: 5.0.51a-community, but I've noticed a few things which I would like to share with you.

It seems that some queries run on the old server don't work on the new version. I think the easiest way to explain this is the difference between HTML and XHTML. The new Server version: 5.0.51a-community is more complex and requires more detailed and correct information.

The new Server version: 5.0.51a-community doesn't 'think' you have to tell it everything.

In markusdavids case it didn't know where to get the information from, although it was obvious for the old version and for a coder

i.e: a form action = post ... the old version would automatically get the information from the form, for the new version you have to specify $client = $_POST['client']

Do I make sense???

I'm having a problem with the new version myself at the moment and I'm not sure how to do it.

Why did they make it so difficult for us?????

Thanks for reading my waffle

DeMan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Jul 14th, 2008, 23:19
Up'n'Coming Member
Join Date: Jul 2008
Location: UK and Spain
Age: 24
Posts: 91
Thanks: 2
Thanked 9 Times in 9 Posts
Re: SQL query not working anymore

that sounds like a difference in the register globals setting, that's a PHP setting, not a MySQL one... or I've got completely the wrong end of the stick lol

Stu
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Jul 15th, 2008, 12:16
New Member
Join Date: Jul 2008
Location: UK
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: SQL query not working anymore

Ok, I've got a question then

Why does a query work on the old version but not on the new one?

what are the main differences in coding php for the new Mysql version?

I've got one at the moment and I'm struggeling

does anyone know?????

Thanks
DeMan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Jul 22nd, 2008, 10:59
Up'n'Coming Member
Join Date: Jul 2008
Location: UK and Spain
Age: 24
Posts: 91
Thanks: 2
Thanked 9 Times in 9 Posts
Re: SQL query not working anymore

what is the exact query you are running ok on the old one, and that doesn't work on the new version?

Do you have an error message at all?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Aug 4th, 2008, 17:38
New Member
Join Date: Jul 2008
Location: UK
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: SQL query not working anymore

Hiya,
this is the code, I got it from widgetmonkey.com.
Its a exam question script (questions and answers are stored in the database)
It works perfectly fine on the old version of the mysql Server.

I don't get an error message, but the query doesn't run. Instead it goes back to the beginning (showing the questions and answers) No matter what I do, I can't get it to work.

It seems like a little problem, but I'm drawing a blank.

Any help would be greatly appreciated!!

PHP: Select all

<?php
//copyright widgetmonkey.com 2001
include("contentdb.php");
$display mysql_query("SELECT * FROM $table ORDER BY id",$db);
if (!
$submit) {
    echo 
"<form method=post action=$PHP_SELF>";
    echo 
"<table border=0>";
    while (
$row mysql_fetch_array($display)) {
    
$id $row["id"];
    
$question $row["question"];
    
$opt1 $row["opt1"];
    
$opt2 $row["opt2"];
    
$opt3 $row["opt3"];
    
$answer $row["answer"];
    echo 
"<tr><td colspan=3><br><b>$question</b></td></tr>";
    echo 
"<tr><td>$opt1 <input type=radio name=q$id value=\"$opt1\"></td><td>$opt2 <input type=radio name=q$id value=\"$opt2\"></td><td>$opt3 <input type=radio name=q$id value=\"$opt3\"></td></tr>";
    }
    echo 
"</table>";
    echo 
"<input type='submit' value='See how you did' name='submit'>";
    echo 
"</form>";
}
elseif (
$submit
{
    
$score 0;
    
$total mysql_num_rows($display);
        while (
$result mysql_fetch_array($display)) 
        {
            
$answer $result["answer"];
            
$q $result["q"]; 
        if ($
$q == $answer
        {
        
$score++; 
        }
    }
    echo 
"<p align=center><b>You scored $score out of $total</b></p>";
    echo 
"<p>";
    if   (
$score == $total) {
    echo 
"Congratulations! You got every question right!";
    }
    elseif (
$score/$total 0.34) {
    echo 
"Oh dear. Not the best score, but don't worry, it's only a quiz.";
    }
    elseif (
$score/$total 0.67) {
    echo 
"Well done! You certainly know your stuff.";
    }
    else {
    echo 
"Not bad - but there were a few that caught you out!";
    }
echo 
"</p>";
echo 
"<p>Here are the answers:";
echo 
"<table border=0>";
$display mysql_query("SELECT * FROM $table ORDER BY id",$db);
while (
$row mysql_fetch_array($display)) {
$question $row["question"];
$answer $row["answer"];
$q $row["q"];
echo 
"<tr><td><br>$question</td></tr>";
if ($
$q == $answer
        {
        echo 
"<tr><td>&raquo;you answered ${$q}, which is correct</td></tr>";
        }
elseif ($
$q == "") {
echo 
"<tr><td>&raquo;you didn't select an answer. The answer is $answer</td></tr>";
}
else {
echo 
"<tr><td>&raquo;you answered ${$q}. The answer is $answer</td></tr>";
}
}
echo 
"</table></p>";
}
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Aug 7th, 2008, 23:58
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,255
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: SQL query not working anymore

Would you have happened to upgrade PHP as well? There are a few problems in the script that could happen depending on your PHP config.
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Aug 9th, 2008, 09:39
New Member
Join Date: Jul 2008
Location: UK
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: SQL query not working anymore

Yep, PHP got upgraded from 2.11.0 to 2.11.4

I got the script so far that it actually goes to the page with the answers, but the answers aren't displayed. It seems that its not quering the database.

Have you got any clues as to whats wrong with the code?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Aug 9th, 2008, 16:47
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,255
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: SQL query not working anymore

Could you paste what the code outputs?
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Aug 9th, 2008, 22:14
New Member
Join Date: Jul 2008
Location: UK
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: SQL query not working anymore

It queries the database and pulls out the correct answers, but doesn't compare the input answer with the correct one.

PHP: Select all

<form method=post action=>
<
table border=0><tr><td colspan=3><br><b>test question</b></td></tr>
<
tr><td>test answer <input type=radio name=q3 value="test answer"></td>
<
td>answer test <input type=radio name=q3 value="answer test"></td>
<
td>test test <input type=radio name=q3 value="test test"></td></tr>
<
tr><td colspan=3><br><b>when are we going?</b></td></tr>
<
tr><td>i dont know <input type=radio name=q4 value="i dont know"></td>
<
td>soonmaybe <input type=radio name=q4 value="soon, maybe"></td>
<
td>or whenever <input type=radio name=q4 value="or whenever"></td></tr></table>
<
input type='submit' value='See how you did' name='submit'></form
I select an answer and hit 'submit' and this is what i get, it always says "you didn't select an answer".
PHP: Select all

<p align=center>
<
b>You scored 0 out of 2</b></p>
<
p>Oh dearNot the best scorebut don't worry, it's only a quiz.</p>
<
p>Here are the answers:<table border=0><tr><td>&raquo;you didn't select an answer. The answer is answer test</td></tr>
<tr><td>&raquo;you didn'
t select an answerThe answer is or whenever</td></tr></table></p
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Aug 14th, 2008, 12:12
New Member
Join Date: Jul 2008
Location: UK
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: SQL query not working anymore

Has anyone got any ideas?
I just need some tips as to what has changed with the new php.

thanks heaps
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Aug 14th, 2008, 21:05
CloudedVision's Avatar