Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 nakoso · Aug 04, 2015 at 11:17 PM · errorphp

Error CS0119 but new keyword was used

I'm connecting to my database with this:

 IEnumerator ValidateLogin() {
         WWWForm form = new WWWForm();
         form.AddField( "myform_user", formUser );
         form.AddField( "myform_pass", formPassword );
         //error is here
         WWW www = new WWW(URL, form);
         yield return www;
         if (www.error != null) {
             print(www.error);
         } else {
             print("Test ok");
             formText = www.data;
             www.Dispose();
         }
     }
 

I'm getting the error: CS0119: Expression denotes a 'type', where a 'variable', 'value' or 'method group' was expected

On the line: WWW www = new WWW(URL, form);

I haven't done a lot of c# or unity web connectivity, and I'd appreciate the help. All of the other solutions I've found are because the programmer was missing the "new" keyword.

Comment
Add comment · Show 3
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 tanoshimi · Aug 05, 2015 at 09:11 PM 0
Share

Have you called this script URL.cs or form.cs, perchance?

avatar image Bonfire-Boy · Aug 06, 2015 at 03:09 AM 0
Share

It looks like URL is the name of a class, that would produce exactly this error. WWW's constructor needs a string as its first argument. So, @nakoso, where do you declare URL? What is it?

avatar image nakoso · Aug 07, 2015 at 01:41 PM 0
Share

I won't leave my website address, but otherwise the declaration is below.` string URL = "http://redacted/index.php";`

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by zach-r-d · Aug 04, 2015 at 11:20 PM

Pretty sure it's complaining about URL, not WWW. Try replacing URL with a literal string (or string variable) that is the URL to post the form to. Unless URL is the name of a string variable in all caps, in that case you should use lower case instead.

Comment
Add comment · Show 5 · 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 Bonfire-Boy · Aug 06, 2015 at 03:11 AM 0
Share

I don't think URL being the name of a string variable would produce this error. There's absolutely nothing wrong with having a variable name in caps.

avatar image zach-r-d · Aug 06, 2015 at 03:36 AM 0
Share

I think you misunderstood my intention there. The reason I wrote that last sentence was in case a variable was given the same identifier as a type in the same assembly (basically, what you and tanoshimi said). In such a case, the compiler may have resolved the identifier in that line of code to the type ins$$anonymous$$d of the variable; if it did, it would in fact produce exactly that error. The suggestion to use lowercase ins$$anonymous$$d was a quick way to resolve such a name collision.

Personally, I believe having a variable name in caps is acceptable if and only if the variable is a constant.

avatar image Bonfire-Boy · Aug 06, 2015 at 07:34 AM 0
Share

Ah, fair enough zach, thanks for clarifying. I've not encountered that particular kind of compiler-confusion so it's interesting to hear about.

However, na$$anonymous$$g conventions are very much subjective and local.

I've worked on projects where types would always be given Pascal case names, and so a name in all-uppercase (even initialisms) would actually indicate that it is a variable.

avatar image nakoso · Aug 07, 2015 at 01:38 PM 0
Share

I use all-caps for constants declared at the class level. URL is such a constant.

avatar image zach-r-d · Aug 07, 2015 at 07:41 PM 0
Share

Ah, got it. Could you try rena$$anonymous$$g it to FOR$$anonymous$$_POST_URL or something else, just in case there's a URL class that's causing a name collision? There's almost certainly no type with that name. If that doesn't fix it, then try rena$$anonymous$$g "form".

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Unity Null Reference Error 1 Answer

Unity PHP login always returning true 3 Answers

Getting Fatal Error 2030 using WWW in Flash 7 Answers

CommandInvokationFailure: Unable to install APK to device 6 Answers

Having difficulty with semicolons. 2 Answers


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