473,387 Members | 1,624 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,387 software developers and data experts.

Can't use PHP with MySQL... get an 'object expected' error

Hi,
This probably has an extremely stupid answer, but I'm just beginning to learn PHP in an attempt to have a working registration program for my website. I have made the HTML and PHP the way that several tutorials online have showed me, and I want to make it so that when you register under a username, password, etc, that data goes into my MySQL database so that it can remember you the next time you log in.

The problem is, when I run the HTML and it calls the PHP, I get an error in line 39, char 2, which doesn't even exist in my PHP file. Code 0, 'object expected'. I wish they could try to be a little more specific as to what went wrong...
If it helps, here's my HTML code
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2.  
  3. <html>
  4. <head>
  5. <title>Register for an account on xxxx!</title>
  6. </head>
  7. <body>
  8. <form action="http://subdomain.mywebsite.com/submitinfo.php">
  9. Username:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  10. &nbsp;
  11. <input type="text" name="Username">
  12. <br />
  13. Full Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  14. &nbsp;
  15. <input type="text" name="Name">
  16. <br />
  17. Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  18. &nbsp;
  19. <input type="password" name="Password">
  20. <br />
  21. Confirm Password:
  22. <input type="password" name="Confirm Password">
  23. <br />
  24. E-mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  25. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  26. <input type="text" name="E-mail">
  27. <br />
  28. Confirm E-mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  29. <input type="text" name="Confirm E-mail">
  30. <br />
  31. Gender:<br />
  32. <input type="radio" name="Gender"> Male<br />
  33. <input type="radio" name="Gender"> Female<br />
  34. <input type="submit" name="Submit">
  35. </form>
  36. </body>
  37. </html>
  38.  
And the PHP code is just down to its bare bones and not transmitting everything yet, but I wanted to see if it would work first to transmit data to my database:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $link = mysql_connect ("xx.x.xxx.xxx", "myusername", "mypassword")
  3. or die('Could not connect ' . mysql_error());
  4. mysql_select_db ("myusername", $link) or die('Could not select database.');
  5. $Username = $_POST['Username'];
  6. $Password = $_POST['Password'];
  7. $Name = $_POST['Name'];
  8. $Email = $_POST['E-mail'];
  9.  
  10. $sql="INSERT INTO Usernames and Passwords (Username, Password, E-mail, Name) VALUES ($Username,$Password,$Email,$Name)";
  11. if (!mysql_query($sql,$link))
  12.   {
  13.   die('Error: Couldn''t insert the data.' . mysql_error());
  14.   }
  15.     mysql_close($link);
  16.     ?>
  17.  
Thanks for helping!
--Gladi8r
Jan 18 '09 #1
8 2709
Dormilich
8,658 Expert Mod 8TB
can't make any sense of the error message either, maybe copy and post the error message directly from the browser...

nevertheless, you are trying to access a variable you don't have. the error lies within the HTML code. in the <form> tag you don't specify the transfer method (get or post) which then defaults to "get". thus you have no $_POST data.

furthermore, your SQL looks weird. if I read the manual right, you have to specify one table, not sure if "Usernames and Passwords" conforms to the SQL naming scheme here.
Jan 18 '09 #2
I had made a table called Usernames and Passwords for user data earlier on my database. I inserted some data from the manager, and it didn't seem to care.
When I changed my method to "post" in my HTML, it came back with the exact same error:
Line: 39
Char: 2
Error: Object expected
Code: 0
URL: <Url removed - just lead to an advertising page>
Jan 18 '09 #3
Dormilich
8,658 Expert Mod 8TB
to me it looks more like a javascript error on IE....
Jan 18 '09 #4
Then is there any way I can fix it so that it works with my browser?
Jan 18 '09 #5
Dormilich
8,658 Expert Mod 8TB
I think so, but without knowing the javascript I cannot tell. maybe it helps if you disable javascript.
Jan 18 '09 #6
It's just a bit odd. I've never had to do that on a registration before.
Jan 18 '09 #7
pbmods
5,821 Expert 4TB
Heya, gladi8r.

You've probably got some spyware or malware on your computer that's causing the JS error. Try running a spyware/malware removal tool and seeing if the problem goes away.

Alternatively, try accessing the PHP script on a different computer.
Jan 18 '09 #8
Atli
5,058 Expert 4TB
Hey, I get it now... IE's poor JavaScript support is a security mechanism :]

You could try installing Firefox and viewing the page in that.
If the error still shows up, Firefox should give you a better idea as to why and where it is happening.

If it doesn't, pbmods is probably right (which he usually is) and you have a spyware/malware/virus problem going on.
Jan 18 '09 #9

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

Similar topics

3
by: joemyre | last post by:
Hi everyone, What I'm trying to do is take php variables i got from user input, and pass them as the MySQL query terms. $query = "select * from ident where ".$searchtype1."=".$searchterm1."";...
10
by: Matthew Sims | last post by:
I've been performing search after search all over the internet reading up on all topics about making PHP secure with MySQL. There's a lot out there and not many concrete examples on how you should...
4
by: Yossi Naggar | last post by:
Hello to everyone, I am an experienced user in MSSQL Server. Lately I have been started using MySQL. I managed to create my database and tables. When I wanted to execute the following query:...
4
by: Bill | last post by:
I call a function in my .js file like this: onClick="location.href='blank.html' + generateSearchStringFromForm('section')" where section is the name of my form. The function is defined as...
5
by: MLH | last post by:
I'm supposed to set a password for the MySQL root user. The output of mysql_install_db instructed me to run the following commands... /usr/bin/mysqladmin -u root -h appserver password mynwewpasswd...
26
by: Dave Hammond | last post by:
In document "A.html" I have defined a function and within the document body have included an IFRAME element who's source is document "B.html". In document "B.html" I am trying to call the function...
13
by: MLH | last post by:
Suppose I have this simple SQL string... SELECT tblDrivers.DriverID, tblDrivers.DName FROM tblDrivers WHERE (((tblDrivers.DName) Like "N*")) ORDER BY tblDrivers.DriverID; And suppose that...
5
by: gooderthanyou | last post by:
Alright i've looked a ton of topics and most of them are unresolved... configure: error: Cannot find MySQL header files under usr/local/mysql. Note that the MySQL client library is not bundled...
11
by: kennthompson | last post by:
Trouble passing mysql table name in php. If I use an existing table name already defined everything works fine as the following script illustrates. <?php function fms_get_info() { $result =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.