Jump to content

[SOLVED] mysql_query()


keithschm

Recommended Posts

mysql_query() sends an unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.

 

 

so if multiple queries are not supporeted what would I use.

 

I have script using php to read a database, that passes data to a function that uses the PEAR::DB module  to read and write to a differnt table on the same database.  If my php query respondes with more the 1 result I get

 

Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Warning: mysql_query(): A link to the server could not be established

 

if I disable the pear part it works fine, if I disable the mysql_query() and feed it static info it works fine.  they just will not work together.

 

any suggestions?

 

Thanks

 

here is my query

 

$query  = "SELECT user_id, user_name FROM e107_user WHERE user_name  like  'somedata%'";
   $result = mysql_query($query);

   while($row = mysql_fetch_assoc($result))

   {


   $userid = $row['user_id'];


   	$query2 = "SELECT user_location FROM e107_user_extended WHERE user_extended_id = $userid";
   $result2 = mysql_query($query2);
   while($row2 = mysql_fetch_assoc($result2))
   {

   $loc = $row2['user_location'];

   }

 

Link to comment
https://forums.phpfreaks.com/topic/47644-solved-mysql_query/
Share on other sites


function getCache($address) {
        if(!isset($this->dsn))
            return false;

        $_ret = array();

        // PEAR DB
        require_once('DB.php');
        $_db =& DB::connect($this->dsn);
        if (PEAR::isError($_db)) {
            die($_db->getMessage());
        }
	$_res =& $_db->query("SELECT lon,lat FROM {$this->_db_cache_table} where address = ?", $address);
        if (PEAR::isError($_res)) {
            die($_res->getMessage());
        }
        if($_row = $_res->fetchRow()) {
            $_ret['lon'] = $_row[0];
            $_ret['lat'] = $_row[1];
        }

        $_db->disconnect();

        return !empty($_ret) ? $_ret : false;
    }

Link to comment
https://forums.phpfreaks.com/topic/47644-solved-mysql_query/#findComment-232678
Share on other sites

On a side note:

 

$query  = "SELECT user.user_id, user.user_name usere.user_location FROM e107_user user LEFT JOIN (e107_user_extended usere) ON (usere.user_extended_id = user.user.user_id) WHERE user.user_name  like  'somedata%'";

 

That query might better suit your needs so you only have to run 1 query instead of 2 =)

Link to comment
https://forums.phpfreaks.com/topic/47644-solved-mysql_query/#findComment-232683
Share on other sites

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.