Jump to content


Photo

not a valid MySQL???


  • Please log in to reply
19 replies to this topic

#1 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 19 April 2003 - 05:59 PM

my error

Warning: Supplied argument is not a valid MySQL result resource in c:apachehtdocsadminedituser.php on line 4

my code
[php:1:ff6f2dbf6b]<?php
$info_query = mysql_query(\"SELECT * FROM users WHERE id=\'$id\'\");
$result = mysql_query($info_query);
$info = mysql_fetch_array($info_query)[/php:1:ff6f2dbf6b]
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#2 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 19 April 2003 - 06:10 PM

your query failed.

use something like this to check for that and avoid the errors:[php:1:557323ef68]if ($result==FALSE)
{
# query failed.. do this
print \"QUERY FAILED<br>\".mysql_error();
}
else
{
# query was successful
$info = mysql_fetch_array($info_query);
}[/php:1:557323ef68]

basically just remember that mysql_query returns a result handler on success, FALSE on failure. you can use this method to avoid the ugly errors ;)

hope that helps.

#3 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 19 April 2003 - 06:35 PM

your query failed.

use something like this to check for that and avoid the errors:[php:1:538252109a]if ($result==FALSE)
{
 # query failed.. do this
 print \\\"QUERY FAILED<br>\\\".mysql_error();
}
else
{
 # query was successful
 $info = mysql_fetch_array($info_query);
}[/php:1:538252109a]

basically just remember that mysql_query returns a result handler on success, FALSE on failure. you can use this method to avoid the ugly errors ;)

hope that helps.


ahhh
thx man

at least somebody knows some SQL
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#4 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 19 April 2003 - 06:50 PM

ok
I figured out WHY the result was false (didn\'t connect to the database lol)
but....

when I include() or require() or just copy my database connection onto the page I get this...

You have an error in your SQL syntax near \'Resource id #2\' at line 1

but when I remove the code to connect to the database...
its fine
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#5 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 19 April 2003 - 10:19 PM

you should get no SQL syntax errors when connecting to the db ;)

can you show me how exactly you\'re connecting?

#6 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 20 April 2003 - 12:52 AM

you should get no SQL syntax errors when connecting to the db ;)

can you show me how exactly you\'re connecting?


thats the thing
thats not the problem b/c if it was then I\'d be getting that same error on all of the pages that I use that connection with

that connection is in my functions.php page
and I use require on all my pages to get that connection

when I use require or include on this new page
I get that weird error
so I copied the connection code over and replaced the require/include
same error

I remove it
no errors

so I can see it\'d be natural to think it was my connection
but thats just it
it can\'t be b/c I don\'t get that error on ANY other page that I required functions.php from
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#7 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 20 April 2003 - 01:41 AM

you\'re positive you have 0 queries executed in functions.php ?

it would help to see some code.

#8 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 20 April 2003 - 01:52 AM

you\'re positive you have 0 queries executed in functions.php ?

it would help to see some code.


*shrugs*

alright

fucntions.php (part of it)
[php:1:9a06a29786]
<?php
$location = \"localhost\";
$username = \"DarthViper3k\";
$password = \"\"; //password removed
$database = \"admin\";

