unrealmanel Posted April 23, 2013 at 11:14 AM Report #504504 Posted April 23, 2013 at 11:14 AM (edited) <html> <style type="text/css"> .bold { font-weight: bold; } </style> <body> <?php $db="localhost"; $username=""; $password=""; $database=""; mysql_connect($db,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $code = mysql_real_escape_string($_POST['textfield']); $query = mysql_query("SELECT * FROM wp_wpdeals_permissions WHERE code = '{$code}' "); $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="1" cellspacing="2" cellpadding="2"> <tr> <td><font face="Arial, Helvetica, sans-serif" class="bold">Voucher Code</font></td> <td><font face="Arial, Helvetica, sans-serif" class="bold">Deal ID</font></td> <td><font face="Arial, Helvetica, sans-serif" class="bold">Order ID</font></td> <td><font face="Arial, Helvetica, sans-serif" class="bold">Order Key</font></td> <td><font face="Arial, Helvetica, sans-serif" class="bold" color="#0000FF">User Email</font></td> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"vouchers"); $f2=mysql_result($result,$i,"deal_id"); $f3=mysql_result($result,$i,"order_id"); $f4=mysql_result($result,$i,"order_key"); $f5=mysql_result($result,$i,"user_email"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> </tr> <?php $i++; } ?> </body> </html> Oi pessoal tudo bem? Estou tendo aqui um problema que não percebo porque esta acontecendo, a conexão é feita com sucesso a BD mas nao Retorna nenhuma informação, Alguma dica? Agradecido desde já 🙂 Edited April 23, 2013 at 06:02 PM by brunoais tags code + geshi.
pikax Posted April 23, 2013 at 11:21 AM Report #504508 Posted April 23, 2013 at 11:21 AM Nao uses a funcao mysql*, usa antes o mysqli* Se usares mysqli* usa prepared statments Tens dados na tabela? Qual e' o valor do $code. Usa as tags para por codigo sff. Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
unrealmanel Posted April 23, 2013 at 11:26 AM Author Report #504511 Posted April 23, 2013 at 11:26 AM (edited) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action="test.php"> Voucher Code <input type="text" name="textfield" value ='' /> <input type="submit" name="Get Details" value="Get Details" /> </label> </p> </form> </body> </html> Sim tenho dados na BD o Valor do $code Vai até 20 que é um numero de codigo de voucher digitado no form acima Edited April 23, 2013 at 06:06 PM by brunoais geshi
pikax Posted April 23, 2013 at 11:40 AM Report #504515 Posted April 23, 2013 at 11:40 AM (edited) o campo code na tabela e' uma string, certo? Edited April 23, 2013 at 11:40 AM by pikax Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
unrealmanel Posted April 23, 2013 at 11:42 AM Author Report #504516 Posted April 23, 2013 at 11:42 AM certo
HappyHippyHippo Posted April 23, 2013 at 11:48 AM Report #504519 Posted April 23, 2013 at 11:48 AM (edited) $result=mysql_query($query) or die(mysql_error()); Edited April 23, 2013 at 11:51 AM by HappyHippyHippo IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
unrealmanel Posted April 23, 2013 at 01:11 PM Author Report #504529 Posted April 23, 2013 at 01:11 PM Esta me retornando o erro Query was empty :/
HappyHippyHippo Posted April 23, 2013 at 01:33 PM Report #504533 Posted April 23, 2013 at 01:33 PM Esta me retornando o erro Query was empty :/ ups ... queria que fizesses isso era no query anterior $query = mysql_query("SELECT * FROM wp_wpdeals_permissions WHERE code = '{$code}' ") or die(mysql_error()); IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now