Jump to content

shadowpat

Members
  • Posts

    15
  • Joined

  • Last visited

Posts posted by shadowpat

  1. Says the person who doesn't know what "sans" means... The irony ;)

    Okay got that working too!

    I used the JavaScript document.open() like this:

     

     

    <script language=JavaScript>
    function createDoc()
      {
      var doc=document.open(\"text/html\",\"replace\");
      var txt=\"$row[message]\";
      doc.write(txt);
      doc.close();
      }
    </script>

     

    i just echoed that along with my script, and had a button that (when clicked) would call createDoc() and then it would output the message.. ;)

  2. Says the person who doesn't know what "sans" means... The irony ;)

     

    okay got it working....

     

     

    echo "<table border='1'>";
    while($row = mysqli_fetch_array($result)) { //while you still have data left in the table:
       echo "<tr><td><font color='grey'>".$row['date']."</font></td><td> ".$row['sender']."</td><td> - ".$row['subject']."</td></tr>";
    }
    echo '</table>'; //ends the table.

     

    is that a good way to do it?

    Thanks....

    on to the next question.....

     

    This is what I want to achieve with this program I have been working on:

     

    I have a user system that allows users to log in with their username and password...

    I want the users to be able to send emails to each other, but without using email.

    I will solve this by creating a table for each user (when the sign up) that is username-mail.. all of their mail is stored in there (is this a bad way to do it?)

     

    so this is what a username-mail table would look like:

     

    date-sender-subject-message

     

    for example an entry might be:

     

    5/12/13 bob mysubject mymessage

     

    I told the script not to echo the message because it might get annoying if it is in the table too... so what i want to do (not sure if even possible) is to have a link at the end of each entry (after the subject) that will open a new window (or something of that sort) that shows the message.... for example, we would now have this:

     

    5/12/13 bob mysubject open

     

    Is this possible? Sorry about the really long explanation... Please let me know how I should do this!

    Thanks!

  3. Says the person who doesn't know what "sans" means... The irony ;)

    ohhhh i assumed he meant "and"... i thought it was a typo.... haha, so what does it mean? Also, I got it working!!! Do you know how to turn every result into a table row with this code?

     

     

    while($row = mysqli_fetch_array($result)) { 
       echo "<font color='grey'>".$row['date']."</font> ".$row['sender']." - ".$row['subject']."";
    }
    Please post the code if you get it working in a table.... I'm not sure of the best way to do it...... thanks!
    I also have another question.... but I won't post it until i get this figured out.... thanks!
  4. This is similar to where you should be, taking all the info out of a database, and dumping it back to the screen:

    commented up

     
    <?php
    include('connection.php'); //make sure you have a mysqli connection.
    $sql = "SELECT * FROM `{$myusername}-mail` ORDER BY date ASC"; //define your sql statement.
    $result = mysqli_query($connection,$sql) or trigger_error($sql . ' - has encountered an error at:<br />' . mysqli_error($connection)); //call the sql statement, if it errors give us de-bugging info.
    $fields = mysqli_fetch_fields($connection); //get your field list.
    $field_count = mysqli_num_fields($connection); //get the number of fields.
    echo '<table>' . "\n" . '<tr>'; //start a table.
    $i = 0; //define a counter.
    foreach($fields as $field) { //for each field
    if(++$i == 1) { //if this is the first run of the foreach statemnt.
    echo '<th colspan="' . $field_count . '">' . $field->table . '</th></tr><tr>'; //print out a table header with the table name.
    }
    echo "\n" . '<th>' . $field-name . '</th>'; //print the column name at the top of each column.
    }
    echo '</tr>'; //ends the column row.
    while($row = mysqli_fetch_row($result)) { //while you still have data left in the table:
        echo '<tr><td>' . implode('</td><td>' , $row) . '</td></tr>';     //dump it all into a row, matching the data to the correct column.
    }
    echo '</table>'; //ends the table.
     
    

    Sometimes it helps to just see it, with comments to follow what it is doing.

    YAY! that solved it! That code had a few errors, but I changed a few things and got it working. Thanks allot! Also, the tables didnt work... i will post a new question to see if anybody can get it to work. thanks!

  5. This is similar to where you should be, taking all the info out of a database, and dumping it back to the screen:

    commented up

     
    <?php
    include('connection.php'); //make sure you have a mysqli connection.
    $sql = "SELECT * FROM `{$myusername}-mail` ORDER BY date ASC"; //define your sql statement.
    $result = mysqli_query($connection,$sql) or trigger_error($sql . ' - has encountered an error at:<br />' . mysqli_error($connection)); //call the sql statement, if it errors give us de-bugging info.
    $fields = mysqli_fetch_fields($connection); //get your field list.
    $field_count = mysqli_num_fields($connection); //get the number of fields.
    echo '<table>' . "\n" . '<tr>'; //start a table.
    $i = 0; //define a counter.
    foreach($fields as $field) { //for each field
    if(++$i == 1) { //if this is the first run of the foreach statemnt.
    echo '<th colspan="' . $field_count . '">' . $field->table . '</th></tr><tr>'; //print out a table header with the table name.
    }
    echo "\n" . '<th>' . $field-name . '</th>'; //print the column name at the top of each column.
    }
    echo '</tr>'; //ends the column row.
    while($row = mysqli_fetch_row($result)) { //while you still have data left in the table:
        echo '<tr><td>' . implode('</td><td>' , $row) . '</td></tr>';     //dump it all into a row, matching the data to the correct column.
    }
    echo '</table>'; //ends the table.
     
    

    Sometimes it helps to just see it, with comments to follow what it is doing.

    thanks i will try that soon... stay posted

  6. the current error is because mysqli_error( ... ) requires the mysqli connection resource as a parameter.

    Here is my code now... i get a new error with more info:

     

     

    $result = mysqli_query($connection,"SELECT * FROM ".$myusername."-mail ORDER BY date ASC");
     
    echo "The \$result variable contains: ".$result;
    echo "<br/>";
     
    if ($result) {
       while($row = mysqli_fetch_array($result)) {
         echo "done";
         echo "<br>";
        }
    } else {
      echo "Error message".mysqli_error($connection);
    }

     

    Now i get an error telling me that there is an error near -mail. There is a variable near -mail.... maybe that is the cause of the error?

  7. I think you need some basic lessons on programming. You can't just copy and paste code into yours and expect it to work.

    That isn't what I was doing at first.... I used my own code from a mysql table, and changed it over to mysqli.... but since that didnt really work i kind of had to copy some other code..... i do know how to program you know. How well could you program in PHP or even MYSQLI when you were 13?

  8. try echoing your query to make sure it contains what you expect it to contain

    Thanks. This does not solve the problem, or give me any info..... here is my code now:

     

     

     
    $result = mysqli_query($connection,"SELECT * FROM ".$myusername."-mail ORDER BY date ASC");
     
    echo "The \$result variable contains: ".$result;
    echo "<br/>";
     
    if ($result) {
       while($row = mysqli_fetch_array($result)) {
         echo "done";
         echo "<br>";
        }
    } else {
      echo "Oh noes, an error!";
    }

     

    when i do echo "The \$result variable contains: ".$result;

    all i get is The $result Variable is:

    That is all.....

    please help

  9. @Jessica:

    ok now i have 

     

     
    $result = mysqli_query($connection,"SELECT * FROM ".$myusername."-mail ORDER BY date ASC") or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error(), E_USER_ERROR);
     
    while($row=mysqli_fetch_array($connection,$result))
      {
      echo "done";
      echo "<br>";
      }
     
    and get this error:
     
    Warning: mysqli_error() expects exactly 1 parameter, 0 given in /hermes/bosoraweb172/b2121/ipg.unityinvtorg/main.php on line 61 Fatal error: Query Failed! SQL: - Error: in /hermes/bosoraweb172/b2121/ipg.unityinvtorg/main.php on line 61

     

  10. Thanks for the speedy reply! Now i get this error:

    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in /hermes/bosoraweb172/b2121/ipg.unityinvtorg/main.php on line 63

     

    again line 63 is the "while" line

    thanks!

  11. Hello,

    For the past day I have been trying to echo all of a mysqli table. Although I keep getting tons of errors.

    Right now my code is:

     

     
    $result = mysqli_query($connection,"SELECT * FROM ".$myusername."-mail ORDER BY date ASC");
     
    while($row = mysqli_fetch_array($result))
      {
      echo "done";
      echo "<br>";
      }
     

    Right now I get this error: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /hermes/bosoraweb172/b2121/ipg.unityinvtorg/main.php on line 63

     

    line 63 is the "while" line that i posted here.....

    Thank you so much!

    Patrick

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