Jump to content

not a valid MySQL???


DarthViper3k

Recommended Posts

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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.