Sunday, April 4, 2010

Problems getting data into a SET Column

I am having a problem with the SET Column storing multiple days of the week.?When I submit the form, a link that says function.implode shows up at the top of the page and enters NULL in my Column.?Any ideas why??I also had a lot of server side validation that was in this code.?I removed all of it thinking that might be the problem, but the same thing is happening either way.

Here is the code:

mysql_select_db($database_connRegister, $connRegister);
$query_getusers = ''SELECT * FROM users'';
$getusers = mysql_query($query_getusers, $connRegister) or die(mysql_error());
$row_getusers = mysql_fetch_assoc($getusers);
$totalRows_getusers = mysql_num_rows($getusers);

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
?$editFormAction .= ''?'' . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST[''MM_insert''])) %26amp;%26amp; ($_POST[''MM_insert''] == ''sign_form'')) {
if (isset($_POST['days_to_play'])) {
?$_POST['days_to_play'] = implode(',', $_POST['days_to_play']);
} else {
?$_POST['days_to_play'] = 'Monday';
}
?$insertSQL = sprintf(''INSERT INTO users (user_name, password, first_name, last_name, address, city, `state`, zip, phone_number, member_since, email, days_to_play, handicap, home_course, play_in_tournaments, casual_compet, hear_about_us, confirm_pass, site_city, text) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'',
GetSQLValueString($_POST['user_name'], ''text''),
GetSQLValueString($_POST['password2'], ''text''),
GetSQLValueString($_POST['first_name'], ''text''),
GetSQLValueString($_POST['last_name'], ''text''),
GetSQLValueString($_POST['address'], ''text''),
GetSQLValueString($_POST['city'], ''text''),
GetSQLValueString($_POST['state'], ''text''),
GetSQLValueString($_POST['zip'], ''int''),
GetSQLValueString($_POST['phone_number'], ''text''),
GetSQLValueString($_POST['member_since'], ''defined'', 'NOW()'),
GetSQLValueString($_POST['email'], ''text''),
GetSQLValueString($_POST['days_to_play'], ''text''),
GetSQLValueString($_POST['handicap'], ''int''),
GetSQLValueString($_POST['home_course'], ''text''),
GetSQLValueString($_POST['play_in_tournaments'], ''text''),
GetSQLValueString($_POST['casual_compet'], ''text''),
GetSQLValueString($_POST['hear_about_us'], ''text''),
GetSQLValueString($_POST['confirm_pass'], ''text''),
GetSQLValueString($_POST['site_city'], ''text''),
GetSQLValueString($_POST['text'], ''text''));

?mysql_select_db($database_connRegister, $connRegister);
?$Result1 = mysql_query($insertSQL, $connRegister) or die(mysql_error());

?$insertGoTo = ''golferstats.php'';
?if (isset($_SERVER['QUERY_STRING'])) {
?$insertGoTo .= (strpos($insertGoTo, '?')) ? ''%26amp;'' : ''?'';
?$insertGoTo .= $_SERVER['QUERY_STRING'];
?}
?header(sprintf(''Location: %s'', $insertGoTo));
}

Problems getting data into a SET Column

What does your insert form look like? Is days_to_play an array? The name of the checkbox group or multiple-select list needs to end in a pair of square brackets like this: name=''days_to_play[]''.

Problems getting data into a SET Column

Yes, I had actually already caught my mistake before you sent this. It is

working now. I have 2 more unrelated questions that can't seem to find in

your book.

#1 - I have an updated page separate from the user input page and I want it

to populate the days_to_play record when they open update so they can edit

these days if they want. I can't get it to show what is already selected.

#2 - I have quotes that appear on the page and it works fine and selects

them randomly when the page is accessed, but I want to add a picture(s).

How can I add pictures to a database table and get them to display randomly

with the text I already have?

Thanks for your help. I am enjoying the book!

David,

One other small problem I have...more of a convenience issue. I have a form

to send a message to another member, but I also want to send the message by

email to that member. Everything is fine except I have a dynamic list menu

for the user to pick the member he wants to send the message to and a hidden

field containing the email. The only problem is, I cant get the email field

to populate automatically when it's selected or changed (I had to use a go

button and then the send button). How can I set it up so the hidden email

field will populate automatically? Right now I have a record set with the

form variable parameter set.

Thanks!

No comments:

Post a Comment