ID:1180655
 
(See the best response by Stephen001.)
It's been a while since I've used MySQL, but I've been looking into it again as the benefits of using it for saving in Byond games seems worth the effort. I'm doing things one step at a time so I fully understand what my code is doing as opposed to just using someone elses work.

Code:
/*
Server: localhost
Database: byond
Table: variables
Columns: ckey, hp, cash

I started off by manually inserting a row into my table with my ckey, hp and cash
using phpmyadmin.
*/


mob
var
hp = 10
cash = 50
verb
Save()
Query("INSERT INTO `variables` (`ckey`,`hp`, `cash`) VALUES ('[ckey]','[hp]','[cash]');")
// Query("UPDATE `variables` SET `hp`='[hp]',`cash`='[cash]' WHERE `ckey`='[ckey]';")


Problem description: After changing my variables, I can update the existing row with my ckey without any bother. Using `INSERT INTO` on the other hand does not create a new row in the table.

Can you show us the table definition for the variables table?
I assume this is what you mean? Not quite as neat as the table it displayed it to me in.

Field - Type - Null - Key - Default - Extra

ckey - varchar(25) - NO - PRI - NULL
hp - varchar(15) - NO - - NULL
cash - varchar(15) - NO - - NULL
Best response
If I were to guess, the issue is your primary key. A primary key must be unique to that row, so in your definition you cannot have two rows with the same ckey. Did you already have an existing row for that ckey when you attempted an insert?
I did yes, seems I forgot the basics. After adding a random string to my ckey, it inserts a new row just fine. Thanks Stephen.