Table always returns empty result set despite inputs from php form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mike j
    New Member
    • Dec 2010
    • 3

    #1

    Table always returns empty result set despite inputs from php form

    Hi everyone,

    If anyone could help me with this problem I'd appreciate it greatly. Basically I have a simple table on my database. It is linked with a php form that I created on my site. The php form allows a person to input information on it (firstname, lastname, email) and then it gets stored in the database table. Now on my other server it works just fine but on this new one it doesn't, despite the fact that they both use phpmyadmin and a similar version of mysql. However the new server doesn't allow for innodb so I thought that perhaps that was the reason for the problem. However, I created the same table on my old server using a myisam engine and it still works. Furthermore, on my new server when I create my table and I try to click on the browse option I cannot and the cursor turns to a red x. I think this indicates that the table is empty. But again when, when I input information through the form I still get the same result, and it always says table returns empty result set.

    The table was created in a standard way. The table is called registeredusers . I just put in four fields (ru_id, firstname, lastname, email). ru_id is INT(11) auto increment, not null, primary key. The other fields are also all not null, varchar(50).

    Thanks
  • AutumnsDecay
    New Member
    • Mar 2008
    • 170

    #2
    Did you make the table using phpmyadmin?

    Also, try running an SQL query from phpmyadmin:

    Code:
    INSERT INTO `registeredusers` (firstname, lastname, email) VALUES ('Test', 'Person', 'someone@somewhere.com');
    If that works, then it's your PHP script. Note that some version of mysql require ` or ', and some will work with one and not the other.

    Comment

    • mike j
      New Member
      • Dec 2010
      • 3

      #3
      Hey AutumnsDecay,

      Thanks for the reply!

      I made the table using phpmyadmin. I did what you said and it amazingly entered those values into the fields and now I can click on the browse button (no red x now).

      However, when I fill in the form on my site the values don't get stored into table on the database. Now I have used the exact same table and exact same form on the exact same site but on a different server and it worked. So now I am kind of thinking the server is doing something.

      I'm not sure if this is the reason but the old server where the form worked had innodb as the storage system, but the new server does not have innodb on the server, it uses myisam. However, on the old server I did a test whereby I changed the storage system to myisam and it still worked.

      Comment

      • AutumnsDecay
        New Member
        • Mar 2008
        • 170

        #4
        In your PHP script, are you selecting which database table to use?

        It's one thing to connect to a database using 'localhost' , 'username', 'password', but afterwards you want to tell your script which database to use on that server.

        PHP uses a function called 'mysql_select_d b()' to choose which database you are using.

        Also, make sure you added a user with sufficient privileges to that table through phpmyadmin. A common error is that people make a user for their mysql database, but dont assign that user to that database, so your script never really executes at all because the login information will be incorrect, as their is no user assigned to it.

        Check both of those things and report back.

        Comment

        • mike j
          New Member
          • Dec 2010
          • 3

          #5
          Hey thanks for the reply again. I checked all the things you said but no luck. But I do have some questions that I am confused about.

          Where you said 'localhost', I wasn't sure if I use that or the server name. I tried both in any case and neither worked. I checked the user and its privileges, and just in case I set them again but still nothing.

          In phpmyadmin along the top it has the directories of everything.

          Server: something.net
          Database: Database name
          Table: registeredusers

          For the server I tried using what was listed in phpmyadmin, but technical support gave me a different address, the one for the Managing Database which I also tried using. I also tried using local server.

          I notice that the user for the database is different from my login to the hosting service, is that normal? It makes me think if whether the password to the managing database is also different, but I get bypassed into the database automatically by logging in to the site.

          Comment

          • AutumnsDecay
            New Member
            • Mar 2008
            • 170

            #6
            Hey,

            Generally if your script is hosted on the web-server and you have a MySQL database that's also hosted on that server, you can use 'localhost' as a server address.

            I don't generally offer hands-on help, but if you would like me to try and get this up and running for you, send me an email. info [at] autumnsolutions [dot] org. If you provide your username / password to log into the backend (I'll assume cPanel) I can double check everything, and your script. If you don't want to provide that info, it's all good and I understand. I'm just trying to help out, considering it's "the holiday season". Haha.

            Did you specify a database when you did 'mysql_select_d b()'? The correct usage would be:
            Code:
            mysql_connect('localhost', 'username', 'password');
            mysql_select_db('yourdatabase');
            And yes, your username for your MySQL database IS different than your login to cPanel.

            Comment

            Working...