$conn = mysql_connect(\"$location\",\"$username\",\"$password\");
if (!$conn) die (\"Could not connect MySQL\");
mysql_select_db($database,$conn) or die (\"Could not open database\");
[/php:1:9a06a29786]

[php:1:9a06a29786]
<?php
require(\"fucntions.php\");

$info_query = mysql_query(\"SELECT * FROM users WHERE id=\'$id\'\");
$result = mysql_query($info_query);
if ($result==FALSE)
{
# query failed.. do this
print \"QUERY FAILED<br>\".mysql_error();
}
else
{
# query was successful
$info = mysql_fetch_array($info_query);
}
?>[/php:1:9a06a29786]

I know I missspelled functions
but I spelled it like that when I made the file
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#9 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 20 April 2003 - 02:20 AM

There\'s absolutely nothing wrong with that code.

Going back over the error, where would \"Resource id #2\" come from? The error looks like there\'s an attempt to query the database where \"Resource id #2\" is in the query.. any idea?

#10 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 20 April 2003 - 02:22 AM

There\'s absolutely nothing wrong with that code.

Going back over the error, where would \\\"Resource id #2\\\" come from? The error looks like there\'s an attempt to query the database where \\\"Resource id #2\\\" is in the query.. any idea?


I don\'t have a \"Resource id #2\" as a query though ANYWHERE

I\'ve never see that error before
and I only get it when I try to connect to the database
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#11 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 20 April 2003 - 02:41 AM

Using this, do you still get an error:[php:1:521bbbb532]<?php

$location = \"localhost\";
$username = \"DarthViper3k\";
$password = \"\"; //password removed
$database = \"admin\";

$conn = mysql_connect(\"$location\",\"$username\",\"$password\");
if ($conn==FALSE) die (\"Could not connect MySQL\");
$db = mysql_select_db($database,$conn);
if ($db==FALSE) die (\"Could not open database\");

$info_query = mysql_query(\"SELECT * FROM users WHERE id=\'$id\'\");
$result = mysql_query($info_query);
if ($result==FALSE)
{
# query failed.. do this
print \"QUERY FAILED<br>\".mysql_error();
}
else
{
# query was successful
$info = mysql_fetch_array($info_query);
}

?>[/php:1:521bbbb532]

This sure is frustrating ;)

#12 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 20 April 2003 - 02:56 AM

Using this, do you still get an error:[php:1:8c5c88e16b]<?php

$location = \\\"localhost\\\";
$username = \\\"DarthViper3k\\\";
$password = \\\"\\\"; //password removed
$database = \\\"admin\\\";

$conn = mysql_connect(\\\"$location\\\",\\\"$username\\\",\\\"$password\\\");
if ($conn==FALSE) die (\\\"Could not connect MySQL\\\");
$db = mysql_select_db($database,$conn);
if ($db==FALSE) die (\\\"Could not open database\\\");

$info_query = mysql_query(\\\"SELECT * FROM users WHERE id=\'$id\'\\\");
$result = mysql_query($info_query);
if ($result==FALSE)
{
 # query failed.. do this
 print \\\"QUERY FAILED<br>\\\".mysql_error();
}
else
{
 # query was successful
 $info = mysql_fetch_array($info_query);
}

?>[/php:1:8c5c88e16b]

This sure is frustrating ;)


yup
the only time I don\'t get that error is if I leave out the connection to the database
however
I need that connection in order for this page to work properly

its part of the admin panel
and this is the \"Edit Users Profile\" page

edit: and I agree
it is VERY frustraiting
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#13 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 20 April 2003 - 03:35 AM

ok start narrowing it down.. does this cause an error?[php:1:61e98c0148]<?php

$location = \"localhost\";
$username = \"DarthViper3k\";
$password = \"\"; //password removed
$database = \"admin\";

$conn = mysql_connect(\"$location\",\"$username\",\"$password\");
if ($conn==FALSE) die (\"Could not connect MySQL\");
$db = mysql_select_db($database,$conn);
if ($db==FALSE) die (\"Could not open database\");

?>[/php:1:61e98c0148]

#14 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 20 April 2003 - 05:42 AM

ok start narrowing it down.. does this cause an error?[php:1:e46a5ffdac]<?php  

$location = \\\"localhost\\\";
$username = \\\"DarthViper3k\\\";
$password = \\\"\\\"; //password removed
$database = \\\"admin\\\";

$conn = mysql_connect(\\\"$location\\\",\\\"$username\\\",\\\"$password\\\");
if ($conn==FALSE) die (\\\"Could not connect MySQL\\\");
$db = mysql_select_db($database,$conn);
if ($db==FALSE) die (\\\"Could not open database\\\");

?>[/php:1:e46a5ffdac]


nope it doesn\'t
nothing wrong with that

thats what I was saying before
I\'m using that code on a lot of pages (by including it) so thats not the problem

the rest of it has no problems either
I\'ve already done some narrowing down of it

none of it causes an error unless I try to connect to the database
I\'ve been talkin with other peeps
nobody has ever seen it before
and all I hear is \"it doesn\'t make sense\"

so...
I\'m guessing its one of the many bugs that has never been seen before and will hopefuly be fixed once I get this reported

thats the only logical explaination I can come up with
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#15 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 20 April 2003 - 06:09 AM

none of it causes an error unless I try to connect to the database

that code does in fact connect to the database.

try creating a new file (test.php) and use this code:[php:1:34891f45c8]<?php

$location = \"localhost\";
$username = \"DarthViper3k\";
$password = \"\"; //password removed
$database = \"admin\";

$conn = mysql_connect($location,$username,$password);
if ($conn==FALSE) die (\"Could not connect MySQL\");
$db = mysql_select_db($database,$conn);
if ($db==FALSE) die (\"Could not open database\");

$query = mysql_query(\"SELECT * FROM users\",$conn);
if ($query==FALSE)
{
print \"<code><b>ERROR :</b> QUERY FAILED<br>\".mysql_error().\"</code>\";
}
else
{
print \"Found \".mysql_num_rows($query).\" record(s)\";
}

mysql_close($conn);

?>[/php:1:34891f45c8]

if you get no errors then there\'s something stray in this page you\'re having trouble with. let us know what happens.

#16 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 20 April 2003 - 07:25 AM

none of it causes an error unless I try to connect to the database

that code does in fact connect to the database.

try creating a new file (test.php) and use this code:[php:1:d7338bb9c4]<?php

$location = \"localhost\";
$username = \"DarthViper3k\";
$password = \"\"; //password removed
$database = \"admin\";

$conn = mysql_connect($location,$username,$password);
if ($conn==FALSE) die (\"Could not connect MySQL\");
$db = mysql_select_db($database,$conn);
if ($db==FALSE) die (\"Could not open database\");

$query = mysql_query(\"SELECT * FROM users\",$conn);
if ($query==FALSE)
{
print \"<code><b>ERROR :</b> QUERY FAILED<br>\".mysql_error().\"</code>\";
}
else
{
print \"Found \".mysql_num_rows($query).\" record(s)\";
}

mysql_close($conn);

?>[/php:1:d7338bb9c4]

if you get no errors then there\'s something stray in this page you\'re having trouble with. let us know what happens.


not a single error
but
what would be causing the problems??
I can\'t find anything there thats causing the problem
can you?
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#17 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 20 April 2003 - 06:09 PM

I don\'t know.. there\'s nothing wrong with what you\'ve showed me so far.
If it\'s not in functions.php , it\'s in this file you\'re having trouble with.
I don\'t know what else to say.. you\'ve only showed me bits of the code.

#18 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 20 April 2003 - 06:59 PM

I don\'t know.. there\'s nothing wrong with what you\'ve showed me so far.
If it\'s not in functions.php , it\'s in this file you\'re having trouble with.
I don\'t know what else to say.. you\'ve only showed me bits of the code.


I\'ve shown you all of the PHP on the page

everything else (so far at least) is HTML

edit: if you want I can send you the files themselves
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#19 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 20 April 2003 - 07:18 PM

sure.. email them to me: laggor@phirebrush.com

#20 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 21 April 2003 - 02:28 AM

thx for tryin to help metalblend

I talked to effigy and he solved my problem
I was doin something stupid
lol
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users