|
-
Oct 18th, 2001, 02:03 AM
#1
Thread Starter
Lively Member
if you know mysql and php, please help!
this is suppost to connet to my database, and insert data into the table. but as far as it goes is connecting. after that it dies, it will not query the table add data or anything. It just dies! WHY!? It dies right there on the $db = @mysql_select($db_name, $connection) or die ("cannot select");
Code:
// database functions
$db_name = "photos";
$table_name = "data";
$connection = @mysql_connect("localhost", "xxxxx", "xxxxx") or die ("cannot connect");
$db = @mysql_select($db_name, $connection) or die ("cannot select");
$sql = "
INSERT INTO $table_name(set_id, locate, name)
VALUES
(\"$abox\", \"$bbox\", \"$cbox\")
";
$result = @mysql_query($sql, $connection) or die ("cannot connect");
?>
all this thing produces is cannot select.
Does it matter that I have yet to set a user name and password for this stuff? I just use localhost nothing else. the x's here represent where t he user name and password should be.
Last edited by evil_gamer; Oct 18th, 2001 at 02:06 AM.
If you think I am wierd, then thats YOUR problem!
-----------------------------------
I keep snakes and lizards, wanna know more? PM me 
-
Oct 18th, 2001, 02:46 AM
#2
Conquistador
Re: if you know mysql and php, please help!
PHP Code:
// database functions
$db_name = "photos";
$table_name = "data";
$connection = @mysql_connect("", "", "") or die ("cannot connect");
$db = @mysql_select($db_name, $connection) or die ("cannot select");
$sql = "
INSERT INTO $table_name(set_id, locate, name)
VALUES
(\"$abox\", \"$bbox\", \"$cbox\")
";
$result = @mysql_query($sql, $connection) or die ("cannot connect");
?>
Should work now 
Are you running this locally?
-
Oct 18th, 2001, 12:54 PM
#3
Thread Starter
Lively Member
Yes, I am running this localy on a linux machine. I have thought about putting this stuff on windows to develop then move it to my linux machine (web server)
If you think I am wierd, then thats YOUR problem!
-----------------------------------
I keep snakes and lizards, wanna know more? PM me 
-
Oct 18th, 2001, 02:59 PM
#4
how are you connecting to the database if you don't have a username or password? As far as I know you have to have one. even though you are the only one to write to it. I have one but I had to make it as root and still needed a password.
and
$connection = @mysql_connect("", "", "") or die ("cannot connect");
$db = @mysql_select($db_name, $connection) or die ("cannot select");
why are you connecting twice?
just have it
$connection = @mysql_connect("localhost", "username", "password") or die ("cannot connect");
$db = @mysql_select($db_name) or die ("cannot select");
also when you run teh result you don't have to connect to it again. it should be still connected to it.
-
Oct 18th, 2001, 05:19 PM
#5
Conquistador
His code isn't connecting again.
Hie code is just executing another query isn't it?
-
Oct 18th, 2001, 05:57 PM
#6
I don't know that is why I asked. it looks like it is when you
PHP Code:
// you are connecting here, right
$connection = @mysql_connect("", "", "") or die ("cannot connect");
// then you select the database and connect again. hence the $db_name, $connection part.
$db = @mysql_select($db_name, $connection) or die ("cannot select");
maybe it doesn't and it just looks funny. I always use it this way
PHP Code:
mysql_connect($sql_loc, $sql_username, $sql_password) or die();
mysql_select_db($db) or die();
$result=mysql_query("select * from " . $db_table . " order by id desc") or die();
-
Oct 19th, 2001, 02:04 AM
#7
Thread Starter
Lively Member
Re: Re: if you know mysql and php, please help!
Originally posted by da_silvy
PHP Code:
// database functions
$db_name = "photos";
$table_name = "data";
$connection = @mysql_connect("", "", "") or die ("cannot connect");
$db = @mysql_select($db_name, $connection) or die ("cannot select");
$sql = "
INSERT INTO $table_name(set_id, locate, name)
VALUES
(\"$abox\", \"$bbox\", \"$cbox\")
";
$result = @mysql_query($sql, $connection) or die ("cannot connect");
?>
Should work now 
Are you running this locally?
got a fatal error on line 7 call to undefined function mysql_select()
If you think I am wierd, then thats YOUR problem!
-----------------------------------
I keep snakes and lizards, wanna know more? PM me 
-
Oct 19th, 2001, 02:53 AM
#8
Conquistador
It works on windows?
Don't know why it wouldn't work on Linux
try taking the '@' away from the front of the statement?
-
Oct 19th, 2001, 08:01 AM
#9
Thread Starter
Lively Member
Originally posted by da_silvy
It works on windows?
Don't know why it wouldn't work on Linux
try taking the '@' away from the front of the statement?
yeah, I removed the "@" so I could see if it was actualy working and it tossed the error at me. Maybe I screwed up the installation (again ) !?
If you think I am wierd, then thats YOUR problem!
-----------------------------------
I keep snakes and lizards, wanna know more? PM me 
-
Oct 19th, 2001, 10:40 AM
#10
Thread Starter
Lively Member
I got it!!!!!
I got it working! It was the username/password junk so I added a username and password in mysql and got it working. Its a good thing I shaved my head, cause I would of done pulled out all my hair on this one.
Thanks for the help every body. I am going to go kick my self for this one
If you think I am wierd, then thats YOUR problem!
-----------------------------------
I keep snakes and lizards, wanna know more? PM me 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|