surf5502 Posted December 2, 2006 Share Posted December 2, 2006 i just started using MySQL and this is my frist program... i ve read numerous things on how to connect and i think i followed them all... and this is what i ended up with:[color=orange]//connect to MySQL Database and add information into it[/color][color=blue]$username = "bchs";$password = "mattward";$database = "bchssurvey";$hostaddr = "db4free.net:3307";mysql_connect($hostaddr,$username,$password);@mysql_select_db($database) or die("Error: Database not available. Please try again later.");$query = "INSERT INTO survey VALUES('','$type','$isHomePage','$vstAthlet','$vstLinks','$vstEdline','$vstFacul','$vstLaptop','$vstPres','$vstPrinc','$vstCal','$eForms','$sMap','$bRSS','$facWS','$facClub','$facClubWS','$facCon','$facPic','$facEdline1','$facEdline2','$facEdline3','$facEdline4','$facEdline5','$aEdline','$chEdline','$announce','$eFac','$eFindFac','$stuHandouts','$stuWebteam','$stuWebteamN','$stuWebteamH','$otherWB','$conceptHP','$conceptCP','$conceptLike','$conceptNoLike','$comments')";mysql_query($query);mysql_close();[/color]any ideas of what i did wrong? i am actually programming an online survey for my school website (i am the new webmaster)... any questions about what i am trying to do please aski really need this thing to work asapthanks everyone Quote Link to comment Share on other sites More sharing options...
Hypnos Posted December 2, 2006 Share Posted December 2, 2006 You need to post the error. Quote Link to comment Share on other sites More sharing options...
surf5502 Posted December 4, 2006 Author Share Posted December 4, 2006 well besides the fact that the loading.... thing goes on for like 10 minutes... it then goes:[color=blue]Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'db4free.net' (36) in /home/bchs/bchs-web/data/survey/finalize.php on line 10Error: Database not available. Please try again later.[/color]and thats my error for ya Quote Link to comment Share on other sites More sharing options...
surf5502 Posted December 4, 2006 Author Share Posted December 4, 2006 might this have anything to do with it?[color=blue]Used PHP extensions: mysqli[/color]it was on my PHPMyAdmin page... Quote Link to comment Share on other sites More sharing options...
mainewoods Posted December 4, 2006 Share Posted December 4, 2006 you did know that mysql is usually installed on port '3306' and '3307' is what you meant to code?[code]$hostaddr = "db4free.net:3307";[/code] Quote Link to comment Share on other sites More sharing options...
surf5502 Posted December 4, 2006 Author Share Posted December 4, 2006 this server runs it on both actually... i dont know i tried both and neither workedwill the mysqli make a difference? or is it like the same thing? Quote Link to comment Share on other sites More sharing options...
surf5502 Posted December 4, 2006 Author Share Posted December 4, 2006 ok so i got bored and re-coded it to MySQLi:[color=blue]//connect to MySQL Database and add information into it$username = "bchs";$password = "mattward";$database = "bchssurvey";$hostaddr = "db4free.net:3306";$connection = mysqli_connect($hostaddr,$username,$password,$database) or die("Error: Database not available. Please try again later.");$query = "INSERT INTO survey VALUES('','$type','$isHomePage','$vstAthlet','$vstLinks','$vstEdline','$vstFacul','$vstLaptop','$vstPres','$vstPrinc','$vstCal','$eForms','$sMap','$bRSS','$facWS','$facClub','$facClubWS','$facCon','$facPic','$facEdline1','$facEdline2','$facEdline3','$facEdline4','$facEdline5','$aEdline','$chEdline','$announce','$eFac','$eFindFac','$stuHandouts','$stuWebteam','$stuWebteamN','$stuWebteamH','$otherWB','$conceptHP','$conceptCP','$conceptLike','$conceptNoLike','$comments')";$result = mysqli_query($connection,$query);mysqli_free_result($result);mysqli_close($connection);[/color]ok still doesnt work but different error now![color=red]Fatal error: Call to undefined function mysqli_connect() in /home/bchs/bchs-web/data/survey/finalize.php on line 10[/color] Quote Link to comment Share on other sites More sharing options...
mainewoods Posted December 4, 2006 Share Posted December 4, 2006 just try the mysql_connect with 3306 Quote Link to comment Share on other sites More sharing options...
surf5502 Posted December 4, 2006 Author Share Posted December 4, 2006 going backwards...[color=red]Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in /home/bchs/bchs-web/data/survey/finalize.php on line 10Error: Database not available. Please try again later.[/color] Quote Link to comment Share on other sites More sharing options...
surf5502 Posted December 4, 2006 Author Share Posted December 4, 2006 oh ya i fixed it....ignore this thread 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.