[Solved] Strange count 'error'
Moderator: General Moderators
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
[Solved] Strange count 'error'
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...
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...
Last edited by Shendemiar on Tue Mar 02, 2004 4:55 pm, edited 1 time in total.
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
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?
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?
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
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
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
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
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...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
I think it's good to keep maximum error reporting while im trying to learn it...
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
Ä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
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
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
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:
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
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);
?>-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
- EvilWalrus
- Site Admin
- Posts: 209
- Joined: Thu Apr 18, 2002 3:21 pm
- Location: Springmont, PA USA