Results 1 to 10 of 10

Thread: if you know mysql and php, please help!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Posts
    82

    Unhappy 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

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    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?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Posts
    82
    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

  4. #4
    scoutt
    Guest
    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.

  5. #5
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Question

    His code isn't connecting again.

    Hie code is just executing another query isn't it?

  6. #6
    scoutt
    Guest
    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(); 

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Posts
    82

    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

  8. #8
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    It works on windows?

    Don't know why it wouldn't work on Linux

    try taking the '@' away from the front of the statement?

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Posts
    82
    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

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Posts
    82

    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
  •  



Click Here to Expand Forum to Full Width