0

I am running a form that pulls data from multiple mysql tables. However whenever the php/mysql code is in the html form tags it will not read the php/mysql nor will it read any php for exampl echo "here";. I have done this several times before so I imagine it is just an issue with a config file. Any thoughts are much appreciated! Code below.

<td>Education</td>
<td><select name="education">
		<option value="<?echo $education;?>"><?echo $edu_desc;?></option>
		<? echo "here";
		$edusql = ("SELECT unique_id, desc FROM education order by unique_id asc");
		   echo $edusql;
		   $edurslt = mysql_query($edusql) or die("Error: ".mysql_errno().":- ".mysql_error());
while($erow = mysql_fetch_array($edurslt))	
		{
		$unique_id = $erow['0'];
		$desc = $erow['1'];
		?>
		<option value="<?echo $unique_id;?>"><?echo $desc;?></option>
	  <?}
		?>
	</select>
3
Contributors
8
Replies
12
Views
7 Years
Discussion Span
Last Post by camerondane
0

Hi there,

Change your php start tags from <? to <?php as code below.

That should solve the problem.

Please remember to mark the thread as solved if it worked.

Regards,

Max

<td>Education</td><td>

<select name="education">		
<option value="<?php echo $education;?>"><?php echo $edu_desc;?></option>
<?php echo "here";		$edusql = ("SELECT unique_id, desc FROM education order by unique_id asc");
		  echo $edusql;
		  $edurslt = mysql_query($edusql) or die("Error: ".mysql_errno().":- ".mysql_error());
while($erow = mysql_fetch_array($edurslt))			
                           {
			$unique_id = $erow['0'];
			$desc = $erow['1'];
?>		
<option value="<?php echo $unique_id;?>"><?php echo $desc;?></option>	  
<?php 
}		
?>	
</select>
0

Thanks Max! Much appreciated, unfortunately that did not solve it. I should mention that it just stops the page entirely, so the rest of the html form does not output as well. Any other thoughts? Thanks!

0

One other detail it seems only to not execute under a <select>, I am creating a dynamic drop down where the options pull from mysql table. Thanks

0

I tested it with the below code and it displays the following:

Education "and the dropdown box next to it"

Regards,

Max

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<table>
<tr>
<td>Education</td><td>

<select name="education">		
<option value="<?php echo $education;?>"><?php echo $edu_desc;?></option>
<?php echo "here";		$edusql = ("SELECT unique_id, desc FROM education order by unique_id asc");
		  echo $edusql;
		  $edurslt = mysql_query($edusql) or die("Error: ".mysql_errno().":- ".mysql_error());
			while($erow = mysql_fetch_array($edurslt))			{
			$unique_id = $erow['0'];
			$desc = $erow['1'];
											?>		
<option value="<?php echo $unique_id;?>"><?php echo $desc;?></option>	  
<?php 
}		
?>	
</select>

</td>
</tr>
</table>

</body>
</html>

If it still does not work, please post more code, I think the problem lies in the HTML code surrounding the PHP

0

Here is the entire page below. And the link to the beta page: http://www.opcionesinternacionales.com/fasty75/Userport/admin/ap_app_detail.php
Much appreciated!

<?php
require ("db_con.php");

$select = ("SELECT ap_info.ap_id, ap_info.f_name, ap_info.l_name, ap_info.dob, ap_info.email, ap_info.skype, ap_info.home_phone, ap_info.cell_phone, ap_info.home_add, ap_info.education, education.desc, ap_info.marital_status, marital_status.desc, nationality, start_date, end_date, driving, cycling FROM ap_info join education on education.unique_id = ap_info.education join marital_status on marital_status.marital_id = ap_info.marital_status where ap_info.ap_id = '2'");
echo $select;

