PDA

View Full Version : Erm...any ideas what's wrong with this code


jool
08-02-2005, 12:55 PM
Hello all,

I've been working on a search form which returns results based on the values entered. Clicking on the results displayed, more details of that record are then further displayed on the same page (sort of like a master detail frame set).

I have managed this successfully with only 2 search terms. However, I am now trying this with more search terms.

My search form returns the values (teacher names) correctly, however when I click on a teacher name to display more information on the record (in the details part of the page) I receive the following error:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND TestTable.teachingexperience >= LIMIT 0, 40' at line 1


Now, the line of code I have which I belive is causing the problems is the following long piece of code. This code carries with it the values entered in the initial search so that after a record has been selected from the list of results - the list of results stays as it was.

<a href="Complexsearchresults.php?nationality=<?php echo $_GET['nationality'] ?>&language=<?php echo $_GET['language'] ?>&sex=<?php echo $_GET['sex'] ?>&private_price=<?php echo $_GET['private_price'] ?>&teachingexperience=<?php echo $_GET['teachingexperience'] ?>&prefecture=<?php echo $_GET['prefecture'] ?>&mm=<?php echo $_GET['mm'] ?>&ma=<?php echo $_GET['ma'] ?>&me=<?php echo $_GET['me'] ?>&tm=<?php echo $_GET['tm'] ?>&ta=<?php echo $_GET['ta'] ?>&te=<?php echo $_GET['te'] ?>&wm=<?php echo $_GET['wm'] ?>&wa=<?php echo $_GET['wa'] ?>&we=<?php echo $_GET['we'] ?>&thm=<?php echo $_GET['thm'] ?>&tha=<?php echo $_GET['tha'] ?>&the=<?php echo $_GET['the'] ?>&fm=<?php echo $_GET['fm'] ?>&fa=<?php echo $_GET['fa'] ?>&fe=<?php echo $_GET['fe'] ?>&sm=<?php echo $_GET['sm'] ?>&sa=<?php echo $_GET['sa'] ?>&se=<?php echo $_GET['se'] ?>&sum=<?php echo $_GET['sum'] ?>&sua=<?php echo $_GET['sua'] ?>&sue=<?php echo $_GET['sue'] ?>
&recordID=<?php echo $row_m['autonumber']; ?>"><?php echo $row_m['firstname']; ?></a></font></td>

Sorry for dumping all this code in this forum, - any help would be greatly appreciated.

Thanks

Jool

jool
08-03-2005, 04:46 PM
Hello again

I've looked at my code in more detail and I think my problems are a result of the following:


I'm using the POST format to send the data, and had been using the GET to receive. This is due to me following unrelated tutorials and getting help from different people.

I had been sending using the GET method which displayed a list of results. Clicking on these results/records revealed more details about the record (on the same page)

I Used the following line of code:
<a href="Newsearchresults.php?language=<?php echo $_GET['language'] ?>&prefecture=<?php echo $_GET['prefecture'] ?>&recordID=<?php echo $row_sr['autonumber']; ?>"><font size="1" face="Arial, Helvetica, sans-serif"><?php echo $row_sr['firstname']; ?>

This was great as it ensured that when someone clicked on a record (and displayed the details associated with it) the other records which had been produced by the initial search still remained.

However, I changed the initial search form to use a POST method (to solve another issue) and as such, now when I select a record from the displayed results, the record details are shown but the list disappears. So I guess my question is can I change the code above to work for POST submission methods?)(I tried just changing GET to POST - no joy!)

Sorry about the lengthy and perhaps unclear problem explanation.

Thanks

jool
08-03-2005, 07:24 PM
:blink:
I'm sorry all, but I'm beginning to suss out my problem and I think it lies with my initial search form.


In my search form if I enter two ACTUAL values, the form submits a list of results which can be clicked and will then display further details of the record seleced. MOST IMPORTANTLY after selecting a record(result) the list of results stay (i.e the search parametes have been 'kept')

However, I have noticed that if I enter 'any' for either of the search fields (any has the following option value <option value="" selected>any</option> ) the results are still displayed but after clicking on one, the initial search parameters are lost.

So it seems that the following line of code

<a href="Newsearchresults.php?language=<?php echo $_POST['language'] ?>&prefecture=<?php echo $_POST['prefecture'] ?>&recordID=<?php echo $row_sr['autonumber']; ?>"><font size="1" face="Arial, Helvetica, sans-serif"><?php echo $row_sr['firstname']; ?>

doesn't handle these blank values very well....

I think I'm getting closer


Thanks and sorry for my ramblings so far. I'll keep you posted if I sort things out.