Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Posts posted by wildteen88

  1. How do you use a double quote in str_replace?

    $queryline = str_replace(""","'""",$line);

    Either use single quotes wrapped around the double quores

    $queryline = str_replace('"','""',$line);

     

    OR escape the double quotes

    $queryline = str_replace("\"","\"\"",$line);

  2. This is what I did to enable the advanced features (using the latest version 3.4.x)

     

    First login to phpmyadmin and create a new database called phpmadmin. When you have created the database select the import tab at the top of the page. Click the Browse/Choose file button and navigate to your phpmyadmin folder and open the scripts directory and select the create_tables.sql file. Click open to close the window. Then press Go (bottom of page). The database for the control user has been setup.

     

    Next to setup the control user. Go to the phpmyadmin home screen and click the privileges tab. Click the add a new user link. For the username type phpmyadmin. Set anything as the password (Make sure you remember it). Choose the option to Create database with same name and grant all privileges And then click the Go button.

     

    You have now setup the control user and the database for phpmyadmin. You now need to configure phpmyadmin. Open the config file (called config.inc.php). And remove the // from the start of the following lines

    /* User used to manipulate with storage */
    // $cfg['Servers'][$i]['controluser'] = 'pma';
    // $cfg['Servers'][$i]['controlpass'] = 'pmapass';
    
    /* Storage database and tables */
    // $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
    // $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
    // $cfg['Servers'][$i]['relation'] = 'pma_relation';
    // $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
    // $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
    // $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
    // $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
    // $cfg['Servers'][$i]['history'] = 'pma_history';
    // $cfg['Servers'][$i]['tracking'] = 'pma_tracking';
    // $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
    // $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';

     

    Make sure you set $cfg['Servers'][$i]['controluser'] to phpmyadmin and apply the password to $cfg['Servers'][$i]['controlpass']. Log out of phpmyadmin, then log back in (not as the control user). The advanced features should now be enabled.

    • Like 2
  3. The mysql_fetch_* functions return one row at a time. As your query will return more than two rows you'll need to use these functions with a while loop to get all the results

    $result = mysql_query("SELECT pagename FROM tablename WHERE user = 'user1'") or die(mysql_error();
    
    // definee userPages as an array. We'll add the userpages to this array latter
    $userPages = array();
    
    // loop through the results, one row at a time
    while($row = mysql_fetch_assoc($result))
    {
         // add the pagename to userPages array
         $userPages[] = $row['pagename'];
    }
    
    // output the the userPages array
    echo '<pre>' . print_r($userPages, true) . '</pre>';

  4. An alternative way would be take each line within your string and add it into an array. You'd then iterate over the lines within the array searching for the string. When the string is found return the current line.

    Example code

    // the string to search for
    $searchString = 'mystring';
    
    // some example data to work with
    $data = 'Line 1
    Line 2 mystring
    Line 3
    Line 4';
    
    // add each line into the array $lines
    $lines = explode("\n", $data);
    
    // iterate through the lines
    foreach($lines as $key => $line)
    {
        // check to see if the string is on the current line
        if(strpos($line, $searchString) !== FALSE)
        {
            // string has been found, tell the user on what line it is on
            echo "Found '$searchString' on Line " . ($key+1);
            break; // stop the loop
        }
    }

  5. Not quite

    if(!$result)
    {
    echo 'error';
    }
    else
    {
        // check that a record was deleted
        if(mysql_affected_rows() == 1)
        {
            echo 'Query deleted the record ' . $tID . ' successfully';
        }
        // record was not deleted
        else
        {
            echo 'The query did not delete the record' . $tID;
        }
    }

     

    if(mysql_query($result,$conn)){

            echo "$i  encountered an error.<br/>";

      } else {

            echo "$i successfully inserted.<br/>";

          }

    That does need even relate to the OP's code.

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