Constantine8 Posted December 8, 2006 Share Posted December 8, 2006 Not sure what I'm doing wrong... I'm practicing with a book program already put together.. I can get this to work on my local host but can't get it to work on my godaddy server... am I missing something in this code?godaddy::: this one doesn't work<?phpfunction db_connect(){$result = mysql_pconnect('site', 'book_rama', 'password'); if (!$result)return false;if (!mysql_select_db('book_rama'))return false;return $result;}?>local host:::::: this works<?phpfunction db_connect(){$result = mysql_connect('localhost'); if (!$result)return false;if (!mysql_select_db('book_rama'))return false;return $result;}?>thanks in advance. Link to comment https://forums.phpfreaks.com/topic/29861-connections/ Share on other sites More sharing options...
willfitch Posted December 8, 2006 Share Posted December 8, 2006 Is there any reason you are attempting to use persistant connections? Link to comment https://forums.phpfreaks.com/topic/29861-connections/#findComment-137208 Share on other sites More sharing options...
Constantine8 Posted December 8, 2006 Author Share Posted December 8, 2006 not really... it was just already in the code... i have tried it with and without on both but it doesn't seem to affect the result. Link to comment https://forums.phpfreaks.com/topic/29861-connections/#findComment-137211 Share on other sites More sharing options...
willfitch Posted December 8, 2006 Share Posted December 8, 2006 What error are you getting back?Try using mysql_error() Link to comment https://forums.phpfreaks.com/topic/29861-connections/#findComment-137217 Share on other sites More sharing options...
Constantine8 Posted December 8, 2006 Author Share Posted December 8, 2006 i have tried using this and just tried again... forgive me but since i have various forms I'm not sure where to put it... i have an output form, and I have a user_auth form where my echoed error comes from::function register($username, $email, $password)// register new person with db// return true or error message{ // connect to db $conn = db_connect(); if (!$conn) [b]return 'Could not connect to database server - please try later.';[/b] // check if username is unique $result = mysql_query("select * from user where username='$username'"); if (!$result) return 'Could not execute query'; if (mysql_num_rows($result)>0) return 'That username is taken - go back and choose another one.'; // if ok, put in db $result = mysql_query("insert into user values ('$username', password('$password'), '$email')"); if (!$result) //echo mysql_error($result); return 'Could not register you in database - please try again later.'; return true;} Link to comment https://forums.phpfreaks.com/topic/29861-connections/#findComment-137238 Share on other sites More sharing options...
willfitch Posted December 8, 2006 Share Posted December 8, 2006 The mysql_error should go outside of your mysql_query() function. $result = mysql_query("sql statement") or die(mysql_error());Also, make sure you have the correct connection credentials Link to comment https://forums.phpfreaks.com/topic/29861-connections/#findComment-137242 Share on other sites More sharing options...
Constantine8 Posted December 8, 2006 Author Share Posted December 8, 2006 not sure if this is what you meant but it doesn't seem to produce any output:$result = mysql_query("select * from user where username='$username'")or die(mysql_error());it also seems that the error would be before this since the bold text above is where my error occurs. should the 'mysql_error' somehow be checking the $conn db_connect()?? or in my 'funtion db_connect' which is in a separate 'db_fns.php' form'? also i have this all working on a godaddy server but using different forms with different code.. so I don't think it should be my connection credentials. I also checked that multiple times--over multiple hours.thanks for your help.. it would be great to get this error reporting working so I can debug this problem. Link to comment https://forums.phpfreaks.com/topic/29861-connections/#findComment-137252 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.