Post values selected from dropdown into mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

add this to the beginning of your script:

Code: Select all

<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
?>
This will show not critical errors in the code. If the page is still blank then it is a syntax issue (unclosed bracket, missing semi-colon, etc).
JimiH
Forum Commoner
Posts: 92
Joined: Thu Jun 15, 2006 6:10 am

Post by JimiH »

Yes must be something missing the page is still blank!
I recreated the basic problem at home so the tables and fields are different until I get back to work.

Code: Select all

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1); 
echo $TAB1FIELD3  ;	
echo"<select name=\"TAB1FIELD3\">"; 
while($row=mysql_fetch_assoc($my_query)) 
{ 

$selected = ( $TAB1FIELD3 == $row['TAB2FIELD2'] ) ? ' selected="selected"' : '';
    
echo  '<option value="'.$row['TAB2FIELD2'].'"' . $selected .

//echo  "<option value=\"".$row['TAB2FIELD2']."\">".$row['TAB2FIELD2']."</option>"; 
}
I'll have a look and see whats missing

Thanks

Geoff
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You're missing a semicolon

Code: Select all

<?php
while($row=mysql_fetch_assoc($my_query)) 
{ 
    $selected = ( $TAB1FIELD3 == $row['TAB2FIELD2'] ) ? ' selected="selected"' : '';
    // ON THE BELOW LINE ADD A SEMICOLON
    echo  '<option value="'.$row['TAB2FIELD2'].'"' . $selected .
} 
?>
JimiH
Forum Commoner
Posts: 92
Joined: Thu Jun 15, 2006 6:10 am

Post by JimiH »

Hi

This is strange I pasted your original code at work & it worked first time :D

I must have different versions of PHP or something.

anyway it works, thank you very much for your help.

Geoff
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Your welcome. Post back if you have any other troubles.
Post Reply