I am trying to insert data from a form into my database in an object-oriented fashion, but the data just isn't inserted. Why not?
-
class users { var $username; var $password; var $conection; var $tablename = usertable; function mysqldb() { $this->conection = mysql_connect("local host", "root", "") or die(mysql_error()); mysql_select_db("this->tablename"); } function insertdb() { $query = mysql_query("INSERT INTO $this->tablename values ('', '$user', '$pass')"); $result = mysql_query($query); if(!$result) die("Query didn't work. " . mysql_error()); } } $user1 = new users; $user1->username = $_POST["user"]; $user1->password = $_POST["pass"]; $user1->insertdb();
-
Answer:
What's the output of mysql_error()? Have you called mysqldb() ? Do you have a connection? Do you have autocommit enabled in your DB/connection?
Lucian Nutiu at Quora Visit the source
Related Q & A:
- Why isn't a webcam working with AIM?
- Why isn't a new tab opened any longer?Best solution by Ask.Metafilter.Com
- If the "blackbox" flight recorder is never damaged during a plane crash, why isn't the whole damn airplane mad?Best solution by Yahoo! Answers
- What is a post car ? I see that on a muscle car ad and I just don't get it?Best solution by Yahoo! Answers
- Why can't I taste or smell at all after a cold?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.