SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What Im Doing Wrong?????????????

    hi!

    in file x1.php i have this:

    PHP Code:
    $action $HTTP_GET_VARS['action']; 
      if (
    $action == 'draw_step1') { 
        
    draw_step1(); 
      } 
    HTML Code:
    <a href="admstyle.php?action=draw_step1">Body</a><br>
    PHP Code:
    if( isset($_POST["db_submit"]) ) process_step1(); 
    this call another file with functions x2.php

    PHP Code:
    <?php
    function draw_step1()
    {
    ?>
    HTML Code:
    <strong>Body</strong><br><br>
    <form ENCTYPE="multipart/form-data" name="tcp_test" method="post" action="<?=$_SERVER['PHP_SELF']?>" style="margin-bottom:0; margin-top:0">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>              
                    <td width="300"> <div align="left">Left Margin:</div></td>
                    <td>
                        <div align="left">
                          <input name="blmargin" type="text" size="5" value="0">px
                        </div>
                      </td>
                         </tr>
                  <tr> 
                    <td><div align="left">Top Margin:</div></td>
                    <td>
                        <div align="left">
                          <input name="btmargin" type="text" size="5" value="0" >px
                        </div>
                      </td>
                  </tr>
                  <tr> 
                    <td><div align="left">Margin Width:</div></td>
                    <td><div align="left">
                          <input name="bmwidth" type="text" size="5" value="0">px
                        </div></td>
                  </tr>
                  <tr> 
                    <td><div align="left">Margin Height:</div></td>
                    <td><div align="left">
                          <input name="bmheight" type="text" size="5" value="0">px
                        </div></td>
                  </tr>
                  <tr> 
                    <td><div align="left">Background Image:</div></td>
                    <td align="left"><INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1024000"> 
    <INPUT NAME="bgimage" TYPE="file"></td>
                  </tr>
                  <tr> 
                    <td>Background Color (HTML Code):</td>
                    <td><a href="javascript:TCP.popup(document.forms['tcp_test'].elements['input0'])">Pick a color </a><input type="Text" name="input0" size="8" value="#FFFFFF"></td>
                  </tr>
    <tr> 
                    <td align="left">Font face:</td>
                    <td><select name="bff"><option>Arial</option><option>Verdana</option><option>Geneva</option>
    <option>Times New Roman</option><option>Courier New</option>
              </select></td>
                  </tr>
    <tr> 
                    <td align="left">Font color:</td>
                    <td><a href="javascript:TCP.popup(document.forms['tcp_test'].elements['input1'])">Pick a color </a><input type="Text" name="input1" size="8" value="#FFFFFF"></td>
                  </tr>
    <tr> 
                    <td align="left">Font size:</td>
                    <td><select name="bfs"><option>5</option><option>4</option><option>3</option><option>2</option><option>1</option>
    <option>-1</option><option>-2</option><option>-3</option>
              </select></td>
                  </tr>
                  <tr><td width="10">&nbsp;</td><td>&nbsp;</td>
                  </tr><tr>
                    <td width="150"><div align="left"><font color="#ff0000" size="-2">You 
                        can choose only one background; image or color and left the 
                        other field empty!</font></div></td>
                    <td>&nbsp;</td>
                  </tr>
    <tr><td></td><td align="right"><input type="submit" name="db_submit" value="Update"></td></tr>
                </table></form>
    PHP Code:
    <?php
    }
    function 
    process_step1()
    {
    if((
    $blmargin!="") && ($btmargin!=""))
      {    
    $ret "INSERT INTO wt_style_design_body VALUES('', '$blmargin', '$btmargin', '$bmwidth', '$bmheight', '$bgimage', '$input0', '$bff', '$input1', '$bfs')";
          
    $resultat mysql_query($ret);
        
    mysql_close($connect);
    echo 
    "<font color='#ff0000'>Data sucessfully stored!</font><br>";
    } else {
    echo 
    "<font color='#ff0000'>Inserting data problems</font><br>";  
    }}
    ?>
    and i get every time "Inserting data problems"!!!!!!!
    the mysql connection is ok couse there is no mysql_error!!!!!
    where im doing wrong!!!!
    i cant be clearly more then this to explain!!!!!
    any suggestion or help please!!!
    thanx in advance!

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doesn't look to me like you defined the variables your checking other then in the POST array.

    try:

    PHP Code:

    <?php 

    function 
    process_step1() 

    if((
    $_POST["blmargin"] !="") && ($_POST["btmargin"] !="")) 
      {     
    $ret "INSERT INTO wt_style_design_body VALUES('', '$blmargin', '$btmargin', '$bmwidth', '$bmheight', '$bgimage', '$input0', '$bff', '$input1', '$bfs')"
          
    $resultat mysql_query($ret); 
        
    mysql_close($connect); 
    echo 
    "<font color='#ff0000'>Data sucessfully stored!</font><br>"
    } else { 
    echo 
    "<font color='#ff0000'>Inserting data problems</font><br>";   
    }} 
    ?>
    you should use $_POST instead of $HTTP_POST_VARS...as $HTTP_POST_VARS is depreciated.


    hth..
    [0]DemonicPuffin
    Co-Founder/Systems Developer
    0 Group / NekoBurst Web Networks

  3. #3
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    now it works but the mysql table is empty?
    no fields?
    why that now?
    thanx in advance

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry...foregot to point out your query also contains the wrong variables...change your query variables like I pointed out with the if statement....or(easier) define the variables like:

    PHP Code:

    $blmargin 
    $_POST["blmargin"]; 
    for all of them..
    [0]DemonicPuffin
    Co-Founder/Systems Developer
    0 Group / NekoBurst Web Networks

  5. #5
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have added the upload script which wont work and the other stuff work perfectly!!!
    PHP Code:
    <?php
    }
    function 
    process_step1()
    {
    $path "$fpath";
    $bgimage "$UploadedFile_name";
    $blmargin $_POST["blmargin"]; 
    $btmargin $_POST["btmargin"]; 
    $bmwidth $_POST["bmwidth"]; 
    $bmheight $_POST["bmheight"]; 
    $bgimage $_POST["bgimage"]; 
    $input0 $_POST["input0"]; 
    $bff $_POST["bff"]; 
    $input1 $_POST["input1"]; 
    $bfs $_POST["bfs"]; 
    if((
    $_POST["blmargin"] !="") && ($_POST["btmargin"] !="")) 
      {    
    $ret "INSERT INTO wt_style_design_body VALUES('', '$blmargin', '$btmargin', '$bmwidth', '$bmheight', '$bgimage', '$input0', '$bff', '$input1', '$bfs')";
          
    $resultat mysql_query($ret);
        
    mysql_close($connect);
    echo 
    "<font color='#ff0000'>Data sucessfully stored!</font><br>";
    } else {
    echo 
    "<font color='#ff0000'>Inserting data problems!</font><br>";  
    }
        if( 
    $UploadedFile != none )
        {
            if (
    copy$UploadedFile "$path/$UploadedFile_name)){
                print 
    "<font color='#ff0000'>File uploaded sucessfully!</font><br>";
            }else{
                print 
    "<font color='#ff0000'>Cant upload selected file!</font><br>";
            } 
            
    unlink($UploadedFile);
        }else{
            print 
    "No file selected.<br>";
        }

    }
    the path must be defined here or not? couse i have put it into config php!
    suggestions?
    thanx in advance

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey...
    sorry I was at school..

    um....

    PHP Code:
    $path "$fpath"
    would be better as:
    PHP Code:
    $path $fpath
    more importantly:

    PHP Code:
    if($UploadedFile != none
    is an invalid way to check if nothing is in the field....use:

    PHP Code:
    if($UploadedFile != NULL
    and..where is $UploadedFile defined?uploaded files are contained in the $_FILES["fieldname"] array...which is a multi-dimensional array containing the file's information,this link should help you:

    http://ca2.php.net/manual/en/features.file-upload.php

    hth..
    [0]DemonicPuffin
    Co-Founder/Systems Developer
    0 Group / NekoBurst Web Networks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •