Page 1 of 1
[Solved] Strange count 'error'
Posted: Sun Feb 29, 2004 7:22 pm
by Shendemiar
This has been solved.
Main point in this was that i first made a query in phpmyadmin, and pasted it to my code, so save trouble. Usually it works just fine, but with COUNT it doesnt.
phpmyadmin adds an empty space after the COUNT and before the (whatever) like
Count(a)
becomes
Count (a)
And the later dont work with normal php code, it gives an syntax error, but pasting the query again into phpmyadmin, and it works just fine, thus the pain...
Posted: Sun Feb 29, 2004 7:47 pm
by Shendemiar
Even:
select count (*) from news;
Gives me that notice on phpmyadmin, and error in my code:
Error in query:You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(*) from news' at line 1
Posted: Mon Mar 01, 2004 11:49 am
by Shendemiar
New TRY:
I changed my php from CGI to module, and now lately i've been receiving these:
Notice: Undefined variable: url_query in d:\_palvelin\phpmyadmin-2.5.4\libraries\display_tbl.lib.php on line 1477
when i make trivial queries (usually count related) on phpmyadmin or in my project...
What is url_query?
Posted: Mon Mar 01, 2004 12:00 pm
by Shendemiar
CGI/Module, both the same behaviour...
Posted: Mon Mar 01, 2004 2:58 pm
by Shendemiar
I'm not looking for a complete answar... I would appriciate anything, even something like:
"It might be your apache..."
or
"Reinstall everything..."
etc...
Posted: Mon Mar 01, 2004 3:05 pm
by markl999
Well, i'd first get the latest stable version of phpMyAdmin, which is 2.5.6 as you maybe hitting a bug that's since been fixed. I'd also stick with the module version of PHP.
The 'undefined variable' notice is just down to your error_reporting setting. If you have error_reporting set to E_ALL then things like echo $foo; will throw up an undefined variable notice if $foo isn't set. You can tweak the error_reporting value in php.ini, a vhost section of httpd.conf or in a script itself using
http://php.net/error_reporting
Posted: Mon Mar 01, 2004 3:43 pm
by Shendemiar
markl999 wrote:Well, i'd first get the latest stable version of phpMyAdmin, which is 2.5.6 as you maybe hitting a bug that's since been fixed. I'd also stick with the module version of PHP.
The 'undefined variable' notice is just down to your error_reporting setting. If you have error_reporting set to E_ALL then things like echo $foo; will throw up an undefined variable notice if $foo isn't set. You can tweak the error_reporting value in php.ini, a vhost section of httpd.conf or in a script itself using
http://php.net/error_reporting
2.5.6 don't give the notice anymore, and i used other means to count records than count in sql statement, so i guess i'm clear for now...
I think it's good to keep maximum error reporting while im trying to learn it...
Posted: Mon Mar 01, 2004 3:47 pm
by markl999
I think it's good to keep maximum error reporting while im trying to learn it.
I agree, and always use E_ALL. It's just handy to be able to lower it for third party apps as 90% of them would have a fit if they had to work under E_ALL conditions

Posted: Mon Mar 01, 2004 5:20 pm
by Shendemiar
ÄGH...It came again, when i needed count elsewhere:
I have:
error_reporting(E_ALL);
And i Get:
Error in query:You have an error in your SQL syntax.
This time with:
$query=fetch_query("SELECT vote, count (pid) as co from games_requests where gid=$gamenro group by vote ");
I think that the query isn't the issue, it's everything that uses count. The same query goes fluently in phpmyadmin 2.5.6.
Can indexes and uniques etc effect that anyhow.
I have:
Apache/1.3.29 (Win32) PHP/4.3.4 running...
MySql 4.0.18
Posted: Mon Mar 01, 2004 5:56 pm
by Shendemiar
So the question is:
Why "Select count(*) from A" Works with phpmyadmin, but not within my code?
What settings in php.ini and httpd.conf could have any impact with count ?
It doesnt work either on phpED, and it has internal server/php/mysql, so it must be a syntax?
Here's a sample:
Code: Select all
<?php
$query=("SELECT count (*) from games_requests");
$yhteys = mysql_connect($DBC1, $DBC2, $DBC3) or die ("Error on connect:" . mysql_error());
if(isset($yhteys))
{
mysql_select_db($DB, $yhteys);
$haku = mysql_query($query, $yhteys) or die("Error in query:" . mysql_error());
return $haku;
}
mysql_close($yhteys);
?>
Error in query:You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(pid) from games_requests' at line 1
Posted: Mon Mar 01, 2004 6:09 pm
by Shendemiar
I think i solved it:
I used:
count (pid)
Instead of:
count(pid)
I use phpmyadmin to formalize many of my queries, it saves typing, but now i see that i isnt allways that beneficial...
Posted: Mon Mar 01, 2004 10:27 pm
by EvilWalrus
PLease refrain from multiple postings... this is not IRC. Please reedit, or condense your original post with the new information next time.