Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
nick2
- Forum Contributor
- Posts: 118
- Joined: Fri Jul 25, 2003 2:34 pm
Post
by nick2 »
everytime I try and register it tells me:
No database selected
heres my code:
Code: Select all
<?php
<?php
##Edit db details here##
$dbname = "slices_net";
$table_name = "tsusers";
$connection = @mysql_connect("localhost", "username" , "password")
or die(mysql_error());
##Stop editing db details##
$db = @mysql_select_db($db_name, $connection) or die(mysql_error() );
#
$sql = "INSERTINTO $table_name (ID, password, name, location, email, signature) VALUES ('$_POST[ID]',
password('$_POST[password]'), '$_POST[name]', '$_POST[location]', '$_POST[email]', '$_POST[signature]')";
#
$result = @mysql_query($sql,$connection) or die(mysql_error());
#
?>
?>
-
jmarcv
- Forum Contributor
- Posts: 131
- Joined: Tue Jul 29, 2003 7:17 pm
- Location: Colorado
Post
by jmarcv »
Odd.
Looks good to me. You sure you have a slices_net?
-
nick2
- Forum Contributor
- Posts: 118
- Joined: Fri Jul 25, 2003 2:34 pm
Post
by nick2 »
yes my main table is slices_net
-
nielsene
- DevNet Resident
- Posts: 1834
- Joined: Fri Aug 16, 2002 8:57 am
- Location: Watertown, MA
Post
by nielsene »
Try removing the '@'s to stop the surpression of errors/warnings.
-
nick2
- Forum Contributor
- Posts: 118
- Joined: Fri Jul 25, 2003 2:34 pm
Post
by nick2 »
nielsene wrote:Try removing the '@'s to stop the surpression of errors/warnings.
nope, same thing.
could it be because I made my fields .. maybe I made them wrong?
I dunno help!

Last edited by
nick2 on Wed Jul 30, 2003 11:41 pm, edited 1 time in total.
-
jmarcv
- Forum Contributor
- Posts: 131
- Joined: Tue Jul 29, 2003 7:17 pm
- Location: Colorado
Post
by jmarcv »
Good point nielsene
probably isn't even getting a connection. Missed that one.
-
nick2
- Forum Contributor
- Posts: 118
- Joined: Fri Jul 25, 2003 2:34 pm
Post
by nick2 »
help me please... its not connecting to slices_net table why?!
-
nielsene
- DevNet Resident
- Posts: 1834
- Joined: Fri Aug 16, 2002 8:57 am
- Location: Watertown, MA
Post
by nielsene »
Check the name of your db_name variables....
One place you use $dbname, another you use $db_name.... they are not the same, so you are selecting the database named "" (empty).....
-
jmarcv
- Forum Contributor
- Posts: 131
- Joined: Tue Jul 29, 2003 7:17 pm
- Location: Colorado
Post
by jmarcv »
Oh my god, nielsene
Thats 2! Must be the beer.
P.S. what's with the
>help me please... its not connecting to slices_net table why?!
I could almost feel the tears...
-
nick2
- Forum Contributor
- Posts: 118
- Joined: Fri Jul 25, 2003 2:34 pm
Post
by nick2 »
neisele it worked thanks bud!
one more problem:
You have an error in your SQL syntax near 'INSERTINTO trading (ID, password, name, location, email, signature) VALUES ('Nic' at line 1
-
jmarcv
- Forum Contributor
- Posts: 131
- Joined: Tue Jul 29, 2003 7:17 pm
- Location: Colorado
Post
by jmarcv »
Got that one! You need a space between the word INSERT and the word INTO.
Surely you noticed that?
-
nielsene
- DevNet Resident
- Posts: 1834
- Joined: Fri Aug 16, 2002 8:57 am
- Location: Watertown, MA
Post
by nielsene »
INSERTINTO ---> INSERT INTO
(missing a space)
-
nick2
- Forum Contributor
- Posts: 118
- Joined: Fri Jul 25, 2003 2:34 pm
Post
by nick2 »
what would I do without you guys?
thanks!!!!!!!!!!
-
jmarcv
- Forum Contributor
- Posts: 131
- Joined: Tue Jul 29, 2003 7:17 pm
- Location: Colorado
Post
by jmarcv »
uhh.... get another job?
dunno! Dats why we hea!
-
nick2
- Forum Contributor
- Posts: 118
- Joined: Fri Jul 25, 2003 2:34 pm
Post
by nick2 »
need ya again..
login related
I get parse error on line 19, which is } else { where in the code is it getting corrupted?
Code: Select all
<?php
<?php
$db_name = "slices_net";
$table_name = "trading";
#
$connection = mysql_connect("localhost", "slices", "thibault1")
or die(mysql_error());
#
$db = mysql_select_db($db_name, $connection) or die(mysql_error());
#
$sql = "SELECT * FROM $table_name WHERE ID = '$_POST[ID]' AND
password = password('$_POST[password]')";
#
$result = mysql_query($sql,$connection) or die(mysql_error());
#
$num = mysql_num_rows($result);
#
if ($num != 0) {
$msg = "<P>You're now logged in!</P>"
} else {
header("location: Http://slices.net/tradingsystem/login.php");
exit;
}
?>
?>