Re: Cant set info in DB...HELP

From: Date: Sat, 02 Jun 2007 11:03:40 +0000
Subject: Re: Cant set info in DB...HELP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-256002@lists.php.net to get a copy of this message
On 6/2/07, kvigor <k3cheese@insightbb.com> wrote:
Hello, I'm using phpMyAdmin and I can't get any of my form data into the database. It returns message: "MySQL returned an empty result set" w/in phpMyAdmin GUI. However I get no errors on screen when form info is submitted. What I have done to solve issue: drop DB and create new. Review form vars and SQL statements can't find errors...help Please help... //=====================FORM====================================== <?php echo "<div> <link href='css/SOS.css' rel='stylesheet' type='text/css' /> <form id='form1' method='post' action=''>
    <label for='select'></label>
    <label for='conName'><span
class='style2'>Consumer Information</span><br />
    <br />
    *Name:</label>
<input type='text' name='conName' id='formPosition' size='100' class='nameAddressCity_pos' value='{$_POST['conName']}'/>
       <br />
       <br />
    <label for='conAddress'>*Address:</label>
<input name='conAddress' type='text' class='nameAddressCity_pos' id='textfield' value='{$_POST['conAddress']}' size='100' />
       <br />
       <br />
    <label for='conCity'>*City:</label>
<input name='conCity' type='text' class='nameAddressCity_pos' id='textfield' value='{$_POST['conCity']}' />
    <label for='conState' class='stateLabel'>
*State:</label> <input name='conState' type='text' class='state' id='textfield' value='{$_POST['conState']}' />
    <label for='conZip'
class='zipLabel'>*Zip:</label> <input name='conZip' type='text' class='zip' id='textfield' value='{$_POST['conZip']}' />
      <br />
      <br />
    <label for='conPhone'>*Phone:</label>
<input name='conPhone' type='text' class='nameAddressCity_pos' id='textfield' value='{$_POST['conPhone']}' />
      <br />
      <br />
      <br />
       <span class='style2'>School Nomination
Information </span><br />
      <br />
       <label for='schName'>*Name:</label>
<input name='schName' type='text' class='nameAddressCity_pos' id='textfield' value='{$_POST['schName']}' size='100' />
      <br />
      <br />
       <label for='schAddress'>*Address:</label>
<input name='schAddress' type='text' class='nameAddressCity_pos' id='textfield' value='{$_POST['schAddress']}' size='100' />
      <br />
      <br />
       <label for='schCity'>*City:</label>
<input name='schCity' type='text' class='nameAddressCity_pos' id='textfield' value='{$_POST['schCity']}' />
       <label for='schState'
class='stateLabel'>*State:</label> <input name='schState' type='text' class='state' id='textfield' value='{$_POST['schState']}'/>
       <label for='schZip'
class='zipLabel'>*Zip:</label> <input name='schZip' type='text' class='zip' id='textfield' value='{$_POST['schZip']}' />
      <br />
      <br />
       <span class='style2'><br />
       Store Shopped At<br />
       <br />
</span>
       <label for='strName'>*Name:</label>
<input name='strName' type='text' class='nameAddressCity_pos' id='textfield' value='{$_POST['strName']}' size='100'/>
      <br />
      <br />
      <br />
       <label for='strCity'>*City:</label>
<input name='strCity' type='text'class='nameAddressCity_pos' id='textfield' value='{$_POST['strCity']}' />
       <label for='strStat'
class='stateLabel'>*State:</label> <input name='strState' type='text' class='state' id='textfield' value='{$_POST['strState']}' />
      <br />
      <br />
      <br />
    <label for='Reset'></label>
<input type='reset' name='reset' value='Reset' id='Submit'/>
    <label for='Sumbit'></label>
<input type='submit' name='submit' value='Submit' id='Reset'/> </form></div>"; //====================END==FORM================================================ echo" <br /><br /><br /><br /><br /><br />"; //===============================striptags=and=trim=================================== $regName = trim(strip_tags($_POST['conName'])); $regAddress = trim(strip_tags($_POST['conAddress'])); $regCity = trim(strip_tags($_POST['conCity'])); $regState = trim(strip_tags($_POST['conState'])); $regZip = trim(strip_tags($_POST['conZip'])); $regPhone = trim(strip_tags($_POST['conPhone'])); $sclName = trim(strip_tags($_POST['schName'])); $sclAddress = trim(strip_tags($_POST['schAddress'])); $sclCity = trim(strip_tags($_POST['schCity'])); $sclState = trim(strip_tags($_POST['schState'])); $sclZip = trim(strip_tags($_POST['schZip'])); $stoName = trim(strip_tags($_POST['strName'])); $stoCity = trim(strip_tags($_POST['strCity'])); $stoState = trim(strip_tags($_POST['strState'])); //==============================end=striptags=and=trim=================================== //==============================Begin dbPopulation of Form data============================ $dbserver = "localhost"; $dbuser = "root"; $dbpassword = ""; $dbname = "theDB"; $connection = mysqli_connect($dbserver, $dbuser, $dbpassword, $dbname) or die ("Could not connect to the Server. Contact your Network Administrator or your Web Programmer"); $insert_query = "INSERT INTO contestants (conName, conAddress, conCity, conState, conZip, conPhone, schName, schAddress, schCity, schState, schZip, strName, strCity, strState) VALUES('$regName', '$regAddress', '$regCity', '$regState', '$regZip', '$regPhone', '$sclName', '$sclName', '$sclCity', '$sclState', '$sclZip', '$stoName', '$stoCity', '$stoState')"; mysqli_query($connection,$insert_query); ?> //==============================End dbPopulation of Form data============================
Try to add a die() to the mysqli_query, like this: mysqli_query($connection,$insert_query) or die(mysqli_error($connection)); This will probably tell you that there's an error in your SQL code... Tijnema

« previous php.general (#256002) next »