$result = mysql_query($select) or die("Error: ".mysql_errno().":- ".mysql_error());
while($lrow = mysql_fetch_array($result))
		
		{
		$ap_id = $lrow['0'];
		$f_name = $lrow['1'];
		$l_name = $lrow['2'];
		$dob = $lrow['3'];
		$email = $lrow['4'];
		$skype = $lrow['5'];
		$home_phone = $lrow['6'];
		$cell_phone = $lrow['7'];
		$home_add = $lrow['8'];
		$education = $lrow['9'];
		$edu_desc = $lrow['10'];
		$marital_status = $lrow['11'];
		$marital_desc = $lrow['12'];
		$nationality = $lrow['13'];
		$start_date = $lrow['13'];
		$end_date = $lrow['14'];
		$driving = $lrow['15'];
		$cycling = $lrow['16'];
		}
		
?>
<form action="detail_submit.php" method="post"
<table cellpadding="2" cellspacing="2" border="1">
<tr>
<td>First Name</td>
<td><input type="text" name="f_name" value="<?php echo $f_name;?>"></td>
</tr>

<tr>
<td>Last Name</td>
<td><input type="text" name="l_name" value="<?php echo $l_name;?>"></td>
</tr>

<tr>
<td>DOB</td>
<td><input type="text" name="dob" value="<?php echo $dob;?>"></td>
</tr>

<tr>
<td>Email</td>
<td><input type="text" name="email" value="<?php echo $email;?>"></td>
</tr>

<tr>
<td>Skype</td>
<td><input type="text" name="skype" value="<?php echo $skype;?>"></td>
</tr>

<tr>
<td>Home Phone</td>
<td><input type="text" name="home_phone" value="<?php echo $home_phone;?>"></td>
</tr>

<tr>
<td>Cell Phone</td>
<td><input type="text" name="cell_phone" value="<?php echo $cell_phone;?>"></td>
</tr>

<tr>
<td>Address</td>
<td><textarea name="home_add" rows="3" cols="18"><?php echo $home_add;?></textarea></td>
</tr>

<tr>
<td>Education</td>
<td><select name="education">
		<option value="<?php echo $education;?>"><?php echo $edu_desc;?></option>
		<?php echo "here";
		$edusql = ("SELECT unique_id, desc FROM education order by unique_id asc");
		   echo $edusql;
		   $edurslt = mysql_query($edusql) or die("Error: ".mysql_errno().":- ".mysql_error());
while($erow = mysql_fetch_array($edurslt))	
		{
		$unique_id = $erow['0'];
		$desc = $erow['1'];
		?>
		<option value="<?php echo $unique_id;?>"><?php echo $desc;?></option>
	  <?php 
	  }
		?>
	</select>	
</td>
</tr>

<tr>
<td>Marital</td>
<td><select name="marital">
		<option value="<?php echo $marital;?>"><?php echo $marital_desc?></option></td>
		<?php $marsql = ("SELECT marital_id, desc FROM marital_status order by marital_id asc");
		   $marrslt = mysql_query($marsql) or die("Error: ".mysql_errno().":- ".mysql_error());
while($mrow = mysql_fetch_array($marrslt))	
		{
		$marital_id = $mrow['0'];
		$mar_desc = $mrow['1'];
		?>
		<option value="<?php echo $marital_id;?>"><?php echo $mar_desc;?></option>
	  <?php 
	  }
		?>
	</select>	
</tr>

<tr>
<td>Nationality</td>
<td><input type="text" name="nationality" value="<?php echo $nationality;?>"></td>
</tr>

<tr>
<td>Start Date</td>
<td><input type="text" name="start_date" value="<?php echo $start_date;?>"></td>
</tr>

<tr>
<td>End Date</td>
<td><input type="text" name="end_date" value="<?php echo $end_date;?>"></td>
</tr>

<tr>
<td>Driving</td>
<td><input type="text" name="driving" value="<?php echo $driving;?>"></td>
</tr>


<tr>
<td>Cycling</td>
<td><input type="text" name="cycling" value="<?php echo $cycling;?>"></td>
</tr>

