Jump to content

gristoi

Members
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by gristoi

  1. All I can advise is either build the forms the way I have done or comment out each of ur elements to see which is causing an issue. And I forgot that if u have your framework set to production, u can set turn startup errors and

    Display errors from 0 to 1 in your application.ini

  2. WAMP is apache. It is a bundle of everthing you need. is stands for Windows Apache Mysql Php. But as you have said that everything is working i have had a look at the code you are using. I have corrected some mistakes for you:

    <?php
    
    ini_set('display_errors',1);
    error_reporting(E_ALL);   
    
    $con = mysql_connect("localhost","root","orange");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    echo "Connection established";
    
    mysql_select_db("my_db", $con);
    
    $sql="INSERT INTO Persons (FirstName, LastName, Age) VALUES ('".$_POST['firstname']."',''".$_POST['lastname']."',''".$_POST['age']."')";
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "1 record added with name: ". $_POST[firstname].' '. $_POST[lastname];
    
    mysql_close($con)
    
    ?>

    so replace yours with that.

    One of the problems you had was trying to use php within the sql statement. You need to make sure that the string does not escape. ie

    <?php
    $sql ="SELECT * FROM $_POST["table"]";
    
    // will actually translate to : $sql ="SELECT * FROM $_POST["
    
    

    this is because the double quotes tell the php that this is the end of the string. To get around this you use concatination by adding the '.' around your variable:

     

    <?php
    $sql ="SELECT * FROM ". $_POST["table"] ." ";
    

     

    this is by no means an indepth explination, but a quick search for string concatination in php on google should point you in the right direction

  3. ok, you first need to make suret hat your server is operating correctly. what are you using for your php / apacher server. if you are using windows i would advise using WAMP or something similar. if you have only started doing this then maybe it would be a good idea not to dig yourself into a deeper hole trying to fix a server that you may or may not have corrupted without knowing about it. Installing wamp is extremely easy as most of it is done for you. then you just drop you php files into the wamp/htdocs folder.

     

  4. replace the init part of your form with this. I know this particular form works as i have tested it myself:

    <?php
    public function init(){
    
    	$title = $this->createElement('text', 'title');
    	$title->setLabel('Page Title');
    	$title->setRequired(true);
    	$title->addErrorMessage('You must add a title');
    	$title->addValidator('stringLength', true, array(0, 250))
                                   ->addFilter('StripTags');
    
    	$urlName = $this->createElement('text', 'url');
    	$urlName->setLabel('Url Safe name');
    	$urlName->setRequired(true);
    	$urlName->addErrorMessage('You must add a url name');
    	$urlName->addValidator('stringLength', true, array(0, 250))
                                   ->addFilter('StripTags');
    
    	$menuTitle = $this->createElement('text', 'menu_name');
    	$menuTitle->setLabel('Menu Name');
    	$menuTitle->setAllowEmpty(true);
    	$menuTitle->addValidator('stringLength', true, array(0, 250))
    			  ->addValidator('regex', false, array('/^[a-z_]\S/i'))
                      ->addFilter('StripTags')
                      ->addFilter('StringtoLower');
    
    	$body = $this->createElement('textarea', 'body');
    	$body->setLabel('Page Body');
    	$body->setRequired(true);
    
    
    
    	$this->addElements(array($title,$urlName,$menuTitle,$body));
    	$this->addElement('submit', 'submit', array('label' => 'Submit'));
    	$this->setMethod('POST');
    
    }
    
    

     

    and tell me if it displays

  5. $sql="SELECT CONCAT( get value from other place ) get value from other place , CONCAT(get value from other place ) get value from other place , 
    CONCAT(t.fieldOne,"+",s.FieldTwo ) AS ' get value from other place '
    
    FROM survey s JOIN adminTable t USING(id)
    WHERE 
    get value from other place  
    like 'get value from other place %' ORDER BY datum DESC";

     

    hope that helps

  6. what thehippy is trying to say is that Zend framework uses namespacing autoloading for files. so a class called MY_NEW_CONTACTS_CONTACTFORM would tell zend to look in the following folder structure:

    My

    |--NEW

            |--CONTACTS

                      |--CONTACTFORM.php

     

    look at how your forms class is named.

    I normally add this into my bootstrap.php for most projects:

    <?php
    protected function _initAutoLoad(){
            $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath'=>APPLICATION_PATH,'namespace'=>''));
        	$resourceLoader->addResourceType('model', 'models/','Model_');
        	$resourceLoader->addResourceType('form', 'forms/','Form_');
    }
    ?>
    

    this tells the framework where to look for specific files. So anything that begins with FORM_ will be in the APPLICATION_ROOT/forms folder. So a test form :

    <?php
    class Form_MyForm extends Zend_Form{
    }
    

    means that the form is in forms APPLICATION_ROOT/MyForm.php

     

  7. upload the file to your servers home or root directory then in phpmyadmin use the mysql console

    LOAD DATA LOCAL INFILE '/importfile.csv'  // wherever the file is located relative on the server
    INTO TABLE test_table 
    FIELDS TERMINATED BY ',' 
    LINES TERMINATED BY '\n' 
    (field1, filed2, field3);
    

     

    This function was created with large files in mind. I uploaded 1.2 million rows in around 4 seconds

  8. The principle behind serialising the data is that you can unserialise it when you retrieve the data. a quick example of retrieveing the data in php and mysql is:

     

    <?php
    $result = mysql_query("Select ps_name,ps_member,ps_custom_fields from nexus_purchases where ps_name like 'Varified Owner'");
    ..... all of the standard stuff here
    
    while($row = myql_fetch_array($result)
    {
    $ps_custom_fields_to_array = unserialize($row['ps_custom_fields']);
    $ps_comma_seperated_string = implode(',',$ps_custom_fields_to_array);
    
    // this will make $ps_comma_seperated_string look like X, HAE, ....
    }
    

  9. leave the excel date format as it is and use the date conversion power in mysql to alter the date to a timestamp on insert:

    let say for example you had it showing in the excel sheet as 01/10/2011 00:01:01, then you would do this on the insert:

    $date = '01/10/2011 00:01:01';
    INSERT INTO tbl (`datecolumn`) values (STR_TO_DATE($date,'%d/%m/%Y $h:%i:%s'))
    

     

    you basically use the string to date function in mysql. the left hand part of the argument is the date you are passing in and the right hand part telss it what format the date is in. Mysql will do the rest from there and convert it into a datetime / date for you :)

     

  10. just had a quick look at the link you supplied. it is meant to post over the data. Make sure you have somethingn like firebug installed in your browser and follow the post request to make sure the variables are being passed.. also make sure the javascript is actually posting to the correct page

  11. close, you are getting the blog entry via the url , but you are then posting the form back to itself which wipes out the id. add this into your form

    <input type="hidden" name ='id' value="".$_GET['id'].""/>

     

    that will in effect auto forward your get variable along with the form. then:

    if(isset($_POST['workoutName'])){
            $id = $_POST['id'];
    $workoutName = $_POST['workoutName'];
    $workoutDescription = $_POST['workoutDescription'];
    
    $blogUpdate = mysql_query("UPDATE blog SET workoutName='$workoutName', workoutDescription='$workoutDescription' WHERE id='$id' LIMIT 1") or die (mysql_error());
    
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.