Jump to content

dreamwest

Members
  • Posts

    1,223
  • Joined

  • Last visited

    Never

Posts posted by dreamwest

  1. Html:

    <input type='checkbox' name='money[]' value='1' />

    <input type='checkbox' name='money[]' value='2' />

    <input type='checkbox' name='money[]' value='3' />

     

    Php:

    $type = $_GET['money'];

    if($type){

    if(is_array($type)){

    foreach($type as $x){

      echo "$x\n";

    }

    }

    }

     

    You can look at the global by

     

    print_r($_GET);

  2. Im getting this error message randomly 1 in 6 times itll lag and eventually show this error when i try to upload an image to a remote server.

     

    Warning: ftp_put() [function.ftp-put]: php_connect_nonb() failed: Operation now in progress (115) in /home/user/public_html/2.php on line 22
    
    Warning: ftp_put() [function.ftp-put]: Type set to I in /home/user/public_html/2.php on line 22

     

    Script:

    $ftp_server = "";
    $ftp_user   = "";
    $ftp_pass   = "";
    
    // connect to target ftp server
    $target_conn = ftp_connect($ftp_server) or die("Could not connect to server try again!");
    
    if(ftp_login($target_conn, $ftp_user, $ftp_pass)){
       echo 'Success';
    }else{
       echo 'Failed or timed out';
    }
    
    // switch to passive mode if behind a firewall - REMOVE THIS IF YOU RUN INTO PROBLEMS
    ftp_pasv($target_conn, true );
    
    // change to the target path
        ftp_chdir($target_conn, '/1/');
    
    // upload the thumbnail
    ftp_put($target_conn, 'test.jpg', 'tmb_4.jpg', FTP_BINARY) or die("There was an error uploading the thumbnail. Please try again");
    
       	ftp_close($target_conn);
       	
    echo "<hr>All done!";

     

    Anyone know what the error means?

  3. I found a logo design website a while back but ive forgotten the name. They make high quality logos for about $120 and they give you 5 samples to choose from, they also have a gallery of their previous work and a forum

     

    Anyone know who they are?

  4. SimpleXML is much easier

     

    $data = file_get_contents("superman.xml");
    
    $n_data = new SimpleXmlElement($data, LIBXML_NOCDATA);
    
    foreach ($n_data->movies->movie as $d) {
    
    $show .= "{$d->friends} went to see {$d->title}<br />";
    }
    
    echo $show;

  5. <?php
    
    ####################################################################
    # WIZECHO Database Backup - Copyright © 2010 Wizecho Software. All Rights #
    # Reserved. #
    # This file may be redistributed in whole or significant part with this copy write attached #
    # http://www.wizecho.com/nav=php&s=php_mysql_backup #
    ####################################################################
    
    //*************** config ***************//
    $mysql_host='localhost';
    $mysql_database='name'; // database name
    $mysql_username='user'; // user name
    $mysql_password='password'; // password
    
    $storing_dir = "/home/user/html/backups/"; // directory path with an ending slash
    
    //************* end config ************//
    $file_name = $mysql_database."_".date('YmdHis').".sql";
    
    $link = mysql_connect($mysql_host, $mysql_username, $mysql_password);
    if (!$link){
      fwrite($fh, 'Could not connect: ' . mysql_error());
      exit();
    }
    
    $db_selected = mysql_select_db($mysql_database, $link);
    if (!$db_selected){
      fwrite($fh, 'Can\'t use $mysql_database : ' . mysql_error());
      exit();
    }
    
    $myFile = $storing_dir . $file_name;
    $fh = fopen($myFile, 'w') or die("can't open file");
    _mysqldump($mysql_database);
    fclose($fh);
    
    function _mysqldump($mysql_database){
    global $fh;
    _mysqldump_schema_structure($mysql_database);
    $sql="show tables;";
    $result= mysql_query($sql);
    if( $result){
    
        while( $row= mysql_fetch_row($result)){
        _mysqldump_table_structure($row[0]);
        _mysqldump_table_data($row[0]);
        }
    }else{
        $content = "/* no tables in $mysql_database */\n";
        fwrite($fh, $content);
    }
    mysql_free_result($result);
    }
    function _mysqldump_schema_structure($schema){
    global $fh;
    fwrite($fh, "/* database : `$schema` */\n");
    $sql="show create schema `$schema`; ";
    $result=mysql_query($sql);
    if( $result){
        if($row= mysql_fetch_assoc($result)){
        fwrite($fh, $row['Create Database'].";\n\n");
        }
    }
    fwrite($fh, "USE `$schema`; \n\n");
    mysql_free_result($result);
    }
    
    function _mysqldump_table_structure($table){
    global $fh;
    fwrite($fh, "/* Table structure for table `$table` */\n");
    fwrite($fh, "DROP TABLE IF EXISTS `$table`;\n\n");
    $sql="show create table `$table`; ";
    $result=mysql_query($sql);
    if( $result){
        if($row= mysql_fetch_assoc($result)){
        fwrite($fh, $row['Create Table'].";\n\n");
        }
    }
    mysql_free_result($result);
    }
    
    function _mysqldump_table_data($table){
    global $fh;
    $sql="select * from `$table`;";
    $result=mysql_query($sql);
    if( $result){
    $num_rows= mysql_num_rows($result);
    $num_fields= mysql_num_fields($result);
    
    if( $num_rows > 0){
    fwrite($fh, "/* dumping data for table `$table` */\n");
    
    $field_type=array();
    $i=0;
    while( $i < $num_fields){
    $meta= mysql_fetch_field($result, $i);
    array_push($field_type, $meta->type);
    $i++;
    }
    
    //print_r( $field_type);
    fwrite($fh, "insert into `$table` values\n");
    $index=0;
    while( $row= mysql_fetch_row($result)){
    fwrite($fh, "(");
    for( $i=0; $i < $num_fields; $i++){
    if( is_null( $row[$i])){
    fwrite($fh, "null");
    }else{
    switch( $field_type[$i]){
    case 'int':
    fwrite($fh, $row[$i]);
    break;
    case 'string':
    case 'blob' :
    default:
    fwrite($fh, "'".mysql_real_escape_string($row[$i])."'");
    
    }
    }
    if( $i < $num_fields-1)
    fwrite($fh, ",");
    }
    fwrite($fh, ")");
    
    if( $index < $num_rows-1)
    fwrite($fh, ",");
    else
    fwrite($fh, ";");
    fwrite($fh, "\n");
    
    $index++;
    }
    }
    }
    mysql_free_result($result);
    fwrite($fh, "\n");
    }
    
    echo 'All Done!!';
    
    ?>

  6. Use break; to prevent looping

     

    example:

    $x = 2;
    
    switch ($x){
      case 1:
        echo "The number is one";
        break;
      case 2:
        echo "The number is two";
        break;
      case 3:
        echo "The number is three";
        break;
      default:
        echo "Number is greater than 3";
    } 

  7. I took basedir away from /etc/my.cnf because mysql couldnt restart with it, but the PID has --basedir=/

     

    Im running the latest version

     

    root@blue [~]#  mysql --version

    mysql  Ver 14.14 Distrib 5.1.56, for pc-linux-gnu (i686) using readline 5.1

     

×
×
  • 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.