Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Location
    Colorado
    Posts
    132
    Thanks
    7
    Thanked 1 Time in 1 Post

    Mysql Error I cant figure out

    I have this code
    PHP Code:
    <?
    include("connect2.php");
    $users = array("Josh");
    /*$users = array("88934910","aiden","aiden2","alberto13g","alexxx","alix","Andrew","April","AshleyDawn",
    "atopogigio","awesome","awinter925","b3nnic3","billym","boogle","Brittney","brujo22388","caligurl719",
    "carter","cbkman","ccbccb","Charlie","chasebadkids","chelsea","chris16","Cooper","corina75",
    "daikingp","DAnielle126","Danny","dannybat","darkcircuit","DarkFlash","deathgurl75","demo","Demo1",
    "Derek","dfg","dica","dica16","dicaggg","djclaywmts","doggy","donedid","donkey","dork","dsf","dude",
    "eleanore8","Eternal","eve04","feature","fets57","foreal","frankh","garth","Glen","google",
    "greatness","greg","gtmuscle03","GUGKahdaver","hack","handsomedreams","haze","howdy","huh",
    "ibeloshi","iiswhois","isfdjjjcmsd","itsme","jacked","james","jason","Jasons10190","jcrewhond0805",
    "jenna","joetest","Josh","josh","josh2","JoshH","juan369","kenny","lagueitta","Lazaro","lexxums",
    "lissaanne","ljcus10","lucky7","LytesOut","m0rtis","m24life69","madiel","Matt","mattambrogio",
    "matthew","mattx","mdubs","mdubs0","melvin","meme","mememe","merm","metoo","michele","Michele",
    "milenko","mizwingzz","msjunk","my69colla","myersdeep","mymade123","nancip","nessa","nessy_poo",
    "New","new","newguy","newness","nhoj","nickyg","nike21","nikki1127","Nikko","njdevil","ohyeah",
    "oisdfj39d","Omar","ommm","OSaF6","papastone","patricia","phil06","poem","presidentbushe",
    "princessstar","pugzilla","realone","red_roses4","ROb510","Rob610","Roman","roman","romochick100",
    "rosi","ryansan","sam","scotter","scubaahood","sexibeachbum","Shadedhunter","shortester101",
    "snailpace","snowfall","socca","Spencer","steffy1","STEVEN CODY","stevie","straycatmandy","Sue",
    "superness","sweetness","tardgenius","tburgesn","TESS","test","test3","test9999","test12345",
    "testing","tez","TheHypnotic","tkx1453","track1","track6","track12","trackus","twisted_memories_05",
    "Tyler","u3sanders","uaktags","Vietnamese","vintage","watchit","WiSEGuYs954","xfeat","xoalycole",
    "xpm3","ya","yannick"); */
    for($i=0;$i<count($users);$i++)
    {
        
    $sql "SELECT * FROM ".$users[$i]."";
        
    $result mysql_query($sql);
        if(
    mysql_num_rows($result) == 0)
        {
            echo 
    "<br>".$users[$i];
        }
        else
        {
            
    $user $users[$i];
            
    $pass mysql_result($result0"password");
            
    $sql2 "INSERT INTO users (id,username,password) VALUES ('NULL','$user','$pass')";
            
    $result2 mysql_query($sql2);
            
    $sql2 "SELECT id FROM users WHERE username = '$user'";
            
    $result2 mysql_query($sql2);
            
    $uid mysql_result($result2,0,"id");
            
    //enter all hits into DB
            
    while($hitrow mysql_fetch_array($result))
            {
                
    $RID "NULL"//It auto increments
                
    $Current mysql_real_escape_string($hitrow['Current']);
                
    $Referrer mysql_real_escape_string($hitrow['Referrer']);
                
    $Name mysql_real_escape_string($hitrow['Name']);
                
    $Picture mysql_real_escape_string($hitrow['Picture']);
                
    $Login mysql_real_escape_string($hitrow['Login']);
                
    $Cookie mysql_real_escape_string($hitrow['Date']);
                
    $read mysql_real_escape_string($hitrow['read']);
                
    $logins mysql_real_escape_string($hitrow['logins']);
                
    $email mysql_real_escape_string($hitrow['email']);
                
    $ip mysql_real_escape_string($hitrow['ip']);
                
    $info mysql_real_escape_string($hitrow ['info']);
                
    $rowname mysql_real_escape_string($hitrow['rowname']);
                
    $sql3 "INSERT INTO hits (RID,uid,Username,password,Current,Referrer,Name,Picture,Login,Cookie,Date,read,login,email,ip,info,rowname) VALUES ('NULL','$uid','$user','$pass','$Current','$Referrer','$Name','$Picture','$Login','$Cookie','$Date','$read','$logins','$email','$ip','$info','$rowname')";
                
    mysql_query($sql3) or die(mysql_error());
            }
        }
    }
    ?>
    Its not inserting the second query... Heres the error I get
    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 'read,login,email,ip,info,rowname) VALUES ('NULL','1','Josh','rose615','http://pr' at line 1
    I have no idea whats wrong, help please?
    -bubbles

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Do you have a field named Date? That is a reserved word and will mess you up good.

    For this reason I like to use suffixes on my field names-- plus it helps keep variables organized. For example, instead of "Date", try "create_dt".

    p.s. you really should be checking every one of your queries to make sure they didn't fail-- you are only checking one of three.

  • #3
    Regular Coder
    Join Date
    Sep 2006
    Location
    Colorado
    Posts
    132
    Thanks
    7
    Thanked 1 Time in 1 Post
    Yes, I do have a field named date.

    The reason I dont check the other queries is I know they are working... I only die(mysql_error()) if something isnt working right.
    -bubbles


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •