Welcome Guest, Not a member yet? Register   Sign In
mysql sock error using code igniter
#11

[eluser]llbbl[/eluser]
Again, doesn't sound like a CI issue... lol
#12

[eluser]John_Betong[/eluser]
Hi KingConnections,

Try inserting this code in your config/dbase.php file immediately after the cache statements.
I changed the $sql statement to suit my own tables.

Code:
// TESTING
    $myhost  = $db['default']['hostname'];
    $myuser  = $db['default']['username'];
    $mydbase = $db['default']['database'];
    $mypass  = $db['default']['password'];
    $mysql   = 'SELECT * FROM jokes WHERE id < 10';
    
    echo '<br />$myhost     ==> '    .$myhost;
    echo '<br />$mydbase    ==> '     .$mydbase;
    echo '<br />$myuser     ==> '     .$myuser;
    echo '<br />$mypass     ==> '     .$mypass;
    echo '<br />$mysql      ==> '     .$mysql;
    
    $conn = mysql_connect($myhost, $myuser, $mypass);
    if (!$conn) {
        die('<br />Could not connect: ' . mysql_error());
    }
    echo '<br />Connected successfully<br /><br />';
    
    if (!mysql_select_db($mydbase)) {
        echo '<br />Unable to select ==> ' .$mydbase . mysql_error();
        exit;
    }
    
    $sql         = "SELECT email     FROM user ";
        // I CHANGED THIS STATEMENT
    $result = mysql_query($mysql);
    
    if (!$result) {
        echo "<br />Could not successfully run query ($sql) from ==> " .$mydbase . mysql_error();
    exit;
    }
    if (mysql_num_rows($result) == 0) {
        echo "<br />No rows found, nothing to print so am exiting";
        exit;
    }
    
    // While a row of data exists, put that row in $row as an associative array
    // Note: If you’re expecting just one row, no need to use a loop
    // Note: If you put extract($row); inside the following loop, you’ll
    // then create $userid, $fullname, and $userstatus
    while ($row = mysql_fetch_assoc($result)) {
        // echo $row["email"];
        echo $row['id'] .' ==> ' ;
        echo $row['title'];
        echo "<br />";
    }
    
    mysql_free_result($result);
    mysql_close($conn);
    die;
// TESTING

Results
Quote: $myhost ==> localhost
$mydbase ==> johnsjokes
$myuser ==> john_betong
$mypass ==> 0336-1462-5035
$mysql ==> SELECT * FROM jokes WHERE id<10
Connected successfully


1 ==> The weighing machine
2 ==> The elephant and the turtle
3 ==> The hinge and the teapot
4 ==> Stress management
5 ==> The song
6 ==> The gambler & taxi-driver
7 ==> The newlyweds
8 ==> Grandpa and his grand-daughter
9 ==> The Christmas present

Cheers,

John_Betong
&nbsp;
#13

[eluser]kingconnections[/eluser]
John,
Thanks I will try that and see what happens.

llbl,
I don't think it is a problem with code igniter itself. I do think it is a configuration issue somewhere. I am just trying to track it down. The database I am using is a remote database. You can not use socket to connect to a remote database in php/mysql. So it doesn't make any since that I am getting a socket error when my database is remote. For remote databases you use tcp/ip type of mysql connection. As I said I took this project over from someone and have no codedigniter experience. I am not saying anything is wrong with codeigniter at all.

Thanks for all you help!!!
#14

[eluser]kingconnections[/eluser]
OK, something wierd is going on. I did that and it did not work at all. So I thought that maybe the database settings were not getting read at all. I even tried to make it echo something out at the top of the screeen and no dice. So I completely renamed the database.php file to database2.php, just trying to get a different error. And I got the exact same error. How can it be reading that file if it is not there?

So to recap I completely removed the database.php file and it still redirected me to that error. Maybe my path configuration is wrong?
#15

[eluser]llbbl[/eluser]
It connects over port 3306. Your webserver might have that outgoing port blocked or your database server might have that incoming port blocked.
#16

[eluser]llbbl[/eluser]
Hey John its prolly not a good idea to post your database info in the forums. Tongue
#17

[eluser]John_Betong[/eluser]
[quote author="llbbl" date="1194321243"]Hey John its prolly not a good idea to post your database info in the forums. Tongue[/quote]

Hi llbbl,

No problem with the database info, it is not correct, just simplified to make it easier to read but thanks anyway.

Cheers,

John_Betong
&nbsp;
#18

[eluser]kingconnections[/eluser]
Guys, I found the localhost problem. It appears that the last developer put a mysql connection in the routes.php file. I have got it all squared away now.
#19

[eluser]llbbl[/eluser]
bastard! lol grads




Theme © iAndrew 2016 - Forum software by © MyBB