Datenbank verbindung fehlgeschlagen ? -.-

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Schönen guten Morgen.
    Ich habe ein kleines Problem. Ich habe mir jetzt nach dem Tutorial von Maddin ein Script erstellt. Nun
    möchte ich dies testen, doch mein Problem ist ich habe per Navicat eine Datenbank erstellt & per Xampp
    den MySql server gestartet. Doch ich bekomme jedes mal gesagt, das die Verbindung fehlgeschlagen ist ? -.-


    Ich hoffe ihr könnt mir helfen :S


    //EDIT Daten sind so eingetragen


    "127.0.0.1"
    "root"
    ""
    "test"


    & in Navicat siehts soo aus:



    DB
    information schema
    mysql
    test
    Table ... hier ist die accounts drinne

  • Kommt das bei rum


    [04:45:53] CMySQLHandler::~CMySQLHandler() - deconstructor called.


    [04:45:53] CMySQLHandler::FreeResult() - The result is already empty.


    [04:45:53] CMySQLHandler::Disconnect() - Connection was closed.


  • setzte das vor dem Connect_To_Database();


    und dann starten (nach kompilieren)


    dann Debug.txt lesen


    solltest du dann immer noch nicht schlauer sein Connect_To_Database posten und den neuen Text


    Bedanke dich bitte, wenn du den Beitrag als hilfreich empfandest!



  • do.de - Domain-Offensive - Domains für alle und zu super Preisen

  • Spuckt er das aus:


    04:53:02] CMySQLHandler::CMySQLHandler() - constructor called.


    [04:53:02] CMySQLHandler::CMySQLHandler() - Connecting to "127.0.0.1" | DB: "test" | Username: "root" ...


    [04:53:02] CMySQLHandler::Connect() - Connection was successful.


    [04:53:02] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.


    [04:53:02] >> mysql_ping( Connection handle: 83056 )


    [04:53:02] >> mysql_ping() - Invalid connection handle. (You set: 83056, Highest connection handle ID is 1).


    [04:53:02] >> mysql_connect( )


    [04:53:02] CMySQLHandler::Connect() - Connection was successful.


    [04:53:02] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.


    [04:53:02] >> mysql_ping( Connection handle: 83056 )


    [04:53:02] >> mysql_ping() - Invalid connection handle. (You set: 83056, Highest connection handle ID is 1).


    [04:53:02] CMySQLHandler::~CMySQLHandler() - deconstructor called.


    [04:53:02] CMySQLHandler::FreeResult() - The result is already empty.


    [04:53:02] CMySQLHandler::Disconnect() - Connection was closed.

  • Bitteschön.


    stock Connect_To_Database()
    {
    mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS); //Wir versuchen mit den Angaben die wir oben im Script gemacht haben uns mit dem MySQL Server zu verbinden.
    if(mysql_ping() == 1) //Es wird überprüft ob die Verbindung steht.
    {
    //Falls ja wird das in die Console geschrieben und die Funktion wird beendet.
    print("<-| [MYSQL] Verbindung zur Datenbank wurde erfolgreich hergestellt!");
    return true;
    }
    else
    {
    //Falls nicht wird erneut versucht eine verbindung aufzubauen.
    print("<-| [MYSQL] Es konnte keine Verbindung zur Datenbank hergestellt werden!");
    print("<-| [MYSQL] Es wird erneut versucht eine Verbindung zur Datenbank herzustellen!");
    mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS);
    if(mysql_ping() == 1)
    {
    print("<-| [MYSQL] Es konnte im 2 Versuch eine Verbindung hergestellt werden!");
    return true;
    }
    else
    {
    //Falls das auch nicht Funktioniert wird der Server zur Sicherheit wieder heruntergefahren.
    print("<-| [MYSQL] Es konnte keine Verbindung zur Datenbank hergestellt werden!");
    print("<-| [MYSQL] Der Server wird nun beendet!");
    SendRconCommand("exit");
    return true;
    }
    }
    }

  • mach mal nur so:



    stock Connect_To_Database()
    {
    mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS); //Wir versuchen mit den Angaben die wir oben im Script gemacht haben uns mit dem MySQL Server zu verbinden.
    }


    Bedanke dich bitte, wenn du den Beitrag als hilfreich empfandest!



  • S

    debug log


    Sri :S


    [04:57:20] >> mysql_connect( )


    [04:57:20] CMySQLHandler::CMySQLHandler() - constructor called.


    [04:57:20] CMySQLHandler::CMySQLHandler() - Connecting to "127.0.0.1" | DB: "test" | Username: "root" ...


    [04:57:20] CMySQLHandler::Connect() - Connection was successful.


    [04:57:20] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.


    [04:58:05] >> mysql_real_escape_string( Connection handle: 75 )


    [04:58:05] >> mysql_real_escape_string() - Invalid connection handle. (You set: 75, Highest connection handle ID is 1).


    [04:58:05] >> mysql_query( Connection handle: 51 )


    [04:58:05] >> mysql_query() - Invalid connection handle. (You set: 51, Highest connection handle ID is 1).


    [04:58:05] >> mysql_store_result( Connection handle: 75 )


    [04:58:05] >> mysql_store_result() - Invalid connection handle. (You set: 75, Highest connection handle ID is 1).


    [04:58:05] >> mysql_num_rows( Connection handle: 75 )


    [04:58:05] >> mysql_num_rows() - Invalid connection handle. (You set: 75, Highest connection handle ID is 1).


    [04:58:11] >> mysql_real_escape_string( Connection handle: 75 )


    [04:58:11] >> mysql_real_escape_string() - Invalid connection handle. (You set: 75, Highest connection handle ID is 1).


    [04:58:11] >> mysql_real_escape_string( Connection handle: 75 )


    [04:58:11] >> mysql_real_escape_string() - Invalid connection handle. (You set: 75, Highest connection handle ID is 1).


    [04:58:11] >> mysql_query( Connection handle: 51 )


    [04:58:11] >> mysql_query() - Invalid connection handle. (You set: 51, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_query( Connection handle: 80 )


    [04:58:27] >> mysql_query() - Invalid connection handle. (You set: 80, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_query( Connection handle: 80 )


    [04:58:27] >> mysql_query() - Invalid connection handle. (You set: 80, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_query( Connection handle: 80 )


    [04:58:27] >> mysql_query() - Invalid connection handle. (You set: 80, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_real_escape_string( Connection handle: 0 )


    [04:58:27] >> mysql_real_escape_string() - Invalid connection handle. (You set: 0, Highest connection handle ID is 1).


    [04:58:27] >> mysql_query( Connection handle: 80 )


    [04:58:27] >> mysql_query() - Invalid connection handle. (You set: 80, Highest connection handle ID is 1).


    [04:59:11] >> mysql_real_escape_string( Connection handle: 75 )


    [04:59:11] >> mysql_real_escape_string() - Invalid connection handle. (You set: 75, Highest connection handle ID is 1).


    [04:59:11] >> mysql_query( Connection handle: 51 )


    [04:59:11] >> mysql_query() - Invalid connection handle. (You set: 51, Highest connection handle ID is 1).


    [04:59:11] >> mysql_store_result( Connection handle: 75 )


    [04:59:11] >> mysql_store_result() - Invalid connection handle. (You set: 75, Highest connection handle ID is 1).


    [04:59:11] >> mysql_num_rows( Connection handle: 75 )


    [04:59:11] >> mysql_num_rows() - Invalid connection handle. (You set: 75, Highest connection handle ID is 1).



    //EDIT
    Was bedeutet das jetzt ?

  • Ich würde es mal sagen, er zeiht aus irgendeinen Grund ein falschen Handle.


    das einzige was ich machen würde, #define SQL_PASS zu machen ohne die "" oder du setzt passwörter (wozu ich dir raten wurde)
    ansonsten würde ich mit handles arbeiten ;)


    Bedanke dich bitte, wenn du den Beitrag als hilfreich empfandest!



  • do.de - Domain-Offensive - Domains für alle und zu super Preisen