Jump to content

Problem when mysql queries


zixxonx

Recommended Posts

    local query = mysql_query(baza, "SELECT * FROM mapy WHERE map="..mapName) 
    if(result and mysql_num_rows( result ) > 0) then 
        local rows = mysql_fetch_assoc(result) 
        mapinfo.map.firstplayed = rows['firsplayed'] or timestamp 
        mapinfo.map.played = rows['total'] or 0 
        mapinfo.map.rate = rows['rate'] or 0 
        mysql_query(baza, "UPDATE mapy SET lastplayed="..timestamp..",total=total+1 WHERE map="..mapName.."") 
         
         
    else 
        local mapa = mapName 
        local autor = mapInfo.author 
        local baxza = mysql_query(baza, "INSERT INTO `mapy` (map, author, firstplayed, lastplayed) VALUES ("..mapa..", "..autor..", "..timestamp..", "..timestamp..")")  

That's a piece of my code. It should work good for me but it wont, when this query is executed:

    local query = mysql_query(baza, "SELECT * FROM mapy WHERE map="..mapName 

Im getting a mysql error: unknown column (there is my map name) in where clause, i did adding the map but it wont add cuz this error. Any1 know how can i do it?

Link to comment

Now that

local baxza = mysql_query(baza, "INSERT INTO `mapy` (map, author, firsplayed, lastplayed) VALUES ( map="..mapa..", \""..ktostworzyl.."\", "..timestamp..", "..timestamp..")")    

unknown column 'bandito' in field list

bandito is map name... i did

\""..map.."\"

but instead of putting nam name it puts 0 in map column... the type of column is "TEXT", should it be varchar or something? I'll try and edit this post.

edit: varchar isnt working...

edit2: i did it:

local baxza = mysql_query(baza, "INSERT INTO mapy (map, author, firsplayed, lastplayed) VALUES ( map=\""..mapa.."\", \""..ktostworzyl.."\", "..timestamp..", "..timestamp..")")  

and thats error

[2014-01-05 07:04:56] INFO: 1064 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 'the Dam, "Ransom", 1388905496, 1388905496)' at line 1

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...