
- You are not logged in. | Login
January 18, 2007 8:07 am
- selmahyekishot
- Member


Where is mistake in the query?
Query looks like as follows:
$query = "SELECT 'name' FROM 'mytable' WHERE 'id_razdel'='1'";
script shows the following message:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in ....number of the line with that query
I can't understand where is a mistake?
January 18, 2007 8:10 am
- PHPprof
- Member


Re: Where is mistake in the query?
All fields and tables are in `
PHP code:
SELECT `name` FROM `table` ...
I'll come to win... wait...
January 18, 2007 8:22 am
- phppat
- Member


Re: Where is mistake in the query?
Pay attention to inverted commas!!!!!!! `name` и 'name' are different things. You need inverted commas which are situated near key 1
PHP monster
January 18, 2007 8:27 am
- selmahyekishot
- Member


Re: Where is mistake in the query?
I have changed inverted commas and case.
$query = "SELECT `name` FROM `mytable` WHERE `razdel`=1";
$result=mysql_query($query, $db);
Also I added the checking:
$db_c=mysql_connect($db_server,$db_user,$db_pas);
if (!$db_c) echo("Connection to database!!!");
$db=mysql_select_db($db_name,$db_c);
if (!$db) echo("database selection!!!");
These messages don't appear, so the reason is not the connection to the database. Nevertheless there is the same error!
January 18, 2007 8:43 am
- reetesh
- Member


Re: Where is mistake in the query?
Try this:
$result=mysql_query($query) or die(mysql_error());
What does it write?
January 18, 2007 8:46 am
- selmahyekishot
- Member


Re: Where is mistake in the query?
I changed everything you advised
$db=mysql_connect($db_server,$db_user,$db_pas) or die (mysql_error());
$res=mysql_select_db($db_name,$db) or die (mysql_error());
line 13: $query = "SELECT `name` FROM `mytable` WHERE `razdel`=1";
line 14: $result=mysql_query($query, $db) or die(mysql_error());
Appears an error:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /.../script's name.php on line 14
There areno other errors
January 18, 2007 8:49 am
- PHPprof
- Member


Re: Where is mistake in the query?
Hmmmm, what happens till the 13 line.
Are you sure that $db isn't redefined somewhere?
I'll come to win... wait...
January 18, 2007 8:51 am
- selmahyekishot
- Member


Re: Where is mistake in the query?
There is a checking of variables, then include with connection to the database. That's it
January 18, 2007 8:53 am
- selmahyekishot
- Member


Re: Where is mistake in the query?
I deleted $db in the line 14, now:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/.../public_html/script.php on line 15
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/...l/public_html/script.php on line 15
Access denied for user 'nobody'@'localhost' (using password: NO)
January 18, 2007 8:55 am
- PHPprof
- Member


Re: Where is mistake in the query?
selmahyekishot, create a database user and give him permissions.
by the way what are the values of the "$db_server,$db_user,$db_pas" variables?
I'll come to win... wait...


