carleihar Posted November 13, 2009 Share Posted November 13, 2009 I am getting these errors when I go to this page: Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/e/q/u/equianadmin/html/htdocs/practice.php on line 13 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/e/q/u/equianadmin/html/htdocs/practice.php on line 13 Warning: Wrong parameter count for mysql_fetch_assoc() in /home/content/e/q/u/equianadmin/html/htdocs/practice.php on line 14 Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/e/q/u/equianadmin/html/htdocs/practice.php on line 17 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/e/q/u/equianadmin/html/htdocs/practice.php on line 17 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/e/q/u/equianadmin/html/htdocs/practice.php on line 18 $horse_color My username, password, host, and database name is filled out correctly and it works. What's my problem? Thanks! <?php DEFINE ('DB_USER', 'username'); DEFINE ('DB_PASSWORD', 'password'); DEFINE ('DB_HOST', 'host'); DEFINE ('DB_NAME', 'database name'); $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' .mysqli_connect_error() ); $momhorseid=2; $dadhorseid=1; //**********************************COLOR*********************** function getHorseColor(){ $sql = "SELECT color FROM horses WHERE horse_id=$momhorseid LIMIT 1";//limit to 1 row returned $query = mysql_query($sql); $row = mysql_fetch_assoc($query); $momcolor= $row_mcolor['color'];//$momcolor now contains her color $sql_dcolor = "SELECT color FROM horses WHERE horse_id=$dadhorseid LIMIT 1";//limit to 1 row returned $query_dcolor = mysql_query($sql_dcolor); $row_dcolor = mysql_fetch_assoc($query_dcolor); $dadcolor= $row_dcolor['color'];//$dadcolor now contains his color Quote Link to comment https://forums.phpfreaks.com/topic/181415-problem-connecting-to-the-database-and-retrieving-files/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 13, 2009 Share Posted November 13, 2009 You are creating a mysqli connection but using mysql_ functions. You cannot mix the connection/function types between mysqli and non-mysqli Quote Link to comment https://forums.phpfreaks.com/topic/181415-problem-connecting-to-the-database-and-retrieving-files/#findComment-956984 Share on other sites More sharing options...
carleihar Posted November 13, 2009 Author Share Posted November 13, 2009 Ahhhh...something I did not know. Thank you! Now my errors are: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/e/q/u/equianadmin/html/htdocs/practice.php on line 14 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/e/q/u/equianadmin/html/htdocs/practice.php on line 18 Quote Link to comment https://forums.phpfreaks.com/topic/181415-problem-connecting-to-the-database-and-retrieving-files/#findComment-956985 Share on other sites More sharing options...
knsito Posted November 13, 2009 Share Posted November 13, 2009 Ahhhh...something I did not know. Thank you! Now my errors are: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/e/q/u/equianadmin/html/htdocs/practice.php on line 14 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/e/q/u/equianadmin/html/htdocs/practice.php on line 18 this is the same problem as before -- 'mysqli' not 'mysql' Quote Link to comment https://forums.phpfreaks.com/topic/181415-problem-connecting-to-the-database-and-retrieving-files/#findComment-957026 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.