Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem running a MySQL query

Status
Not open for further replies.
Jun 14, 1999
606
US
Hello, I have a problem with a SELECT query to a MySQL database server from Apache+PHP3:<br><br>I have two tables: item and catitem.<br>Item columns:<br>---------------------<br>tstamp&nbsp;&nbsp;&nbsp;- timestamp<br>user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- integer(4)<br>dateitem - date<br>category - integer(4)<br>person&nbsp;&nbsp;&nbsp;- integer(4)<br>amount&nbsp;&nbsp;&nbsp;- integer<br>details&nbsp;&nbsp;- text<br><br>Catitem columns:<br>---------------------<br>id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- integer(4)<br>descr&nbsp;&nbsp;&nbsp;&nbsp;- varchar(80)<br><br>The problem is: When I execute from mysql program (AIX version) this <b><FONT FACE=monospace>SELECT catitem.descr AS 'Category', COUNT( item.amount ) AS 'Number of items', SUM( item.amount ) AS 'Total amount' FROM item,catitem WHERE item.category=catitem.id&nbsp;&nbsp;AND item.dateitem&gt;=20000101&nbsp;&nbsp;AND item.dateitem&lt;=20000701 GROUP BY item.category;<br></font><b>, it gives the correct answer: 15 records with 3 fields each.<br><br>When I connect from my .PHP file with this:<br><FONT FACE=monospace><br>$cx = mysql_pconnect( $server, $user, $pass );<br>if ($cx) {<br>&nbsp;&nbsp;mysql_selectdb( $dataname );<br>&nbsp;&nbsp;$rc = mysql_query( $query );<br>}<br></font><br>It gives wrong results: 0 records of 0 fields each!<br>My database server is the same AIX machine that Apache+PHP server.<br>There is no problem authenticating the user.<br>My Apache server is getting the correct query string, because I'm doing a <FONT FACE=monospace>$FILE=fopen( &quot;somefile&quot;, &quot;a+&quot;); fwrite( $FILE, $query );</font> to debug the program.<br><br>What I'm doing wrong?<br><br>SMTIA!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top