Page 1 of 1

limitations

Posted: Thu Jun 12, 2003 9:17 pm
by stc7outlaw
I am making a program for my dad's company and I am using columns for each form field. And a new table for each record. There are a lot of form fields. Tell me if this is legal and why it wont work. What is supposed to happen is someone types all the form fields in and 2 tables are created for the project store and the project store prices. Then the values are filled in from the form fields to the table. Why wont this work? :



Code: Select all

<?php
if ( !empty($_POST['storenumber']) && !empty($_POST['storeaddress']) && !empty($_POST[ 

'storecity']) && !empty($_POST['storezip']) && !empty($_POST['storestate']) && !empty($_POST 

['storephone']) && !empty($_POST['surveyor']) && !empty($_POST['evaldate']) && !empty($_POST 

['requestor']) && !empty($_POST['requestorphone']) && !empty($_POST['manufacturer']) && ! 

empty($_POST['modelnumber']) && !empty($_POST['modelstyle']) && !empty($_POST['companyname'])  

&& !empty($_POST['companyphone']) && !empty($_POST['concerns']) && !empty($_POST[ 

'electricalpanel']) && !empty($_POST['contactor']) && !empty($_POST['elements']) && !empty( 

$_POST['steamtablewp']) && !empty($_POST['steamcabd']) && !empty($_POST['steamcabmod']) && ! 

empty($_POST['steamcabhe']) && !empty($_POST['producebin']) && !empty($_POST['reachfridge'])  

&& !empty($_POST['panfillsys']) && !empty($_POST['steamtablecont']) && !empty($_POST[ 

'tacowarmunit']) && !empty($_POST['cheesemelter']) && !empty($_POST['integrity']) && !empty( 

$_POST['misc']) && !empty($_POST['summary']) && !empty($_POST['price_electricalpanel']) && ! 

empty($_POST['price_contactor']) && !empty($_POST['price_elements']) && !empty($_POST[ 

'price_elements']) && !empty($_POST['price_steamtablewp']) && !empty($_POST[ 

'price_steamcabwp']) && !empty($_POST['price_steamcabd']) && !empty($_POST[ 

'price_steamcabmod']) && !empty($_POST['price_steamcabhe']) && !empty($_POST[ 

'price_producebin']) && !empty($_POST['price_reachfridge']) && !empty($_POST[ 

'price_panfillsys']) && !empty($_POST['price_steamtablecont']) && !empty($_POST[ 

'price_tacowarmunit']) && !empty($_POST['price_cheesemelter']) && !empty($_POST[ 

'price_integrity']) && !empty($_POST['price_misc']) && !empty($_POST['price_summary'])) {  
    
$user = 'oprods';  
$pass = 'breakin';    
$db = 'projectsdb';  

 $storenumber = $_POST['storenumber']; 
 $storeaddress = $_POST['storeaddress']; 
 $storecity = $_POST['storecity']; 
 $storezip = $_POST['storezip']; 
 $storestate = $_POST['storestate']; 
 $storephone = $_POST['storephone']; 
 $surveyor = $_POST['surveyor']; 
 $evaldate = $_POST['evaldate']; 
 $requestor = $_POST['requestor']; 
 $requestorphone = $_POST['requestorphone']; 
 $manufacturer  = $_POST['manufacturer']; 
 $modelnumber = $_POST['modelnumber']; 
 $modelstyle = $_POST['modelstyle']; 
 $companyname = $_POST['companyname']; 
 $companyphone = $_POST['companyphone']; 
 $concerns = $_POST['concerns']; 
 $electricalpanel = $_POST['electricalpanel']; 
 $contactor = $_POST['contactor']; 
 $elements = $_POST['elements']; 
 $steamtablewp = $_POST['steamtablewp']; 
 $steamcabwp = $_POST['steamcabwp']; 
 $steamcabd = $_POST['steamcabd']; 
 $steamcabmod = $_POST['steamcabmod']; 
 $steamcabhe = $_POST['steamcabhe']; 
 $producebin = $_POST['producebin']; 
 $reachfridge = $_POST['reachfridge']; 
 $panfillsys  = $_POST['panfillsys'];  
 $steamtablecont = $_POST['steamtablecont']; 
 $tacowarmunit = $_POST['tacowarmunit']; 
 $cheesemelter = $_POST['cheesemelter']; 
 $integrity = $_POST['integrity']; 
 $misc = $_POST['misc']; 
 $summary = $_POST['summary']; 

 $price_electricalpanel = $_POST['price_electricalpanel']; 
 $price_contactor = $_POST['price_contactor']; 
 $price_elements = $_POST['price_elements']; 
 $price_steamtablewp = $_POST['price_steamtablewp']; 
 $price_steamcabwp = $_POST['price_steamcabwp']; 
 $price_steamcabd = $_POST['price_steamcabd']; 
 $price_steamcabmod = $_POST['price_steamcabmod']; 
 $price_steamcabhe = $_POST['price_steamcabhe']; 
 $price_producebin = $_POST['price_producebin']; 
 $price_reachfridge = $_POST['price_reachfridge']; 
 $price_panfillsys = $_POST['price_panfillsys']; 
 $price_steamtablecont = $_POST['price_steamtablecont']; 
 $price_tacowarmunit  = $_POST['price_tacowarmunit']; 
 $price_cheesemelter = $_POST['price_cheesemelter']; 
 $price_integrity = $_POST['price_integrity']; 
 $price_misc = $_POST['price_misc']; 
 $price_summary  = $_POST['price_summary']; 
    

   @$link = mysql_connect('localhost', $user, $pass) or die('<p>Could not connect to MySQL 

server.</p>');  
   @mysql_select_db($db) or die('<p>Could not select '.$db.' database');  

   $sql = "SHOW TABLES LIKE 'project_$storenumber'";  
   @$tbl_exists = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');  

   if (mysql_num_rows($tbl_exists) == 1) {  
      echo '<p>Store database project_'.$storenumber.' and Prices database already exist.</ 

p>';  
             
   } else {  
       
      $sql = "CREATE TABLE `project_$storenumber` (storenumber CHAR(255), storeaddress CHAR( 

255), storecity CHAR(255), storezip CHAR(255), storestate CHAR(255), storephone CHAR(255), 

surveyor CHAR(255), evaldate CHAR(255), requestor CHAR(255), requestorphone CHAR(255), 

manufacturer CHAR(255), modelnumber CHAR(255), modelstyle CHAR(255), companyname CHAR(255), 

companyphone CHAR(255), concerns CHAR(255), electricalpanel TEXT, contactor TEXT, elements  

TEXT, steamtablewp TEXT, steamcabwp TEXT, steamcabd TEXT, steamcabmod TEXT, steamcabhe TEXT, 

producebin TEXT, reachfridge TEXT, panfillsys TEXT, steamtablecont TEXT, tacowarmunit TEXT, 

cheesemelter TEXT, integrity TEXT, misc TEXT, summary TEXT)";  
      @mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');  
      echo '<p>Project database created.</p>'; 
      $sql = "CREATE TABLE `projectprices_$storenumber` (price_electricalpanel CHAR(20), 

price_contactor CHAR(20), price_elements CHAR(20), price_steamtablewp CHAR(20), 

price_steamcabwp CHAR(20), price_steamcabd CHAR(20), price_steamcabmod CHAR(20), 

price_steamcabhe CHAR(20), price_producebin CHAR(20), price_reachfridge CHAR(20), 

price_panfillsys CHAR(20), price_steamtablecont CHAR(20), price_tacowarmunit CHAR(20), 

price_cheesemelter CHAR(20), price_integrity CHAR(20), price_misc CHAR(20), price_summary  

CHAR(20))";  
      @mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');  
      echo '<p>Price database created.</p>';  
   }  

    
    
    
   $sql = "REPLACE INTO `project_$storenumber` (storenumber, storeaddress, storecity, 