<tr>
<td>Passport #</td>
<td><input type="text" name="pass_num" value="<?php echo $pass_num;?>"></td>
</tr>

<tr>
<td>Passport Country</td>
<td><input type="text" name="pass_country" value="<?php echo $pass_country;?>"></td>
</tr>

<tr>
<td>Languages</td>
<td>
<?php
$sellang = ("SELECT languages_ap.lang_id, languages.language, languages_ap.speaks FROM languages_ap join languages on languages.lang_id = languages_ap.lang_id WHERE languages_ap.ap_id = '$ap_id' order by languages.lang_id ");
//echo $sellang;
$langrslt = mysql_query($sellang) or die("Error: ".mysql_errno().":- ".mysql_error());
while($lrow = mysql_fetch_array($langrslt))	
		{
		$lang_id = $lrow['0'];
		$language = $lrow['1'];
		$speaks = $lrow['2'];?>
		<input type="checkbox" name="<?php echo $language;?>" value="<?php echo $lang_id;?>" <?php if ($speaks == 'y'){echo "checked";}?>>&nbsp;<?php echo $language;?></br>
		
		<?php 
		}
?>
</td>
</tr>

<tr>
<td>First Aid</td>
<td><input type="text" name="first_aid" value="<?php echo $first_aid;?>"></td>
</tr>
<tr><td><input type="hidden" name="ap_id" value="<?php echo $ap_id;?>"></td>
<td><input type="Submit" value="Submit"></td>
</tr>
</table>
</form>
0
("SELECT ap_info.ap_id, ap_info.f_name, ap_info.l_name, ap_info.dob, ap_info.email, ap_info.skype, ap_info.home_phone, ap_info.cell_phone, ap_info.home_add, ap_info.education, education.desc, ap_info.marital_status, marital_status.desc, nationality, start_date, end_date, driving, cycling FROM ap_info join education on education.unique_id = ap_info.education join marital_status on marital_status.marital_id = ap_info.marital_status where ap_info.ap_id = '2'")
("SELECT languages_ap.lang_id, languages.language, languages_ap.speaks FROM languages_ap join languages on languages.lang_id = languages_ap.lang_id WHERE languages_ap.ap_id = '$ap_id' order by languages.lang_id ");

Remove the curly brackets '()'. This may cause the SQL injection when the query run.

mysql_query($sellang)

This one will look like:

mysql_query(("SELECT languages_ap.lang_id, languages.language, languages_ap.speaks FROM languages_ap join languages on languages.lang_id = languages_ap.lang_id WHERE languages_ap.ap_id = '$ap_id' order by languages.lang_id "))

Try this one:

$select = "SELECT ap_info.ap_id, ap_info.f_name, ap_info.l_name, ap_info.dob, ap_info.email, ap_info.skype, ap_info.home_phone, ap_info.cell_phone, ap_info.home_add, ap_info.education, education.desc, ap_info.marital_status, marital_status.desc, nationality, start_date, end_date, driving, cycling FROM ap_info join education on education.unique_id = ap_info.education join marital_status on marital_status.marital_id = ap_info.marital_status where ap_info.ap_id = '2'";

Instead of

$select = ("SELECT ap_info.ap_id, ap_info.f_name, ap_info.l_name, ap_info.dob, ap_info.email, ap_info.skype, ap_info.home_phone, ap_info.cell_phone, ap_info.home_add, ap_info.education, education.desc, ap_info.marital_status, marital_status.desc, nationality, start_date, end_date, driving, cycling FROM ap_info join education on education.unique_id = ap_info.education join marital_status on marital_status.marital_id = ap_info.marital_status where ap_info.ap_id = '2'");

Hope this help ..!

0

Z it doesn't alter the output in any way, dang it. I appreciate your help. Does anyone think it could be an Apache config file issue somewhere on the server? It is through godaddy and they do not offer technical support!

0

It won't execute under a <select> but outside of a <select> the php will execute? It is very strange. Instead of using drop downs I will just use check boxes. Thanks for all your help!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.