Loading and next works fine - crashes on search
Loading and next works fine - crashes on search
asle
Posts: 96Questions: 28Answers: 0
My first load is fine and I can show next and previous set but when I search, the php search page crashes (500 Internal Server Error).
I have this in my server_processing.php
[code]
$aColumns = array( 'fnavn','firma','kundenr','postnr','sted','kontakt','mobil','ansvarlig' );
[/code]
Wonder if it has to do with the "fnavn" field. This is a subselect and not a field in the MySQL DB. This is MySQL. I am searching the table "montor" and fetching the text "fylke" from the table "fylke" where the "m.fylke" number equals the field "m.fylke_id"
[code]
$sWhere = "WHERE m.fylke = f.fylke_id";
[/code]
[code]
$sQuery = "SELECT SQL_CALC_FOUND_ROWS f.fylke as fnavn, m.fylke, m.firma, m.kundenr, m.postnr, m.sted, m.kontakt, m.mobil, m.ansvarlig
FROM montor AS m, fylke AS f
$sWhere
$sOrder
$sLimit
";
[/code]
My javascript:
[code]
......
"aoColumns": [
{ "mData": "fnavn" },
{ "mData": "firma" },
{ "mData": "kundenr" },
{ "mData": "postnr" },
{ "mData": "sted" },
{ "mData": "kontakt" },
{ "mData": "mobil" },
{ "mData": "ansvarlig" }
]
[/code]
I need the field "fnavn" - is it correct to put it in the $acolumns array? If I remove that field from the javascript and PHP file I get no errors. So the problem seems to be there. But what is the correct way to get that value and not search on it, since the field does not exist in the table itself?
I have this in my server_processing.php
[code]
$aColumns = array( 'fnavn','firma','kundenr','postnr','sted','kontakt','mobil','ansvarlig' );
[/code]
Wonder if it has to do with the "fnavn" field. This is a subselect and not a field in the MySQL DB. This is MySQL. I am searching the table "montor" and fetching the text "fylke" from the table "fylke" where the "m.fylke" number equals the field "m.fylke_id"
[code]
$sWhere = "WHERE m.fylke = f.fylke_id";
[/code]
[code]
$sQuery = "SELECT SQL_CALC_FOUND_ROWS f.fylke as fnavn, m.fylke, m.firma, m.kundenr, m.postnr, m.sted, m.kontakt, m.mobil, m.ansvarlig
FROM montor AS m, fylke AS f
$sWhere
$sOrder
$sLimit
";
[/code]
My javascript:
[code]
......
"aoColumns": [
{ "mData": "fnavn" },
{ "mData": "firma" },
{ "mData": "kundenr" },
{ "mData": "postnr" },
{ "mData": "sted" },
{ "mData": "kontakt" },
{ "mData": "mobil" },
{ "mData": "ansvarlig" }
]
[/code]
I need the field "fnavn" - is it correct to put it in the $acolumns array? If I remove that field from the javascript and PHP file I get no errors. So the problem seems to be there. But what is the correct way to get that value and not search on it, since the field does not exist in the table itself?
This discussion has been closed.
Replies
[code]
"aoColumns": [
{ "mData": "fnavn","bSearchable": false},
[/code]
So now it does not search on the first field. But is there a way to search on the field in any way server-side? Like I would l would like to search for if " fnavn = 'Oslo' ".
[code]
$sWhere = "WHERE m.fylke = f.fylke_id OR fnavn = $search_text ";
[/code]
so that it is added to the search string?