Jump to content

sebastiaandraaisma

Members
  • Posts

    60
  • Joined

  • Last visited

    Never

Posts posted by sebastiaandraaisma

  1. Wow, I'm realy dealing with experts here!!!

    Thanks a lot guys for taking the time to help me out!

    The error message I get now is:
    No database selected

    I always though that this would be done automaticaly?

    My connection script looks like this:
    <?php
    $dbcnx = @mysql_connect('localhost', 'root', 'abc123');
    if (!$dbcnx) {
    echo( '<p>Unable to connect to the ' .
    'database server at this time.</p>' );
    exit();
    }
    ?>

    The name of the database is:
    alfdis_global

    I realy apriciate the help I'm getting here
    I wish I had the knowledge to help someone else on the forum (maybe in 6 months from now if I keep studying hard ;) )
  2. Hello, thank you for your reply!

    I have on line 12:
    $result = mysql_query("SELECT * FROM admins WHERE id = '29'");

    I did try your version, which gave the same error
    $result = $result = mysql_query("SELECT * FROM admins WHERE id = '29'");

    To come back on your question wether I have installed MySQL, Yes MySQL is installed
    I have also Apache 2.x installed and running. I am able to output other php scripts and in the MySQL command line I can see the database, the table and the value I try to extract.

    I'm just very new to this and do not realy know what I'm doing wrong.
    In one of my books I read that an error that includes a Warning has something to do with the file path or something? As far as I know I configured things corectly. Is there anything specific I should look for that you might be aware of?

    Kind regards,
    Sebastiaan
  3. Hello again :)

    I got an error saying:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\www.globalhome.eu\indextest.php on line 13

    On line 13 is the following text:
    while(mysql_fetch_assoc($result)){

    I tried a couple of things but without result.

    I don't know if it has something to do with the fact that I'm running on XP and off-line?

    Kind regards,
    Sebastiaan
  4. Hello I have question that might sound stupid, but how do I echo just one field from the database?

    I tried the following:
    // make the connection to the database
    @require "connect.php";

    // Retreive data from database for translation
    $result = mysql_query('SELECT * FROM admins WHERE id = 29');// Select id 29 from table admins
    $res = mysqli_query($dbh, $result);// I don't understand this
    $newArray = mysqli_fetch_array($res, MYSQLI_ASSOC);// Something with an aray?
    $name = $newArray['name'];//Extract the name from the aray and give it the variable $name?
    echo "$name";// Show the name

    What it does... actually what it doesn't do is echo (print) the name on the screen.

    The table looks like this:

    CREATE TABLE `admins` (
      `id` int(11) NOT NULL auto_increment,
      `name` varchar(50) default NULL,
      `user` varchar(50) default NULL,
      `passwd` varchar(50) default NULL,
      `type` int(11) default NULL,
      `language` int(11) default '0',
      PRIMARY KEY  (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=34 ;


    INSERT INTO `admins` VALUES (29, 'John Doe', 'hello', 'test', 1, 0);

    I just don't know how to get the name as a variable and than echo"$name"
    I'm very new to php :)

    Any help is welcome!

    Kind regards,
    Sebas.
  5. I have turned the setting on, saved the php.ini and re-started the server.
    This time I did get an error, indicating that I am working on the right php.ini file.

    The error I got was:
    Fatal error: Call to undefined function mysqli_connect() in C:\www.globalhome.eu\indextest.php on line 4
    This is the text on line 4:
    $mysqli = mysqli_connect("localhost", "joeuser", "somepass", "testDB");

    I replaced mysqli_connect with mysql_connect but this gave the same error message.

    I did expect to read the error "Connect failed" as the script I'm using says
    if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();

    Any thoughts on this?

    Kind regards,
    Sebastiaan
  6. Thank you for your advise.
    I did turned this setting on, but because I did not restarted the server I guess it didn't help :)

    I will do the same and restart the server this time.
    I don't know the path out of my head as I'm right now in an internet cafe, but I'm using the default path and used the "recommended php.ini" that came with the instalation.

    Thank you for taking the time to answer.

    Kind regards,
    Sebastiaan
  7. Hi my name is Sebastiaan and I'm new to php, MySQL and Appache :)

    I wrote some simple php scripts to test and help me forward in learning the language, but now I'm at a point where I'm stuck.

    I will try to describe my problem.
    I can't connect to the database trough php, I have a simple out of the book connection script that should show me an error message when I can not connect.
    I do not receive any error message. In the php.info I have the following settings:
    error_reporting E_All
    Display_errors = off (I also tried the script with this function on)
    Display_startup_errors = off (also this one I tried with both on and off)

    When I try to use the script in both IE and Firefox I see an empty screen.

    The MySQL command line client works. I can see databases and tables and add data.

    My laptop is a XP 2002 Intel P. 1,86Ghz 504Mb ram

    The MySQL status says:
    Ver 14.12 Distrib 5.0.22, for win32 (ia32)
    Connection ID 2
    Current database (shows empty)
    Current user root@localhost (I'm running off-line)
    SSL Not in use
    Using delimiter ;
    Server version 5.0.22-community-nt
    Protocol version 10
    Connection localhost via TCP/IP
    Characterset latin1
    TCP port 3306

    I have attached the php file where the data is written.

    I hope some one knows what my problem could be? :)
    I personally think its a setting somewhere but I'm to new to all of this to see where.

    Any help is apriciated!

    Kind regards,
    Sebastiaan

    [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.