Jump to content

Problem Connecting to the Database and retrieving files


carleihar

Recommended Posts

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

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

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'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.