I can not search by name in mysql

0

I have a table called debtors with 2 fields, name and amount, where name is a% co_of% of 20 and I value a% co_of% of 13, the key field is name and is% co_of%, I can not run a simple query as:

echo implode("",mysql_fetch_row(mysql_query("SELECT * FROM deudores WHERE nombre=a")));

I already checked the names and nothing, the table does not work, but I execute a line where I do not put a condition and if it works:

echo implode("",mysql_fetch_row(mysql_query("SELECT * FROM deudores")));

the section of code that I can not execute is this:

<?php
            $datos=explode("/",$_POST['abon']);

            $montabon=$_POST['monto'];
            if($montabon>=$datos[2]||$montabon=="todo")$montabon=$datos[2];

            //Aqui
            mysql_query("UPDATE deudores SET monto=monto-".$montabon." WHERE nombre=".$datos[1]);
            //Aqui

            echo implode("",mysql_fetch_row(mysql_query("SELECT nombre FROM deudores ")));

            if($_POST['monto']=="todo"||$_POST['monto']>=$datos[2])
            {
                mysql_query("UPDATE regdeudas SET pagado=1 WHERE ID=".$datos[0],$conn);
                echo "<h1 align=\"center\">Deuda pagada completamente</h1>";
            }
            else 
            {
                mysql_query("UPDATE regdeudas SET monto=monto-'$_POST[monto]' WHERE ID=".$datos[0],$conn);
                echo "<h1 align=\"center\">Monto abonado a la deuda</h1>";
            }
            ?>
    
asked by Anonimo 06.04.2017 в 19:54
source

2 answers

3

Your error is in this line:

implode("",mysql_fetch_row(mysql_query("SELECT * FROM deudores WHERE nombre=a")));

You are selecting a string, therefore it should be:

 "SELECT * FROM deudores WHERE nombre='a'"

quotes are important for comparing strings

    
answered by 06.04.2017 в 20:10
0

Test your select in the following way:

SELECT * FROM deudores WHERE nombre='a'

SELECT * FROM deudores WHERE nombre like '%a%' 
    
answered by 06.04.2017 в 20:11