Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    Problema ajax con PHP 5.3 (credo)

    Ciao a tutti,
    ho un problema con il codice che allego sotto.
    Praticamente in locale con PHP 5.2 funziona tutto bene,
    in remoto (che è comunque una rete locale) con PHP 5.3 non c'è modo di farlo funzionare.

    Dove sbaglio??
    secondo me il problema è nel file findstate.php

    Copio il codice:

    File index.php

    <html>
    <head>
    <title>Roshan's Triple Ajax dropdown code</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="javascript" type="text/javascript">
    // Roshan's Ajax dropdown code with php
    // This notice must stay intact for legal use
    // Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com
    // If you have any problem contact me at http://roshanbh.com.np
    function getXMLHTTP() { //fuction to return the xml http object
    var xmlhttp=false;
    try{
    xmlhttp=new XMLHttpRequest();
    }
    catch(e) {
    try{
    xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(e){
    try{
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e1){
    xmlhttp=false;
    }
    }
    }

    return xmlhttp;
    }

    function getState(countryId) {

    var strURL="findState.php?country="+countryId;
    var req = getXMLHTTP();

    if (req) {

    req.onreadystatechange = function() {
    if (req.readyState == 4) {
    // only if "OK"
    if (req.status == 200) {
    document.getElementById('statediv').innerHTML=req. responseText;
    } else {
    alert("There was a problem while using XMLHTTP:\n" + req.statusText);
    }
    }
    }
    req.open("GET", strURL, true);
    req.send(null);
    }
    }
    function getCity(countryId,stateId) {
    var strURL="findCity.php?country="+countryId+"&state=" +stateId;
    var req = getXMLHTTP();



    }
    </script>
    </head>
    <body>
    <form method="post" action="" name="form1">
    <table width="60%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="150">Country</td>
    <td width="150"><select name="country" onChange="getState(this.value)">
    <option value="">Select Country</option>
    <option value="1">USA</option>
    <option value="2">Canada</option>
    </select></td>
    </tr>
    <tr style="">
    <td>State</td>
    <td ><div id="statediv"><select name="state" >
    <option>Select Country First</option>
    </select></div></td>
    </tr>

    <tr>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    FILE findstate.php (secondo me quello che da problemi)



    <? $country=intval($_GET['country']);
    $link = mysql_connect('localhost', 'root', 'root'); //changet the configuration in required
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db('test');
    $query="SELECT id,statename FROM state WHERE countryid='$country'";
    $result=mysql_query($query);

    ?>
    <select name="state" onchange="getCity(<?=$country?>,this.value)">
    <option>Select State</option>
    <? while($row=mysql_fetch_array($result)) { ?>
    <option value=<?=$row['id']?>><?=$row['statename']?></option>
    <? } ?>
    </select>

  2. #2
    prova a cambiare il tag <? ?> con <?php ?>.....il primo è deprecato, si usa il secondo
    V.I.S.T.A. --> Virus Inside, Switch To Apple

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2005
    Messaggi
    579
    gli shot tag deprecati ? non mi sembra
    l'uomo è tutto ciò che non può essere

    http://www.ebug.it Discussioni da web Designer

    http://www.ebug.it/?p=354 e Dart Fener dove lo mettiamo lol

  4. #4
    PHP Short Tags refers to '<?' when a full tag is '<?php'. Most PHP installations has short tags support - but there are a few installations that have turned it off. So it is recommended that you don't use the short tags in your app if you plan to distribute it.
    V.I.S.T.A. --> Virus Inside, Switch To Apple

  5. #5
    Se non sbaglio saranno ufficialmente deprecati solo con PHP6, ma all'atto pratico gia' ora creano un sacco di problemi, quindi meglio evitarli sempre e bon.

  6. #6
    Utente di HTML.it
    Registrato dal
    Jan 2005
    Messaggi
    579
    da php 6 , no ora
    l'uomo è tutto ciò che non può essere

    http://www.ebug.it Discussioni da web Designer

    http://www.ebug.it/?p=354 e Dart Fener dove lo mettiamo lol

  7. #7
    Adesso ho un altro problema, ma credo che il problema fosse proprio li!! Infatti almeno adesso mi da errore!!

    Quasi non ci volevo credere! GRAZIE 1000!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.