Topic: Help.

Hi!, my code is

function info2($clave){ //En este caso la clave será la palabra a busca.
        $respuesta = new xajaxResponse();
        $LL = mysql_connect('localhost','root','')or
        die("Could not connect: " . mysql_error());   
        $t_respuesta = "";
        $consulta = "SELECT * FROM cliente where giro = '$clave'";
        //$row=mysql_fetch_array( mysql_query($consulta));
        $t_respuesta .="<h2>nada de nada</h2>";
        return $respuesta;

this works, but when uncomment the line  "    //$row=mysql_fetch_array( mysql_query($consulta));  " not works.
why will it be?

Re: Help.

try mysql_fetch_assoc and also mysql_select_db too.

your database may not be selected yet.

mysql_select_db("your database name here");
$consulta = "SELECT * FROM cliente where giro = '$clave'";
        //$row=mysql_fetch_array( mysql_query($consulta));
        $row=mysql_fetch_assoc ( mysql_query($consulta));

Re: Help.


Be carefull with die(...) if you can't connect with database you will get problems with this function you can do something like this:

$LL = mysql_connect('localhost','root','')
$t_respuesta = "code blablablabla";
$t_respuesta = "Error with bbdd connection";

How say bluejay use:


note: @ is for not see errors in screen.

With this 2 function you can get row and rows. There are adapted to a class mysql if you have any doubt u can answer me

function get_registro($consulta_id=-1){
        if ($consulta_id!=-1){
        if (isset($this->consulta_id)){
            $registro = @mysql_fetch_assoc($this->consulta_id);
            $this->set_error("[191]Consulta invalida: <b>$this->consulta_id</b>. El registro no puede ser afectado.<br />");
        return $registro;
    function get_registros($sql){
        $consulta_id = $this->consulta($sql);
        $registros = array();
        while ($fila = $this->get_registro($consulta_id, $sql)){
            $registros[] = $fila;
        return $registros;