storezip, storestate, storephone, surveyor, evaldate, requestor, requestorphone, 

manufacturer, modelnumber, modelstyle, companyname, companyphone, concerns, electricalpanel, 

contactor, elements, steamtablewp, steamcabwp, steamcabd, steamcabmod, steamcabhe, 

producebin, reachfridge, panfillsys, steamtablecont, tacowarmunit, cheesemelter, integrity, 

misc, summary 
) VALUES('$storenumber', '$storeaddress', '$storecity', '$storezip', '$storestate', 

'$storephone', '$surveyor', '$evaldate', '$requestor', '$requestorphone', '$manufacturer', 

'$modelnumber', '$modelstyle', '$companyname', '$companyphone', '$concerns', 

'$electricalpanel', '$contactor', '$elements', '$steamtablewp', '$steamcabwp', '$steamcabd', 

'$steamcabmod', '$steamcabhe', '$producebin', '$reachfridge', '$panfillsys', 

'$steamtablecont', '$tacowarmunit', '$cheesemelter', '$integrity', '$misc', '$summary') ";  
   @mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');   
   echo '<p>Project Database info complete.</p>';  

    $sql = "REPLACE INTO `projectprices_$storenumber` (price_electricalpanel, 

price_contactor, price_elements, price_steamtablewp, price_steamcabwp, price_steamcabd, 

