jeppers Posted November 16, 2008 Share Posted November 16, 2008 i am not sure if i am just missing something but i thought i would just ask to see what you think . i have uploaded my site online. but i am having issues with it connecting my database. i no where its happening but i just don't see the problem. maybe there is something which i have not done but i am baffled. the error is: could not connect to mysql plonk: Lost connection to MySQL server during query my code is DEFINE ('DB_USER', 'example'); DEFINE ('DB_PASSWORD', 'example); DEFINE ('DB_HOST', 'example'); DEFINE ('DB_NAME', 'example'); // make the connection $dbc = @mysql_connect (example, example, example) OR die ('could not connect to mysql plonk: ' .mysql_error()); i have used a database checker to see if the info i was entering was in correct but i was able to gain connection. so have you any idea what it could be and where i should look to sort it out. thanks Link to comment https://forums.phpfreaks.com/topic/132956-solved-mysql-query-help/ Share on other sites More sharing options...
redarrow Posted November 16, 2008 Share Posted November 16, 2008 This mysql connection is already defined as it mysql....... <?php $db=mysql_connect("localhost","username","password"); $res=mysql_select_db("PLONK",$db); if(!$res){ echo"DATABASE CONNECTION PROBLAM!"; } ?> all you need to do is use it as a function, and call that function,or use it on a page and include() it..... mysql is already using a defined method to be added in php, it dosent need to be defined.... Link to comment https://forums.phpfreaks.com/topic/132956-solved-mysql-query-help/#findComment-691426 Share on other sites More sharing options...
jeppers Posted November 16, 2008 Author Share Posted November 16, 2008 DEFINE ('DB_USER', 'example'); DEFINE ('DB_PASSWORD', 'example'); DEFINE ('DB_HOST', 'example.com'); DEFINE ('DB_NAME', 'example'); // make the connection $dbc = @mysql_connect (example, example, example) OR die ('could not connect to mysql plonk: ' .mysql_error()); //select the db @mysql_select_db(DB_NAME) OR die ('Could not select the database: ' . mysql_error()); this code works on my local host not sure what you mean by the code you have suggested. the code i am using is being used via a include file. the problem is that it don't give me an error message i have seen before. could it be a problem when i have uploaded my database to my server or a problem in my code. Link to comment https://forums.phpfreaks.com/topic/132956-solved-mysql-query-help/#findComment-691433 Share on other sites More sharing options...
revraz Posted November 16, 2008 Share Posted November 16, 2008 Dont you want DB_USER, DB_PASSWORD, DB_HOST in your connect string instead of example, example, example? What is the point of defining these variable if you don't use them. Link to comment https://forums.phpfreaks.com/topic/132956-solved-mysql-query-help/#findComment-691435 Share on other sites More sharing options...
jeppers Posted November 16, 2008 Author Share Posted November 16, 2008 they are defined just not in the script i am putting online. i have tested the correct information and it works just not online Link to comment https://forums.phpfreaks.com/topic/132956-solved-mysql-query-help/#findComment-691438 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.