• PHP Help PHP Databases
  • [RESOLVED] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Following the suggestion here http://www.plus2net.com/php_tutorial/checkbox-value.php I get a Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) error msg for the second table of checkboxes I am updating. Removing the second updating makes everything work.

I'd appreciate help on this. Thanks!

//////// Displaying 1
    $query_auttj="select auttjenester from asdtilbud_tjenester where member_id='$member_id' ";
    $row_auttj=mysql_fetch_object(mysql_query($query_auttj));
    $valg_array_auttj=split(",",$row_auttj->auttjenester);
    $qt_auttj=mysql_query("select * from asdtilbud_tjenestedef ");
    echo "<form method=post action=''><input type=hidden name=todo_auttj value=submit_form_auttj>";
    echo "<div id='auttjenester'>";
    echo "<table>";
    echo "<tr align='center'><td>autisme</tr>";
    $st="";
    while($noticia_auttj=mysql_fetch_array($qt_auttj)){
    if(@$bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
    else{$bgcolor='#f1f1f1';}
    if(in_array($noticia_auttj['tjeneste_no'],$valg_array_auttj)){$st_auttj="checked";}
    else{$st_auttj="";}
     echo "<tr bgcolor='$bgcolor' align='center'>
    <td class='data'><input type=checkbox name=valg_array_auttj[] value='$noticia_auttj[tjeneste_no]' $st_auttj></tr>";
    }
    echo  "</table>";
//////// Displaying 2
    $query_asptj="select asptjenester from asdtilbud_tjenester where member_id='$member_id' ";
    $row_asptj=mysql_fetch_object(mysql_query($query_asptj));
    $valg_array_asptj=split(",",$row_asptj->asptjenester);
    $qt_asptj=mysql_query("select * from asdtilbud_tjenestedef ");
    echo "<form method=post action=''><input type=hidden name=todo_asptj value=submit_form_asptj>";
    echo "<div id='asptjenester'>";
    echo "<table>";
    echo "<tr align='center'><td>asperger</tr>";
    $st2="";
    while($noticia_asptj=mysql_fetch_array($qt_asptj)){
    if(@$bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
    else{$bgcolor='#f1f1f1';}
    if(in_array($noticia_asptj['tjeneste_no'],$valg_array_asptj)){$st_asptj="checked";}
    else{$st_asptj="";}

 echo "<tr bgcolor='$bgcolor' align='center'>
<td class='data'><input type=checkbox name=valg_array_asptj[] value='$noticia_asptj[tjeneste_no]' $st_asptj></tr>";
}
echo  "</table>";

//////// Update 1
    @$todo=$_POST['todo_auttj']; // take care of register global if off
    if(isset($todo) and $todo=="submit_form_auttj"){
    $valg_array=$_POST['valg_array_auttj'];
    $tag_string="";
        while (list ($key,$val) = @each ($valg_array)) {
    //    echo "$val,";
        $tag_string.=$val.",";
        }
    $tag_string=substr($tag_string,0,(strLen($tag_string)-1));
        if (mysql_query("update asdtilbud_tjenester set auttjenester='$tag_string' where  member_id='$member_id' "));
        echo "Autismetjenester ble oppdatert<br>";
        }
        else{echo mysql_error();}
    }

//////// Update 2
    @$todo=$_POST['todo_asptj']; // take care of register global if off
    if(isset($todo) and $todo=="submit_form_asptj"){
    $valg_array=$_POST['valg_array_asptj'];
    $tag_string="";
        while (list ($key,$val) = @each ($valg_array)) {
//        echo "$val,";
        $tag_string.=$val.",";
        }
    $tag_string=substr($tag_string,0,(strLen($tag_string)-1));
        if(mysql_query("update asdtilbud_tjenester set asptjenester='$tag_string' where  member_id='$member_id' ")){
        echo "Aspergertjenester ble oppdatert<br>";
        }
        else{echo mysql_error();}
    } 

    You can get a better vay to update or set properties to a member 4 example, based on his primary key, and the multiply properties primary ID's. In this case a connector table should store these lists in separate rows.

    Here you can generate a full code if you set the table names and field names.

    http://www.youtube.com/watch?v=MUnpWtI-Rog

    jjozsi.

      this has nothing to do with coding. please verify that you mysql server is indeed up & running. check my.cnf to locate the actual location of mysql socket, and verify that you have permission to connect to the database.

        The mysql server is indeed up & running.
        When removing Update 2 code, things are working fine.... :-|

          Problem solved. It was a missing curly bracket elsewhere in the code... :-|

            Write a Reply...