keithschm Posted April 18, 2007 Share Posted April 18, 2007 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 More sharing options...
per1os Posted April 18, 2007 Share Posted April 18, 2007 You know you need to connect to mysql and select a db right? www.php.net/mysql_connect www.php.net/mysql_select_db Link to comment https://forums.phpfreaks.com/topic/47644-solved-mysql_query/#findComment-232673 Share on other sites More sharing options...
trq Posted April 18, 2007 Share Posted April 18, 2007 I don't see anything in particular wrong with your code. 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. Could we see some of this (actual) code? Link to comment https://forums.phpfreaks.com/topic/47644-solved-mysql_query/#findComment-232675 Share on other sites More sharing options...
keithschm Posted April 18, 2007 Author Share Posted April 18, 2007 yea include("config.php"); include("configopen.php"); mysql_close($conn); are part of the script just did not think I needed to post it Link to comment https://forums.phpfreaks.com/topic/47644-solved-mysql_query/#findComment-232676 Share on other sites More sharing options...
keithschm Posted April 18, 2007 Author Share Posted April 18, 2007 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 More sharing options...
trq Posted April 18, 2007 Share Posted April 18, 2007 Is this happening on your development box or a remote server? The error youv'e posted is normally associated with a configuration problem associated with the mysql client. Ive had it before, not quite sure what I did though. Link to comment https://forums.phpfreaks.com/topic/47644-solved-mysql_query/#findComment-232681 Share on other sites More sharing options...
per1os Posted April 18, 2007 Share Posted April 18, 2007 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 More sharing options...
keithschm Posted April 21, 2007 Author Share Posted April 21, 2007 Thank you all very much. I struggled with the left join but once I got it working if fixed my issue. Thank you all very much for your help Link to comment https://forums.phpfreaks.com/topic/47644-solved-mysql_query/#findComment-234728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.