Sql Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Sql Error

    Ok, I'm coding a new script, but experiencing a problem with sql.
    Code:
    <?
    include("../config.php");
    include("../style.php");
    $site = $_POST[&#39;site&#39;];
    $site=strtolower($site);
    $query = "SELECT * FROM `users` WHERE `site` = &#39;".$site."&#39;";
    $result = mysql_query($query);
    $otvet = mysql_fetch_array($result);
    if($otvet[&#39;site&#39;]){
    echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
    ?>
    <!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" xml:lang="en" >
    
    <?
    echo "<head>\n";
    echo "<title>Login@".$site."</title>\n";
    echo $style;
    echo "<meta name=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";  
    echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />\n";
    echo "<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />\n";
    echo "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n";
    echo "</head>\n";
    echo "<body>\n";
    $userquery = "SELECT * FROM `users` WHERE site=&#39;".$site."&#39;, `name` = &#39;".$name."&#39; AND pass = LIKE &#39;".$pass."&#39;";
    $userresult = mysql_query($userquery);
    $userotvet = mysql_fetch_array($userresult);
    if($userotvet[&#39;name&#39;]){
    echo "Hi ".$name.", welcome to ".$site." :)
    \n";
    echo "<a href=\"enter.php?site=$site&amp;name=$name&amp;pass=$pass\">Enter ".$site."</a>\n";
    echo "<div class=\"foot\">\n";
    echo "&copy; WapX ".date ("Y")."";
    echo "</div>\n";
    echo "</body>\n";
    echo "</html>\n";
    exit();
    }
    else
    {
    echo "Not Logged in.
    \n";
    echo "Please register or try loging in again.
    \n";
    echo "<a href=\"index.php?site=$site\">Home</a>\n";
    echo "<div class=\"foot\">\n";
    echo "&copy; WapX ".date ("Y")."";
    echo "</div>\n";
    echo "</body>\n";
    echo "</html>\n";
    exit();
    }
    }
    else
    {
    header("location: error/notfound.php");
    exit();
    }
    ?>
    SQL
    Code:
    CREATE TABLE `users` (
      `id` int(4) NOT NULL auto_increment,
      `site` varchar(15) NOT NULL default &#39;&#39;,
      `name` varchar(15) NOT NULL default &#39;&#39;,
      `pass` varchar(30) NOT NULL default &#39;&#39;,
      `birthday` varchar(15) NOT NULL default &#39;&#39;,
      `sex` varchar(8) NOT NULL default &#39;&#39;,
      `country` varchar(20) NOT NULL default &#39;&#39;,
      `province` varchar(20) NOT NULL default &#39;&#39;,
      `level` char(1) NOT NULL default &#39;0&#39;,
      `rtime` varchar(30) NOT NULL default &#39;&#39;,
      `ip` text,
      `soft` text,
      PRIMARY KEY  (`id`),
      UNIQUE KEY `name` (`name`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
    Error I&#39;m getting
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/user/public_html/script/sites/login.php on line 61[/b]
    So theres something wrong with this peace of coding
    $userquery = "SELECT * FROM `users` WHERE site=&#39;".$site."&#39;, `name` = &#39;".$name."&#39; AND pass = LIKE &#39;".$pass."&#39;";
    $userresult = mysql_query($userquery);
    $userotvet = mysql_fetch_array($userresult);


    Someone please correct me on fixing this error?

    Click here!!!

    #2
    maybe instead this
    Code:
    $userquery = "SELECT * FROM `users` WHERE site=&#39;".$site."&#39;, `name` = &#39;".$name."&#39; AND pass = LIKE &#39;".$pass."&#39;";
    this would work
    Code:
    $userquery = "SELECT * FROM `users` WHERE site=&#39;".$site."&#39;, `name` = &#39;".$name."&#39; AND pass = &#39;".$pass."&#39;";
    It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt.
    ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ !
    ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.
    キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

    Comment


      #3
      I&#39;m getting
      Code:
      Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/spiderw/public_html/wapx/sites/login.php on line 61
      Not Logged in.
      Please register or try loging in again.

      Click here!!!

      Comment


        #4
        Code:
        $userquery = "mysql_fetch_array(mysql_query("SELECT (*) FROM `users` WHERE site=&#39;".$site."&#39;, `name` = &#39;".$name."&#39; AND pass = LIKE &#39;".$pass."&#39;"));
        try this prob wont work nowin mu luck
        Want something coded email me at sales@webnwaphost.com for a prices.




        Comment


          #5
          Ok, I&#39;m coding a new script, but experiencing a problem with sql.
          Code:
          <?
          include("../config.php");
          include("../style.php");
          $site = $_POST[&#39;site&#39;];
          $site=strtolower($site);
          $query = "SELECT * FROM `users` WHERE `site` = &#39;".$site."&#39;";
          $result = mysql_query($query);
          $otvet = mysql_fetch_array($result);
          if($otvet[&#39;site&#39;]){
          echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
          ?>
          <!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" xml:lang="en" >
          
          <?
          echo "<head>\n";
          echo "<title>Login@".$site."</title>\n";
          echo $style;
          echo "<meta name=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";  
          echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />\n";
          echo "<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />\n";
          echo "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n";
          echo "</head>\n";
          echo "<body>\n";
          $userquery = "SELECT * FROM `users` WHERE site=&#39;".$site."&#39;, `name` = &#39;".$name."&#39; AND pass = LIKE &#39;".$pass."&#39;";
          $userresult = mysql_query($userquery);
          $userotvet = mysql_fetch_array($userresult);
          if($userotvet[&#39;name&#39;]){
          echo "Hi ".$name.", welcome to ".$site." :)
          \n";
          echo "<a href=\"enter.php?site=$site&amp;name=$name&amp;pass=$pass\">Enter ".$site."</a>\n";
          echo "<div class=\"foot\">\n";
          echo "&copy; WapX ".date ("Y")."";
          echo "</div>\n";
          echo "</body>\n";
          echo "</html>\n";
          exit();
          }
          else
          {
          echo "Not Logged in.
          \n";
          echo "Please register or try loging in again.
          \n";
          echo "<a href=\"index.php?site=$site\">Home</a>\n";
          echo "<div class=\"foot\">\n";
          echo "&copy; WapX ".date ("Y")."";
          echo "</div>\n";
          echo "</body>\n";
          echo "</html>\n";
          exit();
          }
          }
          else
          {
          header("location: error/notfound.php");
          exit();
          }
          ?>
          SQL
          Code:
          CREATE TABLE `users` (
            `id` int(4) NOT NULL auto_increment,
            `site` varchar(15) NOT NULL default &#39;&#39;,
            `name` varchar(15) NOT NULL default &#39;&#39;,
            `pass` varchar(30) NOT NULL default &#39;&#39;,
            `birthday` varchar(15) NOT NULL default &#39;&#39;,
            `sex` varchar(8) NOT NULL default &#39;&#39;,
            `country` varchar(20) NOT NULL default &#39;&#39;,
            `province` varchar(20) NOT NULL default &#39;&#39;,
            `level` char(1) NOT NULL default &#39;0&#39;,
            `rtime` varchar(30) NOT NULL default &#39;&#39;,
            `ip` text,
            `soft` text,
            PRIMARY KEY  (`id`),
            UNIQUE KEY `name` (`name`)
          ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
          Error I&#39;m getting

          So theres something wrong with this peace of coding
          $userquery = "SELECT * FROM `users` WHERE site=&#39;".$site."&#39;, `name` = &#39;".$name."&#39; AND pass = LIKE &#39;".$pass."&#39;";
          $userresult = mysql_query($userquery);
          $userotvet = mysql_fetch_array($userresult);


          Someone please correct me on fixing this error?[/b]
          $userquery = "SELECT * FROM `users` WHERE site=&#39;".$site."&#39;, `name` = &#39;".$name."&#39; AND pass = LIKE &#39;".$pass."&#39;";

          1.You cant use comma , after WHERE clause in mysql query,thatsy the you are getting error

          2.declare the $name and $pass variables first then they are allowed to be used like
          Code:
          $name = $_POST[&#39;name&#39;];
          $pass = $_POST[&#39;pass&#39;];
          its not good to use LIKE mysql operation in case of password as input password need to be same to the saved password in the database
          this query is good
          Code:
          $a = mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM `users` WHERE site=&#39;".$site."&#39; AND`name` = &#39;".$name."&#39; AND pass = &#39;".$pass."&#39;"));
          if($a[0]=="1")
          {}
          else
          {}

          Comment


            #6
            Ah, don&#39;t worry, i think i managed.
            Code:
            $name= strtolower($name);
            $loginquery = "SELECT * FROM `users` WHERE `site` = &#39;".$site."&#39; AND `name` = &#39;".$name."&#39; AND `pass` LIKE &#39;".$pass."&#39; ";
            $loginresult = mysql_query($loginquery);
            $loginotvet = mysql_fetch_array($loginresult);
            if($loginotvet[&#39;name&#39;]){
            And i forgot to
            $name=$_POST["name"];
            $pass=$_POST["pass"];
            Think I&#39;m sorted now.
            Thank you.

            Click here!!!

            Comment


              #7
              u might wanna secure user posted variables with mysql_real_escape_string() before you use them in a query

              Comment


                #8
                lee is that yu lee from ldn ?
                Want something coded email me at sales@webnwaphost.com for a prices.




                Comment


                  #9
                  dunno who ur on about so no im guessing not

                  Comment


                    #10
                    wtf..sm1 playn again

                    Comment


                      #11
                      = huh why them in there ?

                      Code:
                      $clogin = mysql_fetch_array(mysql_query("SELECT (*) FROM usersed WHERE id=&#39;".$sit_id."&#39;"));
                      Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                      Visit: WapMasterz Coming Back Soon!
                      _______
                      SCRIPTS FOR SALE BY SUBZERO
                      Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                      FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                      _______
                      Info & Tips
                      php.net
                      w3schools.com

                      Comment

                      Working...
                      X