Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Jan 2003
    Location
    Switzerland
    Posts
    9

    Angry Unanswered: Cannot write anything into Database

    Hello Together

    I'm not so expiried into MySQL, and so I've got a little Problem.
    I can connect trough PHP into the Database, it seams everything would
    be ok, PHP doesn't show any error. Until I want the create an entry.
    After the "creation" there's no entry in the Database and PHP and MySQL doens't show any error. What could be the reason?

    I attached the create_entry.php at this thread, just delete the ".zip"
    The follwings are the columns in the table

    Thnx in advanced
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2001
    Location
    NC
    Posts
    102
    I found only two minor problems

    1) Lines 1 and 2, eliminate coding
    FROM:
    <?php include("dbconnect.php");?>
    <?php
    TO:
    <?php include("dbconnect.php");

    2) Line 9, add coding
    FROM:
    mysql_query($query);
    TO:
    mysql_query($query) or die(mysql_error());

  3. #3
    Join Date
    Sep 2002
    Location
    Kyiv, Ukraine
    Posts
    77
    Everything is ok with the code, no mistakes that could cause the prevention of script's work. Look more properly into dbconnect.php and what data you actually pass to the query and if there are no problems with MySQL or PHP on the hosting server ...
    Yours faithfully,
    Yaroslav Zaremba

  4. #4
    Join Date
    Jan 2003
    Location
    Switzerland
    Posts
    9

    Wink

    The dbconnect.php works properly, but I'm not sure if the user has write privilege to the database. I can access to the database as root through php but even then i cannot write anything into. How can I create a user who can access to the database with write privilege, or shall I rtfm?

  5. #5
    Join Date
    Sep 2002
    Location
    Kyiv, Ukraine
    Posts
    77
    Something like "CREATE USER blah-blah-blah" should do it. Check the manual, I do not remember the actual syntax for this command.

    But indeed it's a strange thing that you can't write to DB with your root login. Check out your DB files' properties, some time ago I was restoring all my tables from CD-R and so they all had had read-only attributes after I copied them on my HDD. And I met with the same problem - MySQL was unable to write data to these tables under any user privileges ... After looking closely to the problem and removing 'read-only' attribute from all files everything began to work just fine.
    Yours faithfully,
    Yaroslav Zaremba

  6. #6
    Join Date
    Jan 2003
    Location
    Switzerland
    Posts
    9

    it instt create user

    So, i've visited the mysql.com webpage
    and i've found that the users are in a database written
    called mysql int the table user. So i wrote the new user
    with the command insert into user (host, user, password) .....
    but unfortunaly my Windows client crashed after restarting mysql (=> Bluescreen)(@ this moment i want to say "Thank you" to mister bill gates). So this time i'll install Linux with the whole repetoire.
    So I hope after installing linux and mysql and php this guestbook will work.

    So thnx for your help, I'll write again if I should have a problem again. *g*

    thnx a lot

  7. #7
    Join Date
    Jan 2003
    Location
    Switzerland
    Posts
    9
    I've got the same problem again.
    I've created the database wth phpMyAdmin with the table gaestebuch (name,ort,url,email,kommentar). And a user too, who's got insert and select rights. But even then It doenst want work. It isn't write protected and I corrected the two minor problem. (He doens't show any error)
    So i don't know anymore where the error could be. I attached the dbconnect.php. I thnx for your help in advanced.

    PS (rename the dbconnect.php.zip to dbconnect.php)

    Thanks a lot Karl

  8. #8
    Join Date
    Jan 2003
    Location
    Switzerland
    Posts
    9
    here's the file sorry
    Attached Files Attached Files

  9. #9
    Join Date
    Jan 2003
    Posts
    15
    Can you manually enter data into the database? For example, can u go into PHPAdmin and insert data?

  10. #10
    Join Date
    Jan 2003
    Location
    Switzerland
    Posts
    9
    Yes it's possibel.
    Could it be my Apache Webserver which makes some problem?

  11. #11
    Join Date
    Jan 2003
    Posts
    15
    This code will show you the errors if there are any:

    $result = mysql_query($dbQuery) or die("Query Failed
    \n".$dbQuery."
    \n".mysql_errno().": ".mysql_error());

    $dbQuery is your SQL Query name

  12. #12
    Join Date
    Jan 2003
    Location
    Switzerland
    Posts
    9
    What do you mean with

    SQL Query Name:
    Please Help


    <?php include("dbconnect.php");
    if ($submit == "Signieren!")
    {
    $query = " insert into gaestebuch (name,ort,email,url,kommentar) values
    ('$name', '$ort', '$email', '$url', '$kommentar')";
    mysql_query($query) or die(mysql_error());
    $result = mysql_query($query) or die("Query Failed
    \n".$query."
    \n".mysql_errno().": ".mysql_error());


    <h2>Danke!!</h2>
    <h2><a href="view.php">Sehen Sie mein Gästebuch an!!!</a></h2>
    <?php
    }
    else
    {
    include("view.php");
    }
    ?>

  13. #13
    Join Date
    Jan 2003
    Posts
    15
    Basically, that code I gave you shows the user any errors.

    Are u getting any errors?

  14. #14
    Join Date
    Jan 2003
    Location
    Switzerland
    Posts
    9
    Hello

    There was no error, unfortunately.
    So could it be, that the table is wrong?
    name varchar(40) null
    ort varchar(40) null
    email varchar(40) null
    url varchar(40) null
    kommentar text null
    I don't think so, cause i've got this tutorial from a book, and it would be very strange if there would be a false. but it could be possible.

    Thnx for your help

  15. #15
    Join Date
    Jan 2003
    Posts
    15
    Are you entering any data which is > 40 characters?

    print off your SQL query:

    $query = " insert into gaestebuch (name,ort,email,url,kommentar) values
    ('$name', '$ort', '$email', '$url', '$kommentar')";

    echo $query;

    mysql_query($query) or die(mysql_error());
    $result = mysql_query($query) or die("Query Failed
    \n".$query."
    \n".mysql_errno().": ".mysql_error());

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •