Page 1 of 2
Need Help with Simple Registration Form
Posted: Mon Mar 06, 2006 4:02 pm
by Citizen
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]
Posted: Mon Mar 06, 2006 4:58 pm
by neophyte
Check db user name and password... Likely as not, that's your problem! Good luck...
Posted: Mon Mar 06, 2006 5:05 pm
by feyd
ahem, $db vs $dbh
Posted: Tue Mar 07, 2006 2:22 am
by Citizen
I tried the advice you just gave me, but nothing that I try seems to work. What exactly do I need to change?
Posted: Tue Mar 07, 2006 2:27 am
by s.dot
like feyd said
Posted: Tue Mar 07, 2006 9:49 am
by Citizen
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"
Posted: Tue Mar 07, 2006 10:43 am
by feyd
your php doesn't like $dbh being passed to
mysql_query(), try removing them. They often aren't needed anyways.
Posted: Tue Mar 07, 2006 10:59 am
by Citizen
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.
Posted: Tue Mar 07, 2006 11:11 am
by feyd
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.

Posted: Tue Mar 07, 2006 11:21 am
by Citizen
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

Posted: Tue Mar 07, 2006 11:29 am
by feyd
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.
Posted: Tue Mar 07, 2006 12:32 pm
by Citizen
I'm not exactly sure what I need to do. I'm pretty new to php and mysql. What do I need to change?
Posted: Tue Mar 07, 2006 12:37 pm
by feyd
basics:
Code: Select all
<?php
//........
$result=mysql_query($sql);
//........
?>
to
Code: Select all
<?php
//........
$result=mysql_query($sql) or die(mysql_error());
//........
?>
Posted: Tue Mar 07, 2006 12:43 pm
by Citizen
Thanks. I got this error back....
"No Database Selected" but I didnt see any other errors.
Posted: Tue Mar 07, 2006 12:49 pm
by feyd
Make sure the database you're requesting exists and that the function is being called.