Jump to content
Larry Ullman's Book Forums

Jaloney

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by Jaloney

  1. Hello,

    I changed root to drupal user

    as my config file for sql has

    this: [client]

    port=3306

    user=drupaluser

     

    [mysql]

     

    [mysqladmin]

    user=root

    port=3306

     

     

    So  now I get this error:

    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\Users\Owner\Sites\acquia-drupal\CO241\my_script.php on line 11  

    Perplexed.

     

    Jaloney

  2. Hello

    My instructor routinely gives assignments where the code doesn't work and we have to fend for ourselves to figure out what the issue is. My assignment is to enter this code and connect to Acquia Drupal database.

     

    i keep getting an error referring to link 1 where the database connect statement is given.

    The database doesn't have a password. I did enter the code in Phpmy admin before I tried to upload it to the Acqui-Drupal desktop to find the error in line one. 

     

    This is the code. He doesn't use the same syntax as the book which makes learning harder.

    Any idea what is wrong with the database connect statement? I did try adding my user name and password in the connect mysqli_connect statement but it did not help.

     

    <?PHP

    //book page 268
    $dbc=mysqli_connect("localhost","root","");

    mysqli_select_db($dbc,"acquia_drupal");

    $query="select name from role";
    $r=mysqli_query($dbc,$query);

    while($row=mysqli_fetch_array($r))
    {
    echo $row['name']."<br />";
    }

    mysqli_close($dbc);
    ?>

     

     

  3. Okay I found the SQL commands nestled in the middle of the file. I copied and pasted into my PHP Myadmin SQL command prompt and I get an error on line one.

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHARSET utf8' at line 1

     

    I looked at the code and it is exactly the same as yours and the books. All of the other SQL commands for other chapters work fine. I was hoping your command files were different as My instructor tried to figure out why this same error is happening with the file he provided to the class.. which gives the same error. He gave up and I can't give up as I need to learn this stuff and I can't learn it without a way to do the searches with the database.

  4. Hello,

    I am trying to follow along in the book. I am on page 135 number 2. "Insert One row of data into the users table WITHOUT naming the columns.Because I chose to use PHPmyadmin, I don't see how to do this. There is no example in the book. My instructor emailed me and said to use SQL Tab with Insert.. When I do this, I see the names of the columns in there.. Do I delete these? Not sure how to do this excersize with PHPmyadmin

     

  5. I am having problems with the same script. This is the error that is making me get the error message on my form: I am blue in the face and getting so frustrated as I just can't see what the problem is.  Notice: Undefined variable: POST in C:\Users\Owner\Sites\acquia-drupal\CO241\calculator.php on line 12    I keep getting the error on last line of IF statement  && is_numeric($POST['efficiency']) ) {

    Any ideas appreciated.

     

    <?php # Script 3.5 - calculator.php
    $page_title = 'Trip Cost Calculator';
    include ('includes/header.html');


    // Check for form submission;
    if($_SERVER['REQUEST_METHOD'] == 'POST') {
     
     //Minimal form validation
     if (isset($_POST['distance'], $_POST['gallon_price'], $_POST['efficiency']) &&
     is_numeric($_POST['distance']) && is_numeric($_POST['gallon_price'])
     && is_numeric($POST['efficiency']) ) {
      //Calculate the results:
      $gallons = $_POST['distance'] / $_POST['efficiency'];
      $dollars = $gallons * $_POST['gallon_price'];
      $hours = $_POST['distance']/ 65;
      //Print the results:
      echo '<h1>Total Estimated Costs</h1>
      <p>The total cost of driving ' . $_POST['distance'] . ' miles, averaging ' . $_POST
      ['efficiency'] . ' miles per gallon, and paying an average of $' . $_POST['gallon_price'] . '
      per gallon, is $' . number_format($dollars, 2) . '. If you drive at an average of 65 miles
      per hour, the trip will take approximately ' . number_format($hours, 2) . ' hours.</p>';
      
      } else { //Invalid submitted values.
        echo '<h1> Error!</h1>
        <p class="error">Please enter a valid distance, price per gallon, and fuel efficiency.</p>';
      }
     } //End of main submission IF.
     //Leave the PHP section and create the HTML form:
     ?>
       
     <h1>Trip Cost Calculator</h1>
        <form action="calculator.php" method="post">
        <p>Distance (in miles): <input type="text" name="distance" /></p>
        <p>Ave. Price Per Gallon: <span class="input">
            <input type="radio" name="gallon_price" value="3.00" /> 3.00
            <input type="radio" name="gallon_price" value="3.50" /> 3.50
            <input type="radio" name="gallon_price" value="4.00" /> 4.00
            </span></p>
            <p>Fuel Efficiency: <select name="efficiency">
                 <option value="10">Terrible</option>
                 <option value="20">Decent</option> 
                 <option value="30">Very Good</option> 
                 <option value="50">Outstanding</option>
                 </select></p>
                 <p><input type="submit" name="submit" value="Calculate!" /></p>
                 </form>
                
                 <?php include ('includes/footer.html'); ?>
         
                
                
                
                
      
      
      

×
×
  • Create New...