price_steamcabmod,price_steamcabhe, price_producebin, price_reachfridge, price_panfillsys, 

price_steamtablecont, price_tacowarmunit, price_cheesemelter, price_integrity, price_misc, 

price_summary) VALUES('$price_electricalpanel', '$price_contactor', '$price_elements', 

'$price_steamtablewp', '$price_steamcabwp', '$price_steamcabd', '$price_steamcabmod', 

'$price_steamcabhe', '$price_producebin', '$price_reachfridge', '$price_panfillsys', 

'$price_steamtablecont', '$price_tacowarmunit', '$price_cheesemelter', '$price_integrity', 

'$price_misc', '$price_summary') ";  
   @mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');   
   echo '<p>Price Database info complete.</p>';  
} else {  
   echo '<p>Please enter all data fields.</p>';  
}  
?>

the php bbcode putts amp next to the amperstand for some reason, but you know what i mean. IS there some error or something that prevents it from actually doing anything?

Posted: Fri Jun 13, 2003 1:31 am
by delorian
Jest there's a big reason that it doesn't work, and that reason is those
amp instead of amperstands.

In if condition you should have:

Code: Select all

if (something && somethin) 

// not 
if (something && something )
It's correct when you write html page, but in php script is a mistake.

Posted: Fri Jun 13, 2003 2:23 am
by []InTeR[]
PHP Just don't understeand delorian, it's clear what he/she wants...
:) :lol:

Posted: Fri Jun 13, 2003 3:31 am
by cactus
What errors are you seeing ??

Regards,

Posted: Fri Jun 13, 2003 1:59 pm
by stc7outlaw
Well, i'm not seeing any errors. It just isnt doing anything at all. I click submit and then it just wipes all of the text boxes clear and does nothing at all. I have the right database and all and the amp thing i am aware off. Its just something the bbcode does to screw up my code, i dont know why it did that. Is there something that I am missing or that i screwed up. Is there limitations to the number of columns you can have? And if so, why because if there are a lot of text fields, then how am i going to be able to make a table with this many parts. These are just some concerns I have, but there should be some reason it doesnt work. PM me if you would like to see the full text, with the HTML or would like to discuss this matter. Thanks a lot. You guys are a blessing.

-Outlaw

Posted: Fri Jun 13, 2003 2:21 pm
by stc7outlaw
sorry,
i got it working. I guess i was putting too many restrictions on my form fields. In case one wasnt filled in none of it worked. Thank you.