This code was working, but now does not work, why? Can anybody help me? I using, first Xampp 1.6.8 and right now I using Xampp 1.7.3. index.php ====== <?php $cn = mysql_connect("localhost","root","clave"); mysql_select_db("reserva"); $sql = "SELECT * FROM ciudad"; $rsOrigen = mysql_query($sql); $nOrigen = mysql_num_rows($rsOrigen); ?> <form name="fvalida" method="POST" action="form_muestra.php"> <table width="383" border="0" bgcolor="#FFFFFF"> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"><div align="right">Nombre :</div></th> <td><input type="text" name="nombre"/></td> </tr> <tr> </tr> <tr> <th scope="row"><div align="right">Seleccione : </div></th> <th scope="row"><div align="left"> <select name="origen"> <option value="0">Seleccione</option> <? for ($k=0;$k<$nOrigen;$k++) { $idciudad = mysql_result($rsOrigen,$k,"idciudad"); $ciudad = mysql_result($rsOrigen,$k,"ciudad"); ?> <option value="<? echo $idciudad?>"> <? echo $ciudad ?> </option> <? } ?> </select> </div></th> </tr> <th colspan="2" scope="row"> <input type="submit" value="Aceptar"/> </th> </tr> </table> </form> PHP: form_muestra.php ============ <head> <title>EJEMPLO</title> </head> <body> El nombre se fue : <?php echo $_POST['nombre'] ?> La ciudad fue : <?php echo $_POST['origen'] ?> </body> </html> PHP: Data Base : Reserva ============= CREATE TABLE `ciudad` ( `idciudad` int(10) unsigned NOT NULL, `ciudad` varchar(50) NOT NULL default '', PRIMARY KEY (`idciudad`) ) TYPE=MyISAM AUTO_INCREMENT=5 ; INSERT INTO `ciudad` VALUES (1, 'Lima'); INSERT INTO `ciudad` VALUES (2, 'Trujillo'); INSERT INTO `ciudad` VALUES (3, 'Cusco'); INSERT INTO `ciudad` VALUES (4, 'Iquitos'); PHP: Just in case... this code I did not write it.
It would help if you could give us an idea on what is "not working" - like the error message or line number. put this at the top of your script to get maximum error messages and warnings. error_reporting(E_ALL); PHP:
Furthermore ensure short_tags (which one of your files is dependant on) are enabled (via php.ini), as the default configuration of Xampp has this disabled, alternatively replace <? manually with <?php Overwrite your old index.php content with the following, and let us know whether any errors occur (by quoting them exactly). <?php error_reporting(E_ALL); $cn = mysql_connect("localhost","root","clave") or trigger_error('Connection failed: ' . mysql_error($cn), E_USER_ERROR); mysql_select_db("reserva"); $sql = "SELECT * FROM ciudad"; $rsOrigen = mysql_query($sql) or trigger_error('Query failed: ' . mysql_error($rsOrigen), E_USER_ERROR); $nOrigen = mysql_num_rows($rsOrigen); ?> <form name="fvalida" method="POST" action="form_muestra.php"> <table width="383" border="0" bgcolor="#FFFFFF"> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"><div align="right">Nombre :</div></th> <td><input type="text" name="nombre"/></td> </tr> <tr> </tr> <tr> <th scope="row"><div align="right">Seleccione : </div></th> <th scope="row"><div align="left"> <select name="origen"> <option value="0">Seleccione</option> <?php for ($k=0;$k<$nOrigen;$k++) { $idciudad = mysql_result($rsOrigen,$k,"idciudad"); $ciudad = mysql_result($rsOrigen,$k,"ciudad"); ?> <option value="<?php echo $idciudad?>"> <?php echo $ciudad ?> </option> <?php } ?> </select> </div></th> </tr> <th colspan="2" scope="row"> <input type="submit" value="Aceptar"/> </th> </tr> </table> </form> PHP:
Good point. I've had hosting companies beef up their security and block features without warning. First I know is when a script won't run.
ok, you're right. First, the program does not show table "ciudad" in the dropdown. But now It's ok... but why??