pedro_15 Posted June 19, 2012 at 07:39 PM Report Share #464202 Posted June 19, 2012 at 07:39 PM Boa noite, Estou a fazer um projecto no dreamweaver e estou a ligar a um alojador de sites o 00webhost... Ja fiz a conexão á base de dados e tudo o mais, mas o login esta me dando um erro quando insiro o user e a senha,.. Que é este erro: Citação Unknown column 'pedro' in 'where clause' Se me puderem ajudar agradeço imenso. Deixo aqui o codigo do login: <?php require_once('../Connections/log.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['user'])) { $loginUsername=$_POST['user']; $password=$_POST['senha']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "bemvindo.php"; $MM_redirectLoginFailed = "erro.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_log, $log); $LoginRS__query=sprintf("SELECT `user`, senha FROM login WHERE `user`=%s AND senha=%s", GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $log) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();} //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <!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> <style type="text/css"> <!-- body { background-color: #4E5869; margin: 0; padding: 0; color: #000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 100%; line-height: 1.4; } /* ~~ Element/tag selectors ~~ */ ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */ padding: 0; margin: 0; } h1, h2, h3, h4, h5, h6, p { margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */ padding-right: 15px; padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */ } a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */ border: none; } /* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */ a:link { color:#414958; text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */ } a:visited { color: #4E5869; text-decoration: underline; } a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */ text-decoration: none; } /* ~~ this container surrounds all other divs giving them their percentage-based width ~~ */ .container { width: 80%; max-width: 1260px;/* a max-width may be desirable to keep this layout from getting too wide on a large monitor. This keeps line length more readable. IE6 does not respect this declaration. */ min-width: 780px;/* a min-width may be desirable to keep this layout from getting too narrow. This keeps line length more readable in the side columns. IE6 does not respect this declaration. */ background-color: #FFF; margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout. It is not needed if you set the .container's width to 100%. */ } /* ~~the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo~~ */ .header { background-color: #6F7D94; } /* ~~ This is the layout information. ~~ 1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design. */ .content { padding: 10px 0; } /* ~~ This grouped selector gives the lists in the .content area space ~~ */ .content ul, .content ol { padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above. Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention. These may be adjusted as you wish. */ } /* ~~ The footer ~~ */ .footer { padding: 10px 0; background-color: #6F7D94; } /* ~~ miscellaneous float/clear classes ~~ */ .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */ float: right; margin-left: 8px; } .fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */ float: left; margin-right: 8px; } .clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */ clear:both; height:0; font-size: 1px; line-height: 0px; } --> </style> <link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> <link href="../SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" /> <script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script src="../SpryAssets/SpryValidationPassword.js" type="text/javascript"></script> </head> <body> <div class="container"> <div class="header"><a href="#"><img src="../anigif1.gif" alt="Insert Logo Here" name="Insert_logo" width="811" height="159" id="Insert_logo" style="background-color: #8090AB; display:block;" /></a> <!-- end .header --></div> <div class="content"> <h1> </h1> <div id="box"> <div class="content"> <h1> </h1> <form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>"> <p> </p> <p><span id="sprytextfield1">User <input type="text" name="user" id="user" /> <span class="textfieldRequiredMsg">A value is required.</span></span></p> <p> </p> <p><span id="sprypassword1">Senha <input type="password" name="senha" id="senha" /> <span class="passwordRequiredMsg">A value is required.</span></span></p> <p> </p> <p> <input type="submit" name="submit" id="submit" value="login" /> </p> </form> <!-- end .content --></div> <!-- end .container --></div> <p><!-- end .content --></p> </div> <div class="footer"> <p> <em><strong>Copyright © 2012 Pedro</strong></em></p> <!-- end .footer --></div> <!-- end .container --></div> <script type="text/javascript"> var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1"); </script> </body> </html> Link to comment Share on other sites More sharing options...
MASNathan Posted June 20, 2012 at 08:10 AM Report Share #464302 Posted June 20, 2012 at 08:10 AM experimenta colocar assim "SELECT `user`, senha FROM login WHERE `user`='%s' AND senha='%s'" Link to comment Share on other sites More sharing options...
tiagotavares Posted June 20, 2012 at 10:39 AM Report Share #464327 Posted June 20, 2012 at 10:39 AM Boas, no teu comando SQL estás a enviar o utilizador e a password sem estar entre plicas ' Espero ter ajudado Tiago Tavares Link to comment Share on other sites More sharing options...
Joel Luis Posted June 20, 2012 at 11:44 AM Report Share #464342 Posted June 20, 2012 at 11:44 AM Faz assim: "SELECT `user`, senha FROM login WHERE `user`='%s' AND senha='%s'" Faltava-te meter pelicas Link to comment Share on other sites More sharing options...
pedro_15 Posted June 20, 2012 at 12:18 PM Author Report Share #464345 Posted June 20, 2012 at 12:18 PM $LoginRS__query=sprintf("SELECT `user`, senha FROM login WHERE `user`='%s' AND senha='%s'" entao fica assim? Link to comment Share on other sites More sharing options...
pikax Posted June 20, 2012 at 12:26 PM Report Share #464348 Posted June 20, 2012 at 12:26 PM faz assim: $query="SELECT user,senha FROM login WHERE user='".$loginUsername."' AND senha='".$password."'"; 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." Link to comment Share on other sites More sharing options...
pedro_15 Posted June 20, 2012 at 12:26 PM Author Report Share #464349 Posted June 20, 2012 at 12:26 PM (edited) ficou assim: $LoginRS__query=sprintf("SELECT `user`, senha FROM login WHERE `user`='%s' AND senha='%s'" GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text")); --> so que essa linha aparece a vermelho Edited June 20, 2012 at 01:09 PM by scorch Adicionado Geshi. Link to comment Share on other sites More sharing options...
Joel Luis Posted June 20, 2012 at 12:41 PM Report Share #464351 Posted June 20, 2012 at 12:41 PM $LoginRS__query=sprintf("SELECT `user`, senha FROM login WHERE `user`='%s' AND senha='%s'" entao fica assim? Posta só a parte do código PHP aqui sff Link to comment Share on other sites More sharing options...
pedro_15 Posted June 20, 2012 at 12:59 PM Author Report Share #464353 Posted June 20, 2012 at 12:59 PM faz assim: $query="SELECT user,senha FROM login WHERE user='".$loginUsername."' AND senha='".$password."'"; e nao meto ai o $LoginRS atrras do query? Link to comment Share on other sites More sharing options...
MASNathan Posted June 20, 2012 at 01:33 PM Report Share #464356 Posted June 20, 2012 at 01:33 PM (edited) e nao meto ai o $LoginRS atrras do query? da forma como tu tens pões: $LoginRS__query="SELECT user,senha FROM login WHERE user='".$loginUsername."' AND senha='".$password."'"; Edited June 20, 2012 at 01:34 PM by MASNathan Link to comment Share on other sites More sharing options...
pedro_15 Posted June 20, 2012 at 01:44 PM Author Report Share #464359 Posted June 20, 2012 at 01:44 PM metendo esse codigo e trocando pelo outro da este erro: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'pedro'' AND senha=''pedro123''' at line 1 Link to comment Share on other sites More sharing options...
MASNathan Posted June 20, 2012 at 01:47 PM Report Share #464361 Posted June 20, 2012 at 01:47 PM faz echo da $LoginRS__query e tenta correr no servidor Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted June 20, 2012 at 02:31 PM Report Share #464376 Posted June 20, 2012 at 02:31 PM ... 'pedro'' AND senha=''pedro123''' estás a ver a quantidade de ' que estás a criar no comando SQL não estás ?? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
pedro_15 Posted June 20, 2012 at 02:45 PM Author Report Share #464383 Posted June 20, 2012 at 02:45 PM O erro era as ' ... ficava: $LoginRS__query=sprintf("SELECT user, senha FROM login WHERE user=%s AND senha=%s", Link to comment Share on other sites More sharing options...
MASNathan Posted June 20, 2012 at 02:51 PM Report Share #464385 Posted June 20, 2012 at 02:51 PM a cena era substituíres este pedaço de código $LoginRS__query=sprintf("SELECT `user`, senha FROM login WHERE `user`=%s AND senha=%s" GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text")); por este $LoginRS__query="SELECT user,senha FROM login WHERE user='".$loginUsername."' AND senha='".$password."'"; Link to comment Share on other sites More sharing options...
brunoais Posted June 20, 2012 at 04:13 PM Report Share #464411 Posted June 20, 2012 at 04:13 PM Só pelo código que li isto tresanda a Dreamweaver. O código tem vários erros e não cumpre muitas das regras de bom código. Entre as quais, os nomes das variáveis. "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%. Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted June 20, 2012 at 04:48 PM Report Share #464425 Posted June 20, 2012 at 04:48 PM Só pelo código que li isto tresanda a Dreamweaver. O código tem vários erros e não cumpre muitas das regras de bom código. Entre as quais, os nomes das variáveis. Dreamweaver ... lembro-me vagamente disso no meu caixote do lixo 1 Report IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
pikax Posted June 20, 2012 at 05:17 PM Report Share #464439 Posted June 20, 2012 at 05:17 PM Na minha humilde opiniao a IDE do Dreamweaver e' a melhor para php, claro que e' so' para codigo, ja nem me lembro de quando usei a janela de design 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." Link to comment Share on other sites More sharing options...
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