Jump to content

skidmark10

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Posts posted by skidmark10

  1. this line

    . $row['LastName']"</td>";  

     

    Is missing a '.'

     

    try

    <?php
    mysql_select_db("my_db", $con);
    $result = mysql_query("SELECT * FROM Persons");
    echo "<table border='1'><tr><th>Name</th></tr>";
    while($row = mysql_fetch_array($result))  {  
    echo "<tr>";  echo "<td>" . $row['FirstName'] . ' ' . $row['LastName']. "</td>";  
    echo "</tr>";  
    }
    echo "</table>";
    mysql_close($con);
    ?>

     

    I apologize for that, I'm gonna have to get more sleep, and quit being mean to people!

     

    Thank you so much!

  2. No where in your first post did you say anything about a parse error!  Post your ENTIRE script, that is the only way to deal with parse errors. (Include the acutal error also, there should be a line number in it.)

     

    I tried a similar code (not the code I posted)

     

    I put this and got a parse error

    echo "<td>" . $row['FirstName'] . " . $row['LastName']"</td>"

    ;

     

    Then I tried your code too and received a parse error

    echo "<td>" . $row['FirstName'] . ' ' . $row['Last_Name']"</td>";

  3. mysql_select_db("my_db", $con);
    $result = mysql_query("SELECT * FROM Persons");
    echo "<table border='1'><tr><th>Name</th></tr>";
    while($row = mysql_fetch_array($result))  {  
    echo "<tr>";  echo "<td>" . $row['FirstName'] . ' ' . $row['LastName']"</td>";  
    echo "</tr>";  
    }
    echo "</table>";
    mysql_close($con);
    ?>
    

     

    I don't think that works, I keep receiving the same error as before :-\

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'

     

  4. Hello,

     

    I am trying to retrieve and display data from a mysql table into a html table using php. I am using this code and it works successfully.

     

    <?php
    mysql_select_db("my_db", $con);
    
    $result = mysql_query("SELECT * FROM Persons");
    
    echo "<table border='1'>
    <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    </tr>";
    
    while($row = mysql_fetch_array($result))
      {
      echo "<tr>";
      echo "<td>" . $row['FirstName'] . "</td>";
      echo "<td>" . $row['LastName'] . "</td>";
      echo "</tr>";
      }
    echo "</table>";
    
    mysql_close($con);
    ?>

     

    However, I want $row['FirstName'] and $row['LastName'] to appear in the SAME cell of the html table, next to one another. How would I write the code for that, if it is possible

     

    Thanks in advance!

  5. Hello,

     

    I am using an html form where users submit their date of birth into a column in my mysql table. I am using phpmyadmin. I also have a table for current age that should get the users current age based on the information they submitted into the "date of birth" column.

     

    What date function would allow me to do the above? Also, where would I put that function? Again, I am using phpmyadmin.

     

     

  6. The query is failing for some reason, but you have no error-handling logic in place to catch that and report any errors. Is that all of the code, or is there more to it?

     

    How can I put in the error-handling logic? :)

    This is all of my php code (minus my database connection code), I'll post my html code so you can see the form.

     

    HTML

    <form name="input" action="fetchclientprofile.php" method="GET">
    <center> Client ID <input type="text" name="clientid" /><br /> </center>
    <center> <input type="submit" value="Retrieve" /> </center>

     

    PHP

    $sql = "SELECT * FROM `Partners_Body_Types` WHERE Client_ID= " .$_POST['clientid']. "";

     

    $query = mysql_query($sql);

     

    echo "<table border='0'>

    <tr>

    <th>Client ID</th>

    <th>Partner's Body Type</th>

    <th>Partner's Body Type</th>

    <th>Partner's Body Type</th>

    <th>Partner's Body Type</th>

    </tr>";

     

    while ($row = mysql_fetch_array($query))

      {

      echo "<tr>";

      echo "<td>" . $row['Client_ID'] . "</td>";

      echo "<td>" . $row['Slim_Slender'] . "</td>";

      echo "<td>" . $row['Average'] . "</td>";

      echo "<td>" . $row['Athletic'] . "</td>";

      echo "<td>" . $row['Heavy'] . "</td>";

      echo "</tr>";

      }

    echo "</table>";

     

    mysql_close($con);

    ?>

  7. please mark as solved. the topic solved button can be found at the bottom left of the page

     

    I am still receiving the error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource after making the corrections. Is there anything else I can do?

     

    $sql = "SELECT * FROM `Partners_Body_Types` WHERE Client_ID= " .$_POST['clientid']. "";
    
    $query = mysql_query($sql);
    
    echo "<table border='0'>
    <tr>
    <th>Client ID</th>
    <th>Partner's Body Type</th>
    <th>Partner's Body Type</th>
    <th>Partner's Body Type</th>
    <th>Partner's Body Type</th>
    </tr>";
    
    while ($row = mysql_fetch_array($query))
       {
       echo "<tr>";
       echo "<td>" . $row['Client_ID'] . "</td>";
       echo "<td>" . $row['Slim_Slender'] . "</td>";
       echo "<td>" . $row['Average'] . "</td>";
       echo "<td>" . $row['Athletic'] . "</td>";
       echo "<td>" . $row['Heavy'] . "</td>";
       echo "</tr>";
       }
    echo "</table>";
    
    mysql_close($con);
    ?> 

  8. I've never encountered this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

     

    Does anyone knows where it stems from, and ways to fix it?

     

    Here's my code just in case.

     

    $sql = "SELECT * FROM `Partners_Body_Types` WHERE Client_ID=" .$_POST['clientid']. ""or die ('Error: '.mysql_error ());
    
    $query = mysql_query($sql);
    
    echo "<table border='0'>
    <tr>
    <th>Client ID</th>
    <th>Partner's Body Type</th>
    <th>Partner's Body Type</th>
    <th>Partner's Body Type</th>
    <th>Partner's Body Type</th>
    </tr>";
    
    while ($row = mysql_fetch_array($sql));
       {
       echo "<tr>";
       echo "<td>" . $row['Client_ID'] . "</td>";
       echo "<td>" . $row['Slim_Slender'] . "</td>";
       echo "<td>" . $row['Average'] . "</td>";
       echo "<td>" . $row['Athletic'] . "</td>";
       echo "<td>" . $row['Heavy'] . "</td>";
       echo "</tr>";
       }
    echo "</table>";
    
    mysql_close($con);
    ?> 

  9. I keep recieving the error: Parse error: syntax error, unexpected T_ECHO on Line 13. Does anyone know what "T_ECHO" means, so I can know for future reference?

     

    Here's my code, Line 13 is echo "<table border='0'>.

     

    Thanks in advance!

     

    $sql = "SELECT * FROM Partners_Body_Types WHERE Client_ID=" .$_POST['clientid']. "";
    $query = mysql_query($sql)
    
    echo "<table border='0'>
    <tr>
    <th>Client ID</th>
    <th>Partner's Body Type</th>
    <th>Partner's Body Type</th>
    <th>Partner's Body Type</th>
    <th>Partner's Body Type</th>
    </tr>";

  10. Post the code you've written, and describe the problems you're having with it.

     

    Really haven't started any code yet, I'm confused.

     

    I know how to create an html form, with the form action of "post", and it stores the form data into the mysql table.

     

    Now I want an html form where I enter a client's ID number, hit submit, and the row with the ID number in the table is displayed.

  11. I am trying to insert answers from a checkbox on an html form into a mysql table using php. For some odd reason, the data doesnt make it to the mysql table. I'm not sure what the issue is, so I posted all of the information I have so I can see where I made my mistake.

     

    thanks in advance.

     

     

    Here is the html

    <table class=MsoNormalTable border=0 cellpadding=0 width="100%"
    style='width:100.0%;mso-cellspacing:1.5pt;mso-yfti-tbllook:1184;mso-padding-alt:
    0in 5.4pt 0in 5.4pt'>
    <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
      <td width="100%" style='width:100.0%;padding:.75pt .75pt .75pt .75pt'>
      <p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'><INPUT 
    
    TYPE="checkbox" NAME="partnerbodytype1" VALUE="Slender|Slim"> Slender/Slim
      <o:p></o:p></span></p>
      </td>
    </tr>
    <tr style='mso-yfti-irow:1'>
      <td width="100%" style='width:100.0%;padding:.75pt .75pt .75pt .75pt'>
      <p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'><INPUT 
    
    TYPE="checkbox" NAME="partnerbodytype2" VALUE="Average"> Average
      <o:p></o:p></span></p>
      </td>
    </tr>
    <tr style='mso-yfti-irow:2'>
      <td width="100%" style='width:100.0%;padding:.75pt .75pt .75pt .75pt'>
      <p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'><INPUT 
    
    TYPE="checkbox" NAME="partnerbodytype3" VALUE="Athletic"> Athletic
      <o:p></o:p></span></p>
      </td>
    </tr>
    <tr style='mso-yfti-irow:3;mso-yfti-lastrow:yes'>
      <td width="100%" style='width:100.0%;padding:.75pt .75pt .75pt .75pt'>
      <p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'><INPUT 
    
    TYPE="checkbox" NAME="partnerbodytype4" VALUE="Heavy"> Heavy
      <o:p></o:p></span></p>
      </td>
    </tr>
    </table>
    
    </div>

     

     

    Here is the php code

    $sqlpartnersbodytype= "INSERT INTO `Partners_Body_Types` (Slim_Slender, Average, Athletic, Heavy) VALUES ('$_POST[partnerbodytype1]','$_POST[partnerbodytype2]',
    '$_POST[partnerbodytype3]','$_POST[partnerbodytype4]')";

     

    Here is the table information

     `Partners_Body_Types` CHANGE  `Slim_Slender`  `Slim_Slender` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
    CHANGE  `Average`  `Average` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
    CHANGE  `Athletic`  `Athletic` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
    CHANGE  `Heavy`  `Heavy` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL

  12. what do you currently have it set as in the database?

     

    CHANGE  `Slim_Slender`  `Slim_Slender` ENUM(  'Slim|Slender' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,

    CHANGE  `Average`  `Average` ENUM(  'Average' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,

    CHANGE  `Athletic`  `Athletic` ENUM(  'Athletic' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,

    CHANGE  `Heavy`  `Heavy` ENUM(  'Heavy' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL

  13. You could assign an individual name to each value... make sure to update your database table as well:

     

    <td><div align="left">Please select all body types you would be interested in dating: </div></td>

          <td><input name="partnerbodytype1" type="checkbox" value="Slender" /> Slenders 

    <input name="partnerbodytype2" type="checkbox" value="Average" /> Average<br />

    <input name="partnerbodytype3" type="checkbox" value="Athletic" /> Athletic 

    <input name="partnerbodytype4" type="checkbox" value="Heavy" /> Heavy<br />

     

    php:

     

    $partnersbodytype1 = $_POST['partnersbodytype1']

    $partnersbodytype2 = $_POST['partnersbodytype2']

    $partnersbodytype3 = $_POST['partnersbodytype3']

    $partnersbodytype4 = $_POST['partnersbodytype4']

     

    $sqlClientInfo= "INSERT INTO `Client_Info` (partnersbodytype1, partnersbodytype2, partnersbodytype3, partnersbodytype4)

     

    VALUES ('$partnersbodytype1','$partnersbodytype2','$partnersbodytype3','$partnersbodytype4')

     

    I've tried this way, but my answers still don't appear. Is there something wrong with my table? Is there something I can change with the table?

  14. You could assign an individual name to each value... make sure to update your database table as well:

     

    <td><div align="left">Please select all body types you would be interested in dating: </div></td>

          <td><input name="partnerbodytype1" type="checkbox" value="Slender" /> Slenders 

    <input name="partnerbodytype2" type="checkbox" value="Average" /> Average<br />

    <input name="partnerbodytype3" type="checkbox" value="Athletic" /> Athletic 

    <input name="partnerbodytype4" type="checkbox" value="Heavy" /> Heavy<br />

     

    php:

     

    $partnersbodytype1 = $_POST['partnersbodytype1']

    $partnersbodytype2 = $_POST['partnersbodytype2']

    $partnersbodytype3 = $_POST['partnersbodytype3']

    $partnersbodytype4 = $_POST['partnersbodytype4']

     

    $sqlClientInfo= "INSERT INTO `Client_Info` (partnersbodytype1, partnersbodytype2, partnersbodytype3, partnersbodytype4)

     

    VALUES ('$partnersbodytype1','$partnersbodytype2','$partnersbodytype3','$partnersbodytype4')

     

     

    Yikes! Is this the only way???? If so, I have to prepare myself for a LONG night of work....

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