jtjohnson260 Posted August 18, 2007 Share Posted August 18, 2007 My friend says my database isn't set up on my site yet. This is what I get on my register page? Fatal error: Call to a member function on a non-object in /home/content/z/h/a/zhahaman2001/html/jtjohnson260/register.php on line 46 and the line is if (! $sql->query("INSERT INTO users (username, password, email, date_registered) VALUES ('$username', '$password', '$email, 'NOW'())") ) { How do I fix this. I'm on AIM if someone can walk me through it quickly. all the code for the page is attached [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/ Share on other sites More sharing options...
ILYAS415 Posted August 18, 2007 Share Posted August 18, 2007 hehe try: if (!$sql){ mysql_query("INSERT INTO users (username, password, email, date_registered) VALUES ('$username', '$password', '$email, 'NOW'")); } not sure if it works but try it anyway Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327572 Share on other sites More sharing options...
jtjohnson260 Posted August 18, 2007 Author Share Posted August 18, 2007 no, now i get Parse error: parse error, unexpected ')' in /home/content/z/h/a/zhahaman2001/html/jtjohnson260/register.php on line 47 Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327576 Share on other sites More sharing options...
ILYAS415 Posted August 18, 2007 Share Posted August 18, 2007 lol kk here y. replace my code with this one... if (!$sql){ mysql_query("INSERT INTO users (username, password, email, date_registered) VALUES ('$username', '$password', '$email, 'NOW')"); } Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327579 Share on other sites More sharing options...
jtjohnson260 Posted August 18, 2007 Author Share Posted August 18, 2007 now i have even more then before Warning: mysql_query(): Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2) in /home/content/z/h/a/zhahaman2001/html/jtjohnson260/register.php on line 47 Warning: mysql_query(): A link to the server could not be established in /home/content/z/h/a/zhahaman2001/html/jtjohnson260/register.php on line 47 Could not create user Fatal error: Call to a member function on a non-object in /home/content/z/h/a/zhahaman2001/html/jtjohnson260/register.php on line 53 Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327581 Share on other sites More sharing options...
ILYAS415 Posted August 18, 2007 Share Posted August 18, 2007 r u properly connected to ur host? the sql query i gav u was absolutly right. (dont worry, sometimes more errors are meant to pop up) Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327583 Share on other sites More sharing options...
jtjohnson260 Posted August 18, 2007 Author Share Posted August 18, 2007 i dont know how to connect to it, that was what my problem was to begin with Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327584 Share on other sites More sharing options...
ILYAS415 Posted August 18, 2007 Share Posted August 18, 2007 dont u hav a db connection script on ur site? like db_connect.php or config.php? Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327588 Share on other sites More sharing options...
jtjohnson260 Posted August 18, 2007 Author Share Posted August 18, 2007 no, i'll make one right now, what do i put in it? Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327589 Share on other sites More sharing options...
ILYAS415 Posted August 18, 2007 Share Posted August 18, 2007 put this inside it... <?php $mysql_server = "localhost"; $mysql_user = "database user here"; $mysql_password = "database user's password here"; $mysql_database = "databases name here"; mysql_connect ("localhost", "$mysql_user", "$mysql_password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("$mysql_database"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327591 Share on other sites More sharing options...
jtjohnson260 Posted August 18, 2007 Author Share Posted August 18, 2007 exacly how it is? Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327596 Share on other sites More sharing options...
ILYAS415 Posted August 18, 2007 Share Posted August 18, 2007 nope u need the change the variables like $database_name to ur database name etc. wat host r u using? Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327598 Share on other sites More sharing options...
jtjohnson260 Posted August 18, 2007 Author Share Posted August 18, 2007 PhpMYAdmin?? i'm set up as another account on a friends database. i do have my own username and pass though. Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327601 Share on other sites More sharing options...
ILYAS415 Posted August 18, 2007 Share Posted August 18, 2007 ok then put in ur friends database name on their, your database username and pass into those variables Quote Link to comment https://forums.phpfreaks.com/topic/65603-need-help/#findComment-327603 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.