Jump to content

Simple query


grlayouts

Recommended Posts

i have a cell in my database like

 


Stats

100-10-3

 

and i want to update that with my code

 


   $details = 100 . '-' . 10 . '-' . 3; 
   $sql = "UPDATE usertable SET uSkillsMax=$details";

 

but my database updates instead of 100-10-3 it says 87? which is doing the math?

 

any way to fix this?

Link to comment
Share on other sites

Few things..

1) Look into your database.  What "type" of field is "uSkillsMax"?  Is it an "int"?  If so change it to a "VARCHAR"

 

2) In this line you have the numbers listed so they are technically integers...

$details = 100 . '-' . 10 . '-' . 3; 

Instead do this..

$details = strval(100)."-".strval(10)."-".strval(3); 

OR this..

$details = "100"."-"."10"."-"."3"; 

Try those out and let me know what you come up with

Link to comment
Share on other sites

$details is a string and string data must be enclosed in single-quotes in a query, otherwise your string looks like a mathematical expression.

 

$sql = "UPDATE usertable SET uSkillsMax='$details'";

 

Edit: Don't make this harder than it really is.

Link to comment
Share on other sites

i dont get it?

I love how user "litebearer" takes the time to post you a link and if you look at the difference between his post time and that of the OP (grlayouts) he spent all of 1 minute 44 seconds looking at the link provided by litebearer only to quickly respond with a "i dont get it?"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.