Page 1 of 1

html data from my access db appears in my php page

Posted: Wed Nov 26, 2003 6:45 pm
by xinelo
html data from my access db appears in my php page when i use $source*

i´m writing a PHP page to query an Access database via ODBC and something very weird happened: the whole content of the database table I was trying to query appears in a html table on my webpage. Do you know how I can avoid that? It is very annoying as I can´t keep on writing the page.

my php code is:

<?php
$conn=odbc_connect('bd','user','password');
if (!$conn) {
exit("Connection Failed: " . $conn);
}
$sql = "SELECT * FROM t_termino WHERE Champ = '865' ORDER BY CleFr";
$rs = odbc_exec($conn, $sql);
if (!$rs) {
exit("Error in SQL");
}

while (odbc_fetch_row($rs)) {
$field($rs,"field");
if (isset ($field)) {
echo $field;}
}?>

for instance:

$NoteTechniqueFr($rs,"NoteTechniqueFr");
if (isset ($NoteTechniqueFr)) {
echo $NoteTechniqueFr;
}

i´ve found out that the table only appears when 'field' is 'SourceNTFr' or 'SourceNLFr' or 'SourceNTEn' or 'SourceNLEn' (even 'src*' if i replace source with src)... but strangely not 'SourceCleFr' !!


the fact that the following script appeared from nowhere in the page (after </head> and </html>) might be somehow related:

<!-- ZoneLabs Privacy Insertion -->
<script language='javascript' src='http://127.0.0.1:3004/js.cgi?aw&r=4596'></script>

the script doesn´t seem to be directly related to the fact that the table containing all data from the db appears on my webpage. the script seems to be there all the time, but the table only appears in the abovementioned case.

Thank you very much. If you can come up with something I can try, I would be much grateful. All my work is stopped because of that.

Posted: Wed Nov 26, 2003 7:31 pm
by john_drayton
I'm also a newbie about php, but i think you r prob is this:

while (odbc_fetch_row($rs)) {
$field($rs,"field");
if (isset ($field)) {
echo $field;} //<-------- this will print out the whole content of the
}?> // database you are trying to query.


I hope this solution wil help you.

problem with $source

Posted: Wed Nov 26, 2003 7:50 pm
by xinelo
well, i wish you were right but it has to be somehting else

i used field as a generic name for fields, so echo $field; should only print the content of that specific field. and as i said, my problem only happens when field = Source* or Src* EXCEPT SourceCleFr

for instance, i´m getting the data from the following fields with no problems:

while (odbc_fetch_row($rs)) {
$CleFr=odbc_result($rs,"CleFr");
$GramFr=odbc_result($rs,"GramFr");
$SourceCleFr=odbc_result($rs,"SourceCleFr");
$NoteTechniqueFr=odbc_result($rs,"NoteTechniqueFr");
$NoteLinguistiqueFr=odbc_result($rs,"NoteLinguistiqueFr");
$Champ=odbc_result($rs,"Champ");
$CombinatoireFr=odbc_result($rs,"CombinatoireFr");
$CodeOpFr=odbc_result($rs,"CodeOpFr");

echos...

}

it´s difficult to explain, but what actually happens when i use $Source... is that the whole table (exactly as it is in Access) appears in my web pag (with border="0"). php can retrieve data from fields but as far as i know cannot "create" html code... if will print an html block only if it is contained in the code to be executed (and if the condition is true)

if you still think you were right, could you explain in a more detail why?

thanks a lot for replying anyway :)