lrk89 Posted September 5, 2011 Share Posted September 5, 2011 Hi all im trying to create a simple user registration page using php and mysql i created the database and tables locally and tested it and it works great so I did the same for on my sever and in the my mysqli connection script I changed the database name/passwords etc to match the hosting. when i tested the script I get: Notice: Constant DB_USER already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 3 Notice: Constant DB_PASSWORD already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 5 Notice: Constant DB_HOST already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 7 Notice: Constant DB_NAME already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 9 Easy to fix right. dont definine it twice. but im not defining it anywhere but my registration page and the only call i make to it is whne i use require_once("mysqli_connect.php"); next mind boggling error is this: Table 'example_wrdp2.users' doesn't exist ok so to fix this I create the database right. well I have and it still dont work and I dont know why its choosing example_wrdp2 on my server i have 5 databases: example_wrdp1 example_wrdp2 example_wrdp3 example_wrdp4 example_myNewDatabase I don't understand why its not using example_myNewDatabase which i am specifying in my db connect script. Im totally lost and stuck with this. Quote Link to comment Share on other sites More sharing options...
voip03 Posted September 5, 2011 Share Posted September 5, 2011 Turn off error reporting and try Quote Link to comment Share on other sites More sharing options...
lrk89 Posted September 5, 2011 Author Share Posted September 5, 2011 Oh I didnt have error reporting on to begin with but I turned it on to see what was happening. on or off it should still work or not. wtf is John, George, Paul and ....:? EDIT: answer RINGO! i dont even listen to the beetles!.... Quote Link to comment Share on other sites More sharing options...
trq Posted September 5, 2011 Share Posted September 5, 2011 Can you post some relevant code? And John, George, Paul and Ringo are members of arguably the most influential bands of all time. Quote Link to comment Share on other sites More sharing options...
lrk89 Posted September 5, 2011 Author Share Posted September 5, 2011 haha not my cup of tea ;-) yeah sure the code all looks ok to me <?php if (isset($_POST['submitted'])) { include_once "mysqli_connect.php"; $errors = array(); //check all fields for errors when form is submitted if (empty($_POST['FirstName'])) { $errors[] = 'You forgot to enter your first name.'; } else { $FirstName = mysqli_real_escape_string($dbc, trim($_POST['FirstName'])); } //end of fist name if (empty($_POST['LastName'])) { $errors[] = 'You forgot to enter your last name.'; } else { $LastName = mysqli_real_escape_string($dbc, trim($_POST['LastName'])); } // end of last name if (empty($_POST['email'])) { $errors[] = 'You forgot to enter your email address.'; } else { $email = mysqli_real_escape_string($dbc, trim($_POST['email'])); }// end of emial if (!empty($_POST['pass'])) { if ($_POST['pass'] != $_POST['pass2']) { $errors[] = 'Your password did not match the confirmed password.'; // check if passwords match } else { $pass = mysqli_escape_string($dbc, trim($_POST['pass'])); } } else { $errors[] = 'You forgot to enter your password.'; // end of password } if (empty($errors)) { $query = "INSERT INTO users (first_name, last_name, email, pass, registration_date) VALUES ('$FirstName', '$LastName', '$email', SHA1('$pass'), NOW())"; $result = @mysqli_query ($dbc, $query); if ($result) { echo '<h5>Thank you!</h5> <p>You are now registered.</p><p><br /></p>'; } else { echo '<h1>System Error</h1> <p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $query . '</p>'; } exit(); } else { echo '<h1>Error!</h1> <p class="error">The following >>error(s) occurred:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } mysqli_close($dbc); } I cant see anything wrong with the above and my connection script is this: <?php DEFINE ('DB_USER','username'); DEFINE ('DB_PASSWORD','pass'); DEFINE('DB_HOST','localhost'); DEFINE('DB_NAME','databasename'); $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to Mysql database: ' . mysqli_connect_error() ); ?> Quote Link to comment Share on other sites More sharing options...
voip03 Posted September 5, 2011 Share Posted September 5, 2011 comment out the DEFINEs Quote Link to comment Share on other sites More sharing options...
lrk89 Posted September 5, 2011 Author Share Posted September 5, 2011 That solved the DEFINE issue but im seriously not defining it anywhere else, still says it cant find the right database. its trying to use a database that im using for wordpress could somehow that be conflicting it? its for a different domain but i host all my sites on one hosting. Quote Link to comment Share on other sites More sharing options...
voip03 Posted September 5, 2011 Share Posted September 5, 2011 Can you create new db and try? Quote Link to comment Share on other sites More sharing options...
lrk89 Posted September 5, 2011 Author Share Posted September 5, 2011 Iv done that several times and have given up after some research i have just added print_r(get_defined_constants(true)); before the defines and i got loads of jargon but its alreading defining a connection that relates to one of my wordpress installs. how do i make it choose the one for my new database and site? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.