Domanda

Non riesco a trovare l'errore nel seguente script.Ho controllato mentre ora.Scusa, sono davvero nuovo a SQL e PHP.

    $tCompany_SQLselect = "SELECT ";
    $tCompany_SQLselect .= "ID, preNAME, Name, RegType ";
    $tCompany_SQLselect .= "FROM ";
    $tCompany_SQLselect .= "tCompany ";

    $tCompany_SQLselect_Query = mysql_query($tCompany_SQLselect);

    $index = 1;
    while ($row = mysql_fetch_array($tCompany_SQLselect_Query, MYSQL_ASSOC)) {
        $preNAME = $row['preNAME'];
        $Name = $row['Name'];
        $RegType = $row['RegType'];

        echo $index.".".$preNAME."".$Name."".$RegType" <br />;

        $index++;

    }
.

Altri suggerimenti

Primo: puoi usare:

$tCompany_SQLselect_Query = mysql_query($tCompany_SQLselect) or die(mysql_error());
.

Ciò consentirà di eseguire il debug dell'errore.

Secondo: puoi usare:

$row = mysql_fetch_assoc($tCompany_SQLselect_Query)
.

per abbreviare la sintassi.

La linea echo dovrebbe essere:

echo $index.".".$preNAME." ".$Name." ".$RegType." . "<br />";
.

Ti mancavano citazioni intorno a <br /> e il . per la concatenazione prima di esso.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top