PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Mon Mar 06, 2006 4:02 pm
feyd | Please use Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I get this error:Code: Select all
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource on line 50
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource on line 51
Thank you! Information entered.
The connect.php file has my connection script, which looks like this:
Code: Select all
<?php
$dbh=mysql_connect ("localhost", "*****", "****") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("****");
?>
feyd | Please use Code: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Last edited by
Citizen on Tue Mar 07, 2006 1:37 pm, edited 1 time in total.
neophyte
DevNet Resident
Posts: 1537 Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota
Post
by neophyte » Mon Mar 06, 2006 4:58 pm
Check db user name and password... Likely as not, that's your problem! Good luck...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Mar 06, 2006 5:05 pm
ahem, $db vs $dbh
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Tue Mar 07, 2006 2:22 am
I tried the advice you just gave me, but nothing that I try seems to work. What exactly do I need to change?
s.dot
Tranquility In Moderation
Posts: 5001 Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana
Post
by s.dot » Tue Mar 07, 2006 2:27 am
like feyd said
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Tue Mar 07, 2006 9:49 am
Ok, I made the changes and I'm getting this error now:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource on line 50
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource on line 51
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource on line 62
Thank you! Information entered.
Contents of the connect.php file:
Code: Select all
<?php
$dbh=mysql_connect ("localhost", "db_name", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("db_name");
echo 'Connected successfully';
?>
On the pages, it does echo "connected sucessfully"
Last edited by
Citizen on Tue Mar 07, 2006 1:37 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 07, 2006 10:43 am
your php doesn't like $dbh being passed to
mysql_query() , try removing them. They often aren't needed anyways.
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Tue Mar 07, 2006 10:59 am
Thanks!
Line 51 is:
$samenick = mysql_num_rows($result);
BTW, do you take donations? I dont have a lot, but I could toss a buck or two your way.
Last edited by
Citizen on Tue Mar 07, 2006 1:36 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 07, 2006 11:11 am
your SQL has an error in it..
'accounts'
vs
`accounts`
notice:
' and `
Citizen wrote: BTW, do you take donations? I dont have a lot, but I could toss a buck or two your way.
The forum does not take donations at this time. However individual users may be open to it.
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Tue Mar 07, 2006 11:21 am
feyd wrote: your SQL has an error in it..
'accounts'
vs
`accounts`
notice: ' and `
Also,
feyd wrote:
Citizen wrote: BTW, do you take donations? I dont have a lot, but I could toss a buck or two your way.
The forum does not take donations at this time. However individual users may be open to it.
I meant you, not the forum itself
Last edited by
Citizen on Tue Mar 07, 2006 1:35 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 07, 2006 11:29 am
check what
mysql_error() outputs, you likely need to backtick "name" and should probably escape $name (
mysql_real_escape_string() )
regarding donations, check your private messages.
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Tue Mar 07, 2006 12:32 pm
I'm not exactly sure what I need to do. I'm pretty new to php and mysql. What do I need to change?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 07, 2006 12:37 pm
basics:
Code: Select all
<?php
//........
$result=mysql_query($sql);
//........
?>to
Code: Select all
<?php
//........
$result=mysql_query($sql) or die(mysql_error());
//........
?>
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Tue Mar 07, 2006 12:43 pm
Thanks. I got this error back....
"No Database Selected" but I didnt see any other errors.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 07, 2006 12:49 pm
Make sure the database you're requesting exists and that the function is being called.