connecting a database using godaddy

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nicoletsii
    New Member
    • Oct 2008
    • 15

    connecting a database using godaddy

    I have been tring to connect to my database using godaddy i keep getting an error#1064 you have an error in your SQL syntax check the manual that corresponds to your MYSQL server version for the right syntax to use near
    [PHP]<?php
    // connect to database
    $hostname = 'h41mysql47'.se cure.net';[/PHP]
    How can I fix this?
    Last edited by Atli; Oct 8 '08, 10:21 PM. Reason: Added [code] tags.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    We need more info to be able to help you at all.

    To start with, we need to see the code you are using to connect to your database.

    Comment

    • nicoletsii
      New Member
      • Oct 2008
      • 15

      #3
      sorry here is the code
      [PHP]<?php
      //connect to database
      $hostname = 'h41mysql47.sec ureserver.net';
      $username = ' username';
      $password = 'userpass';
      $dbname = 'dbname';
      $usertable = 'usertable';
      $yourfield = ' yourfield';

      mysql_connect($ hostname, $username, $password) OR DIE
      (' unable to connect to database! please try again later.');
      mysql_select_db ($databasename) ;

      $query = 'select * from $usertable';
      $result = mysql_query ($query);
      if ($result) {
      while ($row = mysql_fetch-array ($result)) {
      $name = $row ['$parts'];
      echo 'name:'. $name;
      }
      }
      ?>[/PHP]

      When I use this code it gives me the error
      #1064 you have an error in you r SQL Synax, check the manual that corresponds to you mySQL sever version for the right synax to use near '<?php
      //connect to database
      $hostname = 'h41mysql47.sec uresever.net at line1
      This is the code & the error that i'm getting & godaddy Tech. support gave me this code & would not help my out any futher. I'm at the point to were I'm ready to get rid of godaddy.
      What do you think?
      Last edited by Atli; Oct 9 '08, 06:07 PM. Reason: Added [code] tags.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        What exactly are you doing with this code?
        The error would suggest you are using it as a SQL query?

        This is PHP code, meant to be executed as PHP code, not as a SQL query.
        It would typically be placed in a .php file on a web-server and execute via a browser.

        P.S.
        Please use [code] tags when posting code examples.

        &#91;code&#9 3; ...Code goes here.. &#91;/code&#93;

        Thank you.
        Moderator

        Comment

        • nicoletsii
          New Member
          • Oct 2008
          • 15

          #5
          Originally posted by Atli
          What exactly are you doing with this code?
          The error would suggest you are using it as a SQL query?

          This is PHP code, meant to be executed as PHP code, not as a SQL query.
          It would typically be placed in a .php file on a web-server and execute via a browser.

          P.S.
          Please use [code] tags when posting code examples.

          [code] ...Code goes here.. &#91;/code]

          Thank you.
          Moderator
          How would you do that? As you can tell I have no clue about servers.

          Comment

          • nicoletsii
            New Member
            • Oct 2008
            • 15

            #6
            Originally posted by nicoletsii
            How would you do that? As you can tell I have no clue about servers.
            I'm using go daddy's database mysql & they are saying that you can use in conjuction with php & other scripting languages.

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              Originally posted by nicoletsii
              How would you do that? As you can tell I have no clue about servers.
              Ok.

              Firstly, why are you attempting this?
              These sort of connections are usually used with PHP web-applications, and by the sounds of it, you are not developing such an application.

              If this is just a test, something your trying to learn, I would recommend finding a tutorial about the basics of web-development first.

              There is really no point in learning how this code works until you have learned that.
              It shouldn't take long tho and there is no shortage of material on this subject online.

              Comment

              • nicoletsii
                New Member
                • Oct 2008
                • 15

                #8
                I do have an associates degree in web development but I have never had such problems connecting to a database. c I used dreamweaver to create my site & go daddy for my hosting server & for some reason u can't use the database in dreamweaver in godaddy. So I created a database in godaddy and was trying to connect it to my web site that way. Do you have any solutions to this problem? I 'm was just going to change my hosting server. I've done alot of research and have not found a solution. When I called godaddy that is the code they told me to use that is why I was trying it. Really i have 2 web sites right now that don't have a database. What do you think I should do?

                Comment

                • nomad
                  Recognized Expert Contributor
                  • Mar 2007
                  • 664

                  #9
                  Originally posted by nicoletsii
                  I do have an associates degree in web development but I have never had such problems connecting to a database. c I used dreamweaver to create my site & go daddy for my hosting server & for some reason u can't use the database in dreamweaver in godaddy. So I created a database in godaddy and was trying to connect it to my web site that way. Do you have any solutions to this problem? I 'm was just going to change my hosting server. I've done alot of research and have not found a solution. When I called godaddy that is the code they told me to use that is why I was trying it. Really i have 2 web sites right now that don't have a database. What do you think I should do?
                  have you enabled the gui script that will all your site to read php?
                  if not it should be in your host settings.
                  nomad

                  Comment

                  • Atli
                    Recognized Expert Expert
                    • Nov 2006
                    • 5062

                    #10
                    Originally posted by nicoletsii
                    I do have an associates degree in web development but I have never had such problems connecting to a database. c I used dreamweaver to create my site & go daddy for my hosting server & for some reason u can't use the database in dreamweaver in godaddy.
                    I don't really know what Dreamweaver is doing behind the scenes so I can't really say what it's doing wrong, but I know that if you can actually edit the code itself it shouldn't be hard to fix.

                    I actually took a couple of "Web-Development" courses in school a few years back that were all about Dreamweaver. If that is anything like what you are doing, then I would strongly recommend trying to learn the actual code behind it, not just how to create it using Dreamweaver.

                    Being dependent on proprietary GUI tools and wizards, like Dreamweaver, to create your web-pages is very very bad, at least if you don't know what it is that is happening behind the scenes. You are basically limiting yourself to the features Adobe figures should be automated.

                    Making your code do whatever you want is easy. Making Dreamweaver do anything beyond the basics is next to impossible.

                    Comment

                    • nicoletsii
                      New Member
                      • Oct 2008
                      • 15

                      #11
                      Actually I do know alot about the coding so I do more coding then just creating. I really don't think the problem is with dreamweaver. I 'm really thinking that the problem is with my hosting server ( godaddy). Do you know anything about godaddy? See someone else within the company had the web site set on linux instead of windows. So I changed it back to windows & they give you 3 different was to create the database MySQL, Access and & SQL server so I was trying to create the database with one of them because godaddy told me that dreamweaver & godaddy don't work together to create the database in dreamweaver for some reason I can't remember & I had to use the database feature in godaddy. That is what I 'm trying to do. So if you have any ideas on which one to use that would be great I have tried all of them but have not got any of them to work so far. If you have any ideas or advice it would be great. The access one seemed to be the easiest, for the simple database I need but I have yet to get it to work, there something wrong within the dsn that it won't let me upload the database from my hard drive. MySQL I can't get the SQL coding right. I'm really thinking about just changing hosting server. Because then the database can be created in dreamweaver. Once I research about these issue alot of people have had the same issues with godaddy. Anyways if there is anything that you could help with that would be really great. Thank you for all the advice you have given already.

                      Comment

                      • ak1dnar
                        Recognized Expert Top Contributor
                        • Jan 2007
                        • 1584

                        #12
                        If you using Godaddy's shared hosting package you can't access the provided mysql server from your local machine. what you can do is install mysql server on your local machine and create your application on the same machine. Then you can move your application and the database back to the Godaddy server. On the hosting control panel you can find the "PhpMyAdmin " tool which you can use for maintaining mysql server databases.

                        Comment

                        • nicoletsii
                          New Member
                          • Oct 2008
                          • 15

                          #13
                          Can you use access to create the database? & use microsoft access? I have tried but can not upload it or get the dsn right. Do you know anything about that? What am I doing wroong? They also have SQL Server but i can not insert columns in it & really i'm lost with that.

                          Comment

                          • ak1dnar
                            Recognized Expert Top Contributor
                            • Jan 2007
                            • 1584

                            #14
                            Originally posted by nicoletsii
                            Can you use access to create the database? & use microsoft access? I have tried but can not upload it or get the dsn right. Do you know anything about that? What am I doing wroong? They also have SQL Server but i can not insert columns in it & really i'm lost with that.
                            MS Access is a database file, so upload your ms access database file to the hosting server. you can create it LOCALLY and Then MOVE it to the server.

                            I think I asked you to use MySQL, not Ms Access. If you really need to use access read the documentation on http://php.net/odbc

                            And here is a Sample Source Code that you can get started. but I highly recommend you to stick with mysql instead of ms access.

                            Comment

                            • nicoletsii
                              New Member
                              • Oct 2008
                              • 15

                              #15
                              Sorry I already had the database created in Access that's why i asked. Were can I safely download mysql server to install it?

                              Comment

                              Working...