• Need some help with PHP and MySql
    7 replies, posted
A friend of mine wants me to help set up his programming club for his school this year. I've got the main member management program all set-up and ready to go.. but trying to add the registration page on my server - I ran into a problem. I got the main part of the page set-up properly but I need to check if the records entered already exist in the system I get this really annoying message that says : "[B]Fatal error[/B]: Call to undefined function mysql_connect() in [B]C:\htdocs\RegisterUser.php[/B] on line [B]22"[/B] Did my best to follow all the things I could find.. but still had completely no luck. Here's my code for the 'register.php' web page: [CODE] <?php session_start(); ?> <html> <head> </head> <body> <link rel="stylesheet" type="text/css" href="style.css" /> <center> <img src="23309.png"/> <form class="LoginPanel" action='RegisterUser.php' method="POST"> Email: <br> <input type='text' name='email' id='mail'/></br> NickName: <br> <input type='text' name='nick' id = 'name' /><br> Username: <br> <input type='text' name='username' id='muser'/></br> Password: <br> <input type='password' name='password' id='mpass'/></br> Confirm It : <br> <input type='password' name='Cpassword' id='m2pass'/></br> <input type='submit' value='Submit'/> </center> </center> </form> </body> </html> [/CODE] Here's my code for the 'RegisterUser.php' script: [CODE] <?php session_start(); $email = $_POST['email']; $enick = $_POST['nick']; $userT = $_POST['username']; $passT = $_POST['password']; $cPass = $_POST['Cpassword']; $username="root"; $password="mike7002555"; $database="Velocity"; $server="host1.home"; if($passT == $cPass) { if($userT != "" and $passT != "" and $cPass != "" and $email != "" and $enick != "") { $connection = mysql_connect($server,$username,$password); mysql_select_db($database) or die(mysql_error()); $result = mysql_query("SELECT * FROM clients") or die("Couldn't retreive database table information."); $row = mysql_fetch_array( $result ); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { if($row['email'] == $email) { die("That email is already in use!"); } if($row['Username'] == $userT) { die("Username is already within the system."); } if($row['NickName'] == $enick) { die("NickName is already in use, please choose another one."); } } $work = mysql_query("INSERT INTO Clients ('$enick','$userT','$passT','$email','No information specified','Regular'") or die("Error occured while sending your information."); echo "Register success! Thanks, you can now close the window!"; } else { die("You are missing some fields!"); } } else { die("Passwords do not match!"); } ?> [/CODE] I've tried JSP and failed horribly; ASP.net kept spitting out a "Thread was aborted" exception; Don't know java script.. Can someone please help me out here? [IMG]http://img823.imageshack.us/img823/3298/imagewg.png[/IMG] (Sorry if this is the wrong section, I didn't know where exactly to put it.)
It says that the mysql_connect function doesn't exist, so make sure that you have that extension and it's not commented out in your php.ini Edit: Also, you should really think about using PDO instead of the mysql_* functions, as it can prevent MySQL injection and save you trouble later.
[QUOTE=cas97;31310627]It says that the mysql_connect function doesn't exist, so make sure that you have that extension and it's not commented out in your php.ini Edit: Also, you should really think about using PDO instead of the mysql_* functions, as it can prevent MySQL injection and save you trouble later.[/QUOTE] Ok I just tried PDO and it threw this out: "exception 'PDOException' with message 'could not find driver' in C:\htdocs\RegisterUser.php:23 Stack trace: #0 C:\htdocs\RegisterUser.php(23): PDO->__construct('mysql:host=192....', 'root', 'mike7002555') #1 {main}" I enabled the extensions.. Also PHP.ini doesn't exist. It's just php.ini-development & php.ini-production.
You have posted your database password twice now, you should snip out both of the occurrences (your code, and PDO error). Try renaming php.ini-development to php.ini for now. Later, when you push your code to the production environment, you should use php.ini-production instead.
[QUOTE=wilderbeast;31311490]Ok I just tried PDO and it threw this out: "exception 'PDOException' with message 'could not find driver' in C:\htdocs\RegisterUser.php:23 Stack trace: #0 C:\htdocs\RegisterUser.php(23): PDO->__construct('mysql:host=192....', 'root', 'mike7002555') #1 {main}" I enabled the extensions.. Also PHP.ini doesn't exist. It's just php.ini-development & php.ini-production.[/QUOTE] You still don't have the MySQL extension for either.
I changed the password, and I seem to have fixed the problem. I created an .ini file then corrected the rest of the script. Thanks for the help.
[QUOTE=wilderbeast;31310292]ASP.net kept spitting out a "Thread was aborted" exception;[/QUOTE] huh, how did you manage that?
[QUOTE=tagnara;31319632]huh, how did you manage that?[/QUOTE] Honestly, have no clue. I tried logging into mySql and it kept spitting out "Thread Aborted". Then when I ran it on the server machine itself, it spat out "Connection to server could not be found." exception. Which mySQL and PHP seem to work fine. The server's ASP.net was running Framework 3.5 same with the web site. Would have just used 4.0 but the latest web developer won't install properly on here.
Sorry, you need to Log In to post a reply to this thread.