473,395 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Table always returns empty result set despite inputs from php form

3
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
Dec 19 '10 #1
5 3016
AutumnsDecay
170 100+
Did you make the table using phpmyadmin?

Also, try running an SQL query from phpmyadmin:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO `registeredusers` (firstname, lastname, email) VALUES ('Test', 'Person', 'someone@somewhere.com');
  2.  
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.
Dec 20 '10 #2
mike j
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.
Dec 20 '10 #3
AutumnsDecay
170 100+
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_db()' 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.
Dec 20 '10 #4
mike j
3
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.
Dec 20 '10 #5
AutumnsDecay
170 100+
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_db()'? The correct usage would be:
Expand|Select|Wrap|Line Numbers
  1. mysql_connect('localhost', 'username', 'password');
  2. mysql_select_db('yourdatabase');
  3.  
And yes, your username for your MySQL database IS different than your login to cPanel.
Dec 20 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: milkyway | last post by:
Hello, I have an HTML page that I am trying to import 2 .js file (I created) into. These files are: row_functions.js and data_check_functions.js. Whenever I bring the contents of the files into...
4
by: Bob Bedford | last post by:
We have no access to a mysql NG on my provider's server, so we ask here: We have a long query (long in text) with a UNION between 2 select. We have been informed that some times the query...
5
by: Tim | last post by:
Hello All, I am writing a program that checks for the NumLock status and turns the NumLock on if it is off. I'm not sure what I'm overlooking at this point, but the code will compile and run, but...
7
by: al | last post by:
Greetings all, I use request.form("textbox1") to get data back to page, dim str as string str = request.form("textbox1").tostring But str is always empty after refresh???? I use asp.net...
10
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
1
by: Crazy Cat | last post by:
Hi, whenever the underlying query being called by EXEC in the following has an empty result set I get the following error -- Invalid Data for 'Numeric' when EXEC returns empty row. However if I...
6
by: Michi Henning | last post by:
I'm running the following code in Safari 2.0.4: document.cookie = 'MyCookie=1'; if(document.cookie == '') alert('document.cookie is empty!'); document.cookie always returns the empty string,...
1
by: Andy Fish | last post by:
Hi, using XSLT 1.0, consider something like this: <xsl: variable name="foo"> <apply-templates select="..." mode="..." /> </xsl:variable> <xsl:if test="$foo"> do something in here </xsl:if>
2
by: MDANH2002 | last post by:
Hi From VB.NET I want to simulate the POST request of the following HTML form <html> <title>HTTP Post Testing</title> <body> <form action=http://www.example.com/postdata ...
6
by: unpresedented | last post by:
I have this query (that runs on Oracle 10g database): SELECT ge.*, ge.concept AS glossarypivot FROM s_glossary_entries ge WHERE (ge.glossaryid = '161' OR ge.sourceglossaryid = '161') AND...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.