Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SoloChristian · Oct 04, 2010 at 06:04 AM · updateruntimedatabasemysql

Update mySQL at game runtime ???

I have been using the log in tutorial on the Unity forum and the phphandler scripts up till now with no issues. But I seem to be stuck when it comes to updating the database at run time. I'm pretty sure its my PHP command. See Below:

//////////////////////////////////////////////////////////////////////////////////

$SQL = "SELECT * FROM players WHERE gameName = ' " . $gameName . " ' AND playerPassword = ' " . $playerPassword . " ';";

mysql_query( $SQL ) or die( mysql_error() );

$query = "UPDATE players SET strength = ' " . $strength . " ',' " strengthMax = ' " . $strengthMax . " ',' " agility = ' " . $agility . " ',' " agilityMax = ' " . $agilityMax . " ',' " dexterity = ' " . $dexterity . " ',' " dexterityMax = ' " . $dexterityMax . " ',' " stamina = ' " . $stamina . " ',' " staminaMax = ' " . $staminaMax . " ',' " health = ' " . $health . " ',' " healthMax = ' " . $healthMax . " ',' " intelligence = ' " . $intelligence . " ',' " intelligenceMax = ' " . $intelligenceMax . " ',' " comprehension = ' " . $comprehension . " ',' " comprehensionMax = ' " . $comprehensionMax . " ',' " psyche = ' " . $psyche . " ',' " psycheMax = ' " . $psycheMax . " ',' " mana = ' " . $mana . " ',' " manaMax = ' " . $manaMax . " ',' " lastPosX = ' " . $lastPosX . " ',' " lastPosY = ' " . $lastPosY . " ',' " lastPosZ = ' " . $lastPosZ . " ',' " anchorHead = ' " . $anchorHead . " ',' " anchorLeftHand = ' " . $anchorLeftHand . " ',' " anchorRightHand = ' " . $anchorRightHand . " ',' " anchorChest = ' " . $anchorChest . " ',' " anchorPelvis = ' " . $anchorPelvis . " ',' " anchorRightBicep = ' " . $anchorRightBicep . " ',' " anchorRightForeArm = ' " . $anchorRightForeArm . " ',' " anchorRightWrist = ' " . $anchorRightWrist . " ',' " anchorLeftBicep = ' " . $anchorLeftBicep . " ',' " anchorLeftForeArm = ' " . $anchorLeftForeArm . " ',' " anchorLeftWrist = ' " . $anchorLeftWrist . " ',' " anchorRightThigh = ' " . $anchorRightThigh . " ',' " anchorRightCalf = ' " . $anchorRightCalf . " ',' " anchorRightAnkle = ' " . $anchorRightAnkle . " ',' " anchorLeftThigh = ' " . $anchorLeftThigh . " ',' " anchorLeftCalf = ' " . $anchorLeftCalf . " ',' " anchorLeftAnkle = ' " . $anchorLeftAnkle . " ',' " defaultHair = ' " . $defaultHair . " ',' " XPstrength = ' " . $XPstrength . " ',' " XPagility = ' " . $XPagility . " ',' " XPdexterity = ' " . $XPdexterity . " ',' " XPstamina = ' " . $XPstamina . " ',' " XPhealth = ' " . $XPhealth . " ',' "
XPintelligence = ' " . $XPintelligence . " ',' " XPcomprehension = ' " . $XPcomprehension . " ',' " XPpsyche = ' " . $XPpsyche . " ',' " XPmana = ' " . $XPmana . " ',' " hitPoints = ' " . $hitPoints . " ',' " hitPointsMax = ' " . $hitPointsMax . " ',' " basePhyAtk = ' " . $basePhyAtk . " ',' " basePhyDef = ' " . $basePhyDef . " ',' " baseShotAtk = ' " . $baseShotAtk . " ',' " baseMenAtk = ' " . $baseMenAtk . " ',' " baseMenDef = ' " . $baseMenDef . " ',' " speedMod = ' " . $speedMod . " ' WHERE gameName = ' " . $gameName . " ' AND playerPassword = ' " . $playerPassword . " ';";

///////////////////////////////////////////////////////////////////////////////

I can't seem to find the Syntax Error. Are ther any tutorials show mySQL updating at runtime for Unity??

Thanxs Christian

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Adam Rademacher · Oct 04, 2010 at 06:12 AM

You are trading off your quotations too often. It should follow a pattern like this:

$query ="UPDATE players SET strength = ' " . $strength . " ', strengthMax = '" . $strengthMax . 
(//)
speedMod = ' " . $speedMod . " ' "  WHERE " gameName = ' " . $gameName . " ' AND  playerPassword = ' " . $playerPassword . " '; " ;

In short, you ended up trying to assign the SQL column $strengthMax to a php variable "strength" (backwards from what it should be) in your sql command...if you fix all that syntax it should work appropriately. If you write your php in a program like Notepad++ or Dreamweaver, it should be much easier to see where your syntax errors are.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SoloChristian · Oct 06, 2010 at 09:06 AM 0
Share

Thanxs I got rapidPHP and that helped see my syntax error. The final version of the function is on :

http://forum.unity3d.com/threads/62625-Looking-for-an-example-of-PHP-Using-mySQL-Update-command-during-game-runtime.?p=401708#post401708

avatar image
0

Answer by dyrwoolf · Jan 03, 2012 at 01:44 PM

If ur doing this make sure to clean the $varibles to prevent SQLInjections

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Runtime communication with database 0 Answers

PHP MySQL - How to insert row of data 1 Answer

Export objects to a .3DS file at runtime 1 Answer

when i build my application i get ,some dll error 2 Answers

Database connection on PhPMyAdmin 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges