Hi, I'm having trouble switching from mysql to mysqli. Help? thanks

code follows:

<?php?>
<html><body><div align=right>W</div></body></html>

//Open a new connection to the MySQL server
$mysqli = new mysqli('loclhost','root','','hoappsdb');
//Output any connection error
 if ($mysqli->connect_error)
 {die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);}

//MySqli Select Query
$results = $mysqli->query SELECT * FROM 'waitlist' Where entrytype='T'";

  echo "<b>In House Add-Ons/Transfers<br><br>";

echo "<table border=1>";
            echo "<tr>";

            echo "<th>Appl#</th>";
            echo "<th>Date</th>";
            echo "<th>Time</th>";
            echo "<th>Name</th>";
            echo "<th>Race & Gender</th>";
            echo "<th>Ethnicity</th>";
            echo "<th>LH %</th>";
            echo "<th>Displ.</th>";
            echo "<th>Income Level</th>";                
      echo "<th>B/r s Needed</th>";
      echo "<th>Movein Date</th>";
      echo "<th>Removal Date</th>";
      echo "<th>Code</th>";
      echo "<th>Comments</th>";          
      
echo "</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['appl'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['time'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['racegend'] . "</td>";
echo "<td>" . $row['ethnicity'] . "</td>";
echo "<td>" . $row['laborhsg'] . "</td>";
echo "<td>" . $row['displ'] . "</td>"; 
echo "<td>" . $row['incomelevel'] . "</td>";
echo "<td>" . $row['brneeded'] . "</td>";
echo "<td>" . $row['moveindate'] . "</td>";
echo "<td>" . $row['removaldate'] . "</td>";
echo "<td>" . $row['code'] . "</td>";
echo "<td>" . $row['comments'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close();
?> 

result follows:

//Open a new connection to the MySQL server $mysqli = new mysqli('loclhost','root','','hoappsdb'); //Output any connection error if ($mysqli->connect_error) {die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);} //MySqli Select Query $results = $mysqli->query SELECT * FROM 'waitlist' Where entrytype='T'"; echo "In House Add-Ons/Transfers

"; echo " echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; while($row = mysql_fetch_array($result)) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
Appl#	Date	Time	Name	Race & Gender	Ethnicity	LH %	Displ.	Income Level	B/r s Needed	Movein Date	Removal Date	Code	Comments
" . $row['appl'] . "	" . $row['date'] . "	" . $row['time'] . "	" . $row['name'] . "	" . $row['racegend'] . "	" . $row['ethnicity'] . "	" . $row['laborhsg'] . "	" . $row['displ'] . "	" . $row['incomelevel'] . "	" . $row['brneeded'] . "	" . $row['moveindate'] . "	" . $row['removaldate'] . "	" . $row['code'] . "	" . $row['comments'] . "
"; mysql_close(); ?> 

    Added [code]...[/code] tags to your code blocks. Please be sure to use them in the future.

      So what sort of error messages are you getting? For example, is the server really named loclhost?

        You are seeing the raw php code on the web page because you don't actually have an opening <?php tag at the start of that php code. The opening <?php tag that you do have, is immediately being closed on the same line, then is never being opened again.

        In addition to the misspelling of localhost that Weedpacket pointed out, you have single-quotes around the table name in the sql query, making it a literal string, rather than a table name (identifier), you apparently don't have any () around the ->query() method call, which will produce a php syntax error once you correct the php opening/closing tags, and you haven't converted the mysql_fetch... or mysql_close statements.

        Also, don't echo static html markup. This is a huge waste of typing. Just drop out of php 'mode' when you have a bunch of html that contains no php code.

          Weedpacket is correct in asking what errors you are receiving. Just a cursory inspection of your code makes me wonder if this line isn't a syntax error:

          $results = $mysqli->query SELECT * FROM 'waitlist' Where entrytype='T'";

          It's missing a parenthesis and a double quote.

            As @pbismad notes, there is a problem on the first line. The second line also has a problem

            <html><body><div align=right>W</div></body></html>

            that just looks like it's randomly there for no reason.

            What did the original MySQL-based code you're converting look like?

              I made changes as I understood:

              <html><body><center><b>In House Add-Ons/Transfers</b></center><br>
              <?php
              //Open a new connection to the MySQL server
              $mysqli = new mysqli('localhost','root','','hoappsdb');
              //Output any connection error
               if ($mysqli->connect_error)
               {die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);}
              
              //MySqli Select Query
              $results = $mysqli->query (SELECT * FROM waitlist Where entrytype='T'");
              
              echo "<table border=1>";
                          echo "<tr>";
              
                      echo "<th>Appl#</th>";
                      echo "<th>Date</th>";
                      echo "<th>Time</th>";
                      echo "<th>Name</th>";
                      echo "<th>Race & Gender</th>";
                      echo "<th>Ethnicity</th>";
                      echo "<th>LH %</th>";
                      echo "<th>Displ.</th>";
                      echo "<th>Income Level</th>";                
                echo "<th>B/r s Needed</th>";
                echo "<th>Movein Date</th>";
                echo "<th>Removal Date</th>";
                echo "<th>Code</th>";
                echo "<th>Comments</th>";  
                 
              echo "</tr>";
              while($row = mysql_fetch_array($result))
              {
              echo "<tr>";
              echo "<td>" . $row['appl'] . "</td>";
              echo "<td>" . $row['date'] . "</td>";
              echo "<td>" . $row['time'] . "</td>";
              echo "<td>" . $row['name'] . "</td>";
              echo "<td>" . $row['racegend'] . "</td>";
              echo "<td>" . $row['ethnicity'] . "</td>";
              echo "<td>" . $row['laborhsg'] . "</td>";
              echo "<td>" . $row['displ'] . "</td>"; 
              echo "<td>" . $row['incomelevel'] . "</td>";
              echo "<td>" . $row['brneeded'] . "</td>";
              echo "<td>" . $row['moveindate'] . "</td>";
              echo "<td>" . $row['removaldate'] . "</td>";
              echo "<td>" . $row['code'] . "</td>";
              echo "<td>" . $row['comments'] . "</td>";
              echo "</tr>";
              }
              echo "</table>";
              mysql_close();
              ?> 
              </body></html>
              

              ==================================================================

              result follows:

              In House Add-Ons/Transfers

              connect_error) {die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);} //MySqli Select Query $results = $mysqli->query (SELECT * FROM waitlist Where entrytype='T'"); echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; while($row = mysql_fetch_array($result)) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
              Appl# Date Time Name Race & Gender Ethnicity LH % Displ. Income Level B/r s Needed Movein Date Removal Date Code Comments
              " . $row['appl'] . " " . $row['date'] . " " . $row['time'] . " " . $row['name'] . " " . $row['racegend'] . " " . $row['ethnicity'] . " " . $row['laborhsg'] . " " . $row['displ'] . " " . $row['incomelevel'] . " " . $row['brneeded'] . " " . $row['moveindate'] . " " . $row['removaldate'] . " " . $row['code'] . " " . $row['comments'] . "
              "; mysql_close(); ?>

                It's starting to look like you haven't even got PHP running yet, or that the page isn't one the server is configured to send to the PHP interpreter.

                Have a look at the page, use "View Source" to see if the "<?php" parts are still there.

                Oh, and I added [code]...[/code] tags to your code blocks. Please be sure to use them in the future.

                Weedpacket It's starting to look like you haven't even got PHP running yet, or that the page isn't one the server is configured to send to the PHP interpreter.

                Yeah, looks like it's just treating it as plain HTML, and is therefore treating this as one (invalid) HTML tag (from opening < to closing >):

                <?php
                //Open a new connection to the MySQL server
                $mysqli = new mysqli('localhost','root','','hoappsdb');
                //Output any connection error
                 if ($mysqli->
                 

                  thanks for your assistance. I'm converting old programs to mysli and it does seem that php is not involved. I've worked for days changing dozens of files and all act the same. I don't have them online
                  so I can't do viewsource. I'm 32 bit and it seems I can't re-up my xampp until I up to 64 bit. How can I know what version php I now have.

                    4 days later

                    $results = $mysqli->query (SELECT * FROM waitlist Where entrytype='T'");

                    That missing quote in the SQL query is bound to cause lots of issues. (It should be before the word SELECT).

                      Write a Reply...