No data return

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dsusa
Forum Newbie
Posts: 3
Joined: Tue Aug 05, 2003 1:11 am

No data return

Post by dsusa »

Hi, I tried this many times and I don't know what is wrong with it. No error message is coming up but the dropdown menu to choose the contact is empty.

Code: Select all

<?
include 'db.php';

$sql = "SELECT userid, first_name, last_name FROM $table_name ORDER BY last_name"; 
$result = mysql_query($sql,$connection) or die(mysql_error()); 
$num = mysql_num_rows($result); 

if ($num < 1) &#123;
	$display_block = "<br><b><center>Sorry! No results found.";
	&#125; else &#123;
	
	while($row = mysql_fetch_array($result))&#123; 
    $userid = $row&#1111;'userid'];
	$first_name = $row&#1111;'first_name'];
	$last_name = $row&#1111;'last_name'];
	
	$option_block .= "option value="$userid">$last_name, $first_name</option>";
	&#125;

	$display_block = "<form method="POST" action="show_contact.php">

	<p><b>Contacts: 
	<select name="userid"> 
	$option_block 
	</select>

	<input type="submit" name="submit" value="Select this Contact"<p> 
	</form>";
	&#125;
?>
	

<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
Modify Contact

<? echo "$display_block"; ?>

<br><p><a href="tools_admin.php">Return to Main Menu</a></p>
</body>
</html>
I do get an parse error on the show_contact.php in the first select statement:

Code: Select all

sql = "SELECT first_name, last_name, email_address, telephone_number, company_name, address, 
city, state, zip_code, username, password, user_level FROM $table_name WHERE userid = '$_POST&#1111;userid]'";
Maybe you need the whole code:

Code: Select all

<?
if (!$_POST&#1111;userid]) &#123;
header ("location: selectcontact.php");
exit;

include 'db.php'

sql = "SELECT first_name, last_name, email_address, telephone_number, company_name, address, 
city, state, zip_code, username, password, user_level FROM $table_name WHERE userid = '$_POST&#1111;userid]'";

$result = mysql_query($sql, $connection) or die(mysql_error());

while ($row = mysql_fetch_array($result)) &#123;
$first_name = $row&#1111;'first_name'];
$last_name = $row&#1111;'last_name'];
$email_address = $row&#1111;'email_address'];
$telephone_number = $row&#1111;'telephone_number'];
$company_name = $row&#1111;'company_name'];
$address = $row&#1111;'address'];
$city = $row&#1111;'city'];
$state = $row&#1111;'state'];
$zip_code = $row&#1111;'zip_code'];
$username = $row&#1111;'username'];
$password = $row&#1111;'password'];
$user_level = $row&#1111;'user_level'];
&#125;
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body link="#000000" vlink="#000000" alink="#000000" leftmargin="0" topmargin="0">
<table width="771" height="392" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td colspan="6"><div align="center"><img src="../gifs/spaceflat.jpg" width="50" height="20"></div></td>
  </tr>
  <tr> 
    <td width="51" rowspan="3"><div align="center"><img src="../gifs/spacer51.gif" width="51" height="20"></div></td>
    <td colspan="4"><div align="left"> 
        <p><font size="4" face="Georgia"><u>Admin Tool:</u> </font></p>
        <p><font size="4" face="Georgia">Add a Client or Member</font></p>
      </div></td>
    <td width="50" rowspan="3"><div align="center"><img src="../gifs/spacer50.gif" width="50" height="20"></div></td>
  </tr>
  <tr> 
    <td colspan="4"><div align="center"><img src="../gifs/spaceflat.jpg" width="50" height="20"></div></td>
  </tr>
  <tr> 
    <form name="form1" method="post" action="register_admin.php">
      <td height="291" colspan="4"> <table width="650" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="146" height="30" align="center"> <div align="left"><font color="#990000" face="Webdings">4</font><font face="Georgia">First 
                Name</font></div></td>
            <td width="172" height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="first_name" type="text" id="first_name5" value="<? echo "$first_name"; ?>" size="20" maxlength="25">
                </font></div></td>
            <td width="167" height="30" align="center"> <div align="left"><font face="Georgia"><font color="#990000" face="Webdings">4</font>Last 
                Name</font></div></td>
            <td width="165" height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="last_name" type="text" id="last_name" value="<? echo "$last_name"; ?>" size="20" maxlength="25">
                </font></div></td>
          </tr>
          <tr> 
            <td height="30" align="center"> <div align="left"><font color="#990000" face="Webdings">4</font><font face="Georgia">E-Mail 
                Address</font></div></td>
            <td height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="email_address" type="text" id="email_address" value="<? echo "$email_address"; ?>" size="20" maxlength="40">
                </font></div></td>
            <td height="30" align="center"> <div align="left"><font color="#990000" face="Webdings">4</font><font face="Georgia">Telephone 
                Number</font></div></td>
            <td height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="telephone_number" type="text" id="telephone_number" value="<? echo "$telephone_number"; ?>" size="20" maxlength="10">
                </font></div></td>
          </tr>
          <tr> 
            <td height="30" align="center"> <div align="left"><font color="#FFFFFF" face="Webdings">4</font><font face="Georgia">Company 
                Name</font></div></td>
            <td height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="company_name" type="text" id="company_name" value="<? echo "$company_name"; ?>" size="20" maxlength="25">
                </font></div></td>
            <td height="30" align="center"> <div align="left"><font color="#990000" face="Webdings">4</font><font face="Georgia">Address</font></div></td>
            <td height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="address" type="text" id="address" value="<? echo "$address"; ?>" size="20" maxlength="25">
                </font></div></td>
          </tr>
          <tr> 
            <td height="30" align="center"> <div align="left"><font color="#990000" face="Webdings">4</font><font face="Georgia">City</font></div></td>
            <td height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="city" type="text" id="city" value="<? echo "$city"; ?>" size="20" maxlength="10">
                </font></div></td>
            <td height="30" align="center"> <div align="left"><font color="#FFFFFF" face="Webdings">4</font><font face="Georgia">State</font></div></td>
            <td height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="address2" type="text" id="address2" value="<? echo "$state"; ?>" size="20" maxlength="25">
                </font></div></td>
          </tr>
          <tr> 
            <td height="30" align="center"> <div align="left"><font color="#990000" face="Webdings">4</font><font face="Georgia">Zip 
                Code</font></div></td>
            <td height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="zip_code" type="text" id="zip_code" value="<? echo "$zip_code"; ?>" size="20" maxlength="5">
                </font></div></td>
            <td height="30" align="center"> <div align="left"><font color="#990000" face="Webdings">4</font><font face="Georgia">Username</font></div></td>
            <td height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="username" type="text" id="username" value="<? echo "$username"; ?>" size="20" maxlength="8">
                </font></div></td>
          </tr>
          <tr> 
            <td height="5"> <div align="left"></div></td>
            <td height="5"> <div align="left"><font color="#990000" size="-1" face="Webdings">4</font><font color="#000000" size="-1" face="Georgia"> 
                <em>Required fields!</em></font></div></td>
            <td height="5"> <div align="left"></div></td>
            <td height="5"> <div align="left"><font size="-1" face="Georgia"><var>max. 
                8 characters</var></font></div></td>
          </tr>
          <tr> 
            <td height="30" align="center"> <div align="left"><font color="#990000" face="Webdings">4</font><font face="Georgia">Password</font></div></td>
            <td height="30" align="center"> <div align="left"><font face="Georgia"> 
                <input name="password" type="text" id="password" value="<? echo "$password"; ?>" size="20" maxlength="10">
                </font></div></td>
            <td height="30" align="center"> <div align="left"><font color="#990000" face="Webdings">4</font><font face="Georgia">User 
                Level </font></div></td>
            <td height="30" align="center"> <div align="left"><font face="Georgia"> 
                <select name="user_level" id="user_level">
                  <option value="1">Member</option>
                  <option value="2">Client</option>
                  <option value="3">Client/Mentor</option>
                  <option value="9">Admin</option>
                </select>
                </font></div></td>
          </tr>
          <tr> 
            <td height="5" colspan="2" align="center"><div align="left"></div></td>
            <td height="5" colspan="2" align="center"><div align="left"></div></td>
          </tr>
          <tr> 
            <td height="5" align="center"> <div align="left"></div></td>
            <td height="5" align="center"> <div align="left"></div></td>
            <td height="5" align="center"> <div align="left"></div></td>
            <td height="5" align="center"> <div align="left"></div></td>
          </tr>
          <tr> 
            <td height="20" colspan="4"> <div align="left"> <font color="#FFFFFF">f</font>User 
                Level Details:</div></td>
          </tr>
          <tr> 
            <td colspan="4"><table width="645" border="1" align="center" cellpadding="2" cellspacing="0">
                <tr> 
                  <td width="101"><div align="left">Member</div></td>
                  <td width="530"><div align="left">Access to Property Preview</div></td>
                </tr>
                <tr> 
                  <td><div align="left">Client</div></td>
                  <td><div align="left">Access to Daily Sales, Property Preview, 
                      Forum, Seminars</div></td>
                </tr>
                <tr> 
                  <td><div align="left">Client/Mentor</div></td>
                  <td><div align="left">Access to Daily Sales, Mentor Program, 
                      Property Preview, Forum, Seminars</div></td>
                </tr>
                <tr> 
                  <td><div align="left">Admin </div></td>
                  <td><div align="left">Access to All and Admin Tools (Very Dangerous 
                      Level!!!) </div></td>
                </tr>
                <tr> 
                  <td><div align="left"></div></td>
                  <td><div align="left"></div></td>
                </tr>
              </table></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td colspan="2"> <div align="right"> 
                <input type="submit" name="Submit" value="Update Contact">
              </div></td>
            <td colspan="2"> <div align="left"> 
                <a href="tools_admin.php">Return to Main Menu</a>
              </div></td>
          </tr>
        </table>
    </form><td width="20"></td>
  </tr>
</table>
</body>
</html>
I hope somebody can tell me what the hack is going on or wrong here! THANKS
Post Reply