sws Posted November 12, 2006 Share Posted November 12, 2006 Hi, I've got a form with a hidden field that captures the username for a visitor to the site.They basically are submitting their picks to the db with the form.I can't figure out how to write the username to the db.Here's the form:[code]<form method="post" action="hockey_pickem.php"> <tr><td align="center" colspan="5"> <input type="hidden" name="id" value="<? stripslashes($online['username'])?>" />[/code]So this code stores the usernameNow in my hockey_pickem.php file, how would I go about writing it to the db ?I've tried the following and have am getting errors.Code:[code]// Define the query.$query = "INSERT INTO nhl_managers(id, lw1, lw2, lw3, lw4, lw5, c1, c2, c3, c4, c5, rw1, rw2, rw3, rw4, rw5, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, g1, g2, g3)VALUES ('{$_POST["stripslashes($online['username'])"]}', '{$_POST['lw1']}', '{$_POST['lw2']}', '{$_POST['lw3']}', '{$_POST['lw4']}', '{$_POST['lw5']}', '{$_POST['c1']}', '{$_POST['c2']}', '{$_POST['c3']}', '{$_POST['c4']}', '{$_POST['c5']}', '{$_POST['rw1']}', '{$_POST['rw2']}', '{$_POST['rw3']}', '{$_POST['rw4']}', '{$_POST['rw5']}', '{$_POST['d1']}', '{$_POST['d2']}', '{$_POST['d3']}', '{$_POST['d4']}', '{$_POST['d5']}', '{$_POST['d6']}', '{$_POST['d7']}', '{$_POST['d8']}', '{$_POST['d9']}', '{$_POST['d10']}', '{$_POST['g1']}', '{$_POST['g2']}', '{$_POST['g3']}')";// Execute the queryif (@mysql_query ($query)) { print '<p>Thank you for submitting your picks this week. GOOD LUCK!</p>';} else { print '<p>Could not add your entry because: <b>' . mysql_error() . '</b>. The query was $query.</p>';}?>[/code]Can somebody please help me get back on the right track ?Much Obliged Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/ Share on other sites More sharing options...
chiprivers Posted November 12, 2006 Share Posted November 12, 2006 I think'{$_POST["stripslashes($online['username'])"]}'should be 'stripslashes($_POST['username'])' Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/#findComment-123499 Share on other sites More sharing options...
sws Posted November 12, 2006 Author Share Posted November 12, 2006 Still didn't work.Here's the problem I'm having.The data is being written to the db but the username field is always blank.I'm using a "hidden" input type to store the username[code]<input type="hidden" name="handle" value="<? stripslashes($online['username'])?>" />[/code]Then I'm trying to insert it to the db. Do I use the [b]name[/b] property of the input type ? That's what I'm doing here but I think it's wrong. Should I be using the value property instead ?[code]<?phpinclude ("config.php"); # Include the config.php file here error_reporting (E_ALL & ~ E_NOTICE); # Don't show notices.// Define the query.$query = "INSERT INTO nhl_managers(handle, lw1, lw2, lw3, lw4, lw5, c1, c2, c3, c4, c5, rw1, rw2, rw3, rw4, rw5, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, g1, g2, g3) // ALL FIELDS IN MY TABLEVALUES ('{$_POST['handle']}', '{$_POST['lw1']}', '{$_POST['lw2']}', '{$_POST['lw3']}', '{$_POST['lw4']}', '{$_POST['lw5']}', '{$_POST['c1']}', '{$_POST['c2']}', '{$_POST['c3']}', '{$_POST['c4']}', '{$_POST['c5']}', '{$_POST['rw1']}', '{$_POST['rw2']}', '{$_POST['rw3']}', '{$_POST['rw4']}', '{$_POST['rw5']}', '{$_POST['d1']}', '{$_POST['d2']}', '{$_POST['d3']}', '{$_POST['d4']}', '{$_POST['d5']}', '{$_POST['d6']}', '{$_POST['d7']}', '{$_POST['d8']}', '{$_POST['d9']}', '{$_POST['d10']}', '{$_POST['g1']}', '{$_POST['g2']}', '{$_POST['g3']}')"; ALL VALUES FROM FORM// Execute the queryif (@mysql_query ($query)) { print '<p>Thank you for submitting your picks this week. GOOD LUCK!</p>';} else { print '<p>Could not add your entry because: <b>' . mysql_error() . '</b>. The query was $query.</p>';}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/#findComment-123514 Share on other sites More sharing options...
chiprivers Posted November 12, 2006 Share Posted November 12, 2006 Should be using:$_POST['handle'] Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/#findComment-123515 Share on other sites More sharing options...
trq Posted November 12, 2006 Share Posted November 12, 2006 Where are you defining the $online array? Can we see it? Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/#findComment-123517 Share on other sites More sharing options...
sws Posted November 12, 2006 Author Share Posted November 12, 2006 I am using $_POST['handle'] but it's writing blank every time I try it. I'm defining $online in the config.php fileconfig.php[code]<?phperror_reporting (E_ALL & ~ E_NOTICE); # Don't show notices. ob_start(); # allows you to use cookies $connect = mysql_connect("$db_host","$db_username","$db_password"); # connect to the database mysql_select_db("$db_database",$connect); # select the database $uname = addslashes($_COOKIE['username']); # get the username cookie $pword = addslashes($_COOKIE['password']); # get the password cookie $query = "SELECT * FROM `users` WHERE username = '".$uname."' AND password = '".$pword."'"; # set a query $online = mysql_fetch_array(mysql_query($query)); # set an array to get any stored information we want about the browsing user include ("functions.php"); # include the functions ?> [/code]I obviously took out the db connect info but otherwise it's all there. Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/#findComment-123520 Share on other sites More sharing options...
trq Posted November 12, 2006 Share Posted November 12, 2006 You really need to do some debugging (or at very least some error trapping). Running a query all inline like that is terrible, you never even check if it fails or not.Are you sure $online['username'] actually has a value? Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/#findComment-123522 Share on other sites More sharing options...
sws Posted November 12, 2006 Author Share Posted November 12, 2006 Yeah I'm definately a newbie but I'm positive that it has a value because I'm using a display message saying Welcome <b>'.stripslashes($online['username']) at the top of the page and it's working.I'll post the entire form and the php file that handles the form because none of their drop down selections are being populated correctly either.Here's how it's supposed to work.The form is supposed to let users choose players from a series of drop down lists that are dynamically generated from the players table.Once they submit the form it is supposed to write the values to a league managers table containing all of their selections and their username.The handle is not being populated at all and the player selections are all being populated with 0's. They are supposed to contain the player id.Any suggestions ?Form page:[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>NHL Pick'em Roster Form</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body bgcolor="#FFFFFF"><?php include ("config.php"); # Include the config.php file here error_reporting (E_ALL & ~ E_NOTICE); # Don't show notices.echo '<table align="center" border="0" cellpadding="0" cellspacing="0" width="850"> <tr> <td height="22" background="images/nav_bar_02.jpg"><font color="#FFFFFF"><marquee behavior="slide" height="22" direction="left">Welcome to ULTIMATE POOLIES.com We are pleased to announce that our HOCKEY Contests are now in progress!!!</marquee></font> </td> </tr> <tr> <td bgcolor="#FFFFFF"><font face="SerpentineDBol" size="+3" color="#FF0000">Ultimate Poolies.com </font>';if(!empty($online['id'])){ print'Welcome <b>'.stripslashes($online['username']). '</b> You have <b>'. ($online['credits']). ' Credits'. '</b>- <a href="logout.php">Logout</a><br />';}else { # Else, they are not logged in. echo 'You must be logged in to use this page.'; /* Note, you could include the login.php file here */ } //you dont really need to keep this all in a php tag, can just break out of it, and let rest be all html.. not in an echo or print?> </td> </tr> <tr> <td height="22" bgcolor="#FFFFFF" align="center"><a href="index.php">Home </a> | <a href="hockey_contests.php">Hockey </a>| Football | Basketball | Baseball | <a href="upforums/index.php" target="_blank">Message Boards </a> | <a href="mailto:admin@ultimatepoolies.com">Contact U.P.</a> </td> </tr> <tr> <td> <table align="center" bgcolor="#FFFFFF" border="2" cellpadding="3" cellspacing="3" width="576"> <tr><td align="center" colspan="5"> <h1>Roster Form</h1></td></tr> <form method="post" action="hockey_pickem.php"> <tr><td align="center" colspan="5"> <input type="hidden" name="handle" value="<? stripslashes($online['username'])?>" /> </td></tr> <tr><td align="center">LW<br /> <select name='lw1'> <? $lw1_sql = "Select * FROM nhl_players WHERE position = 'LW' ORDER BY name ASC"; $lw1_query = mysql_query($lw1_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($lw1_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">C<br /> <select name='c1'> <? $c1_sql = "Select * FROM nhl_players WHERE position = 'C' ORDER BY name ASC"; $c1_query = mysql_query($c1_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($c1_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">RW<br /> <select name='rw1'> <? $rw1_sql = "Select * FROM nhl_players WHERE position = 'RW' ORDER BY name ASC"; $rw1_query = mysql_query($rw1_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($rw1_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">D<br /> <select name='d1'> <? $d1_sql = "Select * FROM nhl_players WHERE position = 'D' ORDER BY name ASC"; $d1_query = mysql_query($d1_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($d1_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">D<br /> <select name='d2'> <? $d2_sql = "Select * FROM nhl_players WHERE position = 'D' ORDER BY name ASC"; $d2_query = mysql_query($d2_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($d2_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> </tr> <tr><td align="center">LW<br /> <select name='lw2'> <? $lw2_sql = "Select * FROM nhl_players WHERE position = 'LW' ORDER BY name ASC"; $lw2_query = mysql_query($lw2_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($lw2_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">C<br /> <select name='c2'> <? $c2_sql = "Select * FROM nhl_players WHERE position = 'C' ORDER BY name ASC"; $c2_query = mysql_query($c2_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($c2_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">RW<br /> <select name='rw2'> <? $rw2_sql = "Select * FROM nhl_players WHERE position = 'RW' ORDER BY name ASC"; $rw2_query = mysql_query($rw2_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($rw2_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">D<br /> <select name='d3'> <? $d3_sql = "Select * FROM nhl_players WHERE position = 'D' ORDER BY name ASC"; $d3_query = mysql_query($d3_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($d3_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">D<br /> <select name='d4'> <? $d4_sql = "Select * FROM nhl_players WHERE position = 'D' ORDER BY name ASC"; $d4_query = mysql_query($d4_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($d4_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> </tr> <tr><td align="center">LW<br /> <select name='lw3'> <? $lw3_sql = "Select * FROM nhl_players WHERE position = 'LW' ORDER BY name ASC"; $lw3_query = mysql_query($lw3_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($lw3_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">C<br /> <select name='c3'> <? $c3_sql = "Select * FROM nhl_players WHERE position = 'C' ORDER BY name ASC"; $c3_query = mysql_query($c3_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($c3_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">RW<br /> <select name='rw3'> <? $rw3_sql = "Select * FROM nhl_players WHERE position = 'RW' ORDER BY name ASC"; $rw3_query = mysql_query($rw3_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($rw3_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">D<br /> <select name='d5'> <? $d5_sql = "Select * FROM nhl_players WHERE position = 'D' ORDER BY name ASC"; $d5_query = mysql_query($d5_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($d5_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">D<br /> <select name='d6'> <? $d6_sql = "Select * FROM nhl_players WHERE position = 'D' ORDER BY name ASC"; $d6_query = mysql_query($d6_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($d6_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> </tr> <tr><td align="center">LW<br /> <select name='lw4'> <? $lw4_sql = "Select * FROM nhl_players WHERE position = 'LW' ORDER BY name ASC"; $lw4_query = mysql_query($lw4_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($lw4_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">C<br /> <select name='c4'> <? $c4_sql = "Select * FROM nhl_players WHERE position = 'C' ORDER BY name ASC"; $c4_query = mysql_query($c4_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($c4_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">RW<br /> <select name='rw4'> <? $rw4_sql = "Select * FROM nhl_players WHERE position = 'RW' ORDER BY name ASC"; $rw4_query = mysql_query($rw4_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($rw4_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">D<br /> <select name='d7'> <? $d7_sql = "Select * FROM nhl_players WHERE position = 'D' ORDER BY name ASC"; $d7_query = mysql_query($d7_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($d7_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">D<br /> <select name='d8'> <? $d8_sql = "Select * FROM nhl_players WHERE position = 'D' ORDER BY name ASC"; $d8_query = mysql_query($d8_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($d8_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> </tr> <tr><td align="center">LW<br /> <select name='lw5'> <? $lw5_sql = "Select * FROM nhl_players WHERE position = 'LW' ORDER BY name ASC"; $lw5_query = mysql_query($lw5_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($lw5_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">C<br /> <select name='c5'> <? $c5_sql = "Select * FROM nhl_players WHERE position = 'C' ORDER BY name ASC"; $c5_query = mysql_query($c5_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($c5_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">RW<br /> <select name='rw5'> <? $rw5_sql = "Select * FROM nhl_players WHERE position = 'RW' ORDER BY name ASC"; $rw5_query = mysql_query($rw5_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($rw5_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">D<br /> <select name='d9'> <? $d9_sql = "Select * FROM nhl_players WHERE position = 'D' ORDER BY name ASC"; $d9_query = mysql_query($d9_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($d9_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">D<br /> <select name='d10'> <? $d10_sql = "Select * FROM nhl_players WHERE position = 'D' ORDER BY name ASC"; $d10_query = mysql_query($d10_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($d10_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> </tr> <tr><td> </td> <td align="center">G<br /> <select name='g1'> <? $g1_sql = "Select * FROM nhl_players WHERE position = 'G' ORDER BY name ASC"; $g1_query = mysql_query($g1_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($g1_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">G<br /> <select name='g2'> <? $g2_sql = "Select * FROM nhl_players WHERE position = 'G' ORDER BY name ASC"; $g2_query = mysql_query($g2_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($g2_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td align="center">G<br /> <select name='g3'> <? $g3_sql = "Select * FROM nhl_players WHERE position = 'G' ORDER BY name ASC"; $g3_query = mysql_query($g3_sql) OR DIE ("There was an error" .mysql_error()); while ($table_row = mysql_fetch_array($g3_query,MYSQL_ASSOC)){ $player_id = $table_row['id']; $player = $table_row['name']; echo "<option value='.$player_id.'>$player</option>n"; } ?> </select> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td align="center"><input type="submit" name="submit" value="Submit Picks!" /></td> <td> </td> <td> </td> </tr> </form> </table> </body></html>[/code]Here's the script that handles the form and is supposed to write the data to the db:[code]<?phpinclude ("config.php"); # Include the config.php file here error_reporting (E_ALL & ~ E_NOTICE); # Don't show notices.// Define the query.$query = "INSERT INTO nhl_managers(handle, lw1, lw2, lw3, lw4, lw5, c1, c2, c3, c4, c5, rw1, rw2, rw3, rw4, rw5, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, g1, g2, g3)VALUES ('{$_POST['handle']}', '{$_POST['lw1']}', '{$_POST['lw2']}', '{$_POST['lw3']}', '{$_POST['lw4']}', '{$_POST['lw5']}', '{$_POST['c1']}', '{$_POST['c2']}', '{$_POST['c3']}', '{$_POST['c4']}', '{$_POST['c5']}', '{$_POST['rw1']}', '{$_POST['rw2']}', '{$_POST['rw3']}', '{$_POST['rw4']}', '{$_POST['rw5']}', '{$_POST['d1']}', '{$_POST['d2']}', '{$_POST['d3']}', '{$_POST['d4']}', '{$_POST['d5']}', '{$_POST['d6']}', '{$_POST['d7']}', '{$_POST['d8']}', '{$_POST['d9']}', '{$_POST['d10']}', '{$_POST['g1']}', '{$_POST['g2']}', '{$_POST['g3']}')";// Execute the queryif (@mysql_query ($query)) { print '<p>Thank you for submitting your picks this week. GOOD LUCK!</p>';} else { print '<p>Could not add your entry because: <b>' . mysql_error() . '</b>. The query was $query.</p>';}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/#findComment-123526 Share on other sites More sharing options...
trq Posted November 12, 2006 Share Posted November 12, 2006 Well lets just print the query and see what that looks like. Change this...[code=php:0]if (@mysql_query ($query)) {[/code]to...[code=php:0]die($query);if (@mysql_query ($query)) {[/code]What does that produce?ps; By the way... I would get out of the habbit right now of using the short <? tags. Use <?php Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/#findComment-123532 Share on other sites More sharing options...
sws Posted November 12, 2006 Author Share Posted November 12, 2006 Hmmm thanks ThorpThis is what I get...INSERT INTO nhl_managers (handle, lw1, lw2, lw3, lw4, lw5, c1, c2, c3, c4, c5, rw1, rw2, rw3, rw4, rw5, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, g1, g2, g3) VALUES ('', '', '.681.', '.681.', '.681.', '.681.', '.212.', '.212.', '.212.', '.212.', '.212.', '.207.', '.207.', '.207.', '.207.', '.207.', '.148.', '.148.', '.148.', '.148.', '.148.', '.148.', '.148.', '.148.', '.148.', '.148.', '', '', '')I see that handle and lw1 is null ?And all the other fields have a . at the beginning. This wont work because it's field tyle int... And there's 3 null values at the end too but those are because there isn't anything in the dropdown menus yet so that's ok.Any suggestions ? Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/#findComment-123538 Share on other sites More sharing options...
sws Posted November 12, 2006 Author Share Posted November 12, 2006 Can anybody please tell me what I'm doing wrong here ? Thorp was helping me but he's offline now.Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/27009-resolved-writing-form-data-to-a-mysql-database/#findComment-123566 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.