Forum Moderators: coopster

Message Too Old, No Replies

PHP and Insert Into

         

Modern Merlin

10:25 pm on Jul 18, 2008 (gmt 0)

10+ Year Member



I have a flash movie that I am pulling data from. The data is being passed to PHP. That part is working. Now the only problem I am having is that the insert statement in my PHP isnt working.

Here is the last re-write of my code:


$SQL = mysql_query("SELECT * FROM account WHERE login ='".$login."'");
$result = mysql_fetch_array($SQL, $conn);


$acct_id = $result['id'];


$insertSQL = "INSERT INTO character VALUES ('', '$acct_id', '$charname', '', '', '', '', '', '', '', '', '', '', '', '', '', '$cityname', '', '')";


$rs = mysql_query($insertSQL,$conn);


if($rs){
echo '&result=success&';
}else{
echo '&result=failure&';
}

Any help would be greatly appreciated!

MM

janharders

10:41 pm on Jul 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



what exactly is not working? is there an error? what does mysql_error() say after the insert? can you post the table-definition of the character-table?

btw, you really should escape all the data you send to mysql ... it'd be easy to inject something into your sql, since most of the data is probably user-generated.

ah, now I see it. I think, character is a reserved word. write it in backicks (`) and you should be fine.

Modern Merlin

11:07 pm on Jul 18, 2008 (gmt 0)

10+ Year Member



LOL yeah I figured it out and was jsut coming to say it in here when I saw your post. Thank you so much for your response. I just changed the table name :)

MM