• Resolved pippinontheroof

    (@pippinontheroof)


    Banging my head against a brick wall with this one…

    I have written some code to pull data from a table (wp_fm_data_1) which sits in a template php file. What I can’t understand is that some fields work fine and others return an error. For instance the fields “user”, “user_ip”, “unique_id”, “post_id” all let the code run without error and correctly. However, as soon as I use one of the fields I created using the Form Manager plug-in in an echo or print statement, (for instance “text-504877399685a”) then I get syntax errors such as:

    Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /www/sites/696/cce/wchf.catontheroofwebdesign.co.uk/web/wp-content/themes/twentyeleven/walesbyformalsubmissions.php on line 43

    The error is returned with any custom field produced with the Form Manager plugin, but not with the fields the plugin creates automatically.

    This code works:

    <?php
    global $wpdb;
    global $current_user;
    get_currentuserinfo();
    $this_user=$current_user->user_login;
    $sql=”SELECT * FROM wp_fm_data_1 WHERE user='”.$this_user.”‘ ORDER BY wp_fm_data_1.text-504877399685a ASC LIMIT 0 , 30″;

    $posts = $wpdb->get_results($sql);
    print(”

      “);
      foreach ($posts as $post);
      { echo $post->user;
      print(‘unique_id.'”> Edit‘);
      print(”);
      }
      print(“

    “); ?>

    But if I want to have a different field displayed and edit the echo $post->user; to echo $post->text-504877399685a; then I get the syntax eror produced above.

    Any ideas why, and how I can go about rectifying this?

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter pippinontheroof

    (@pippinontheroof)

    After another couple of hours realised that the echo statement was having trouble handling the “-” symbol in the header names. Those created automatically by the plugin included an underscore instead, and therefore the problem didn’t arise. Those custom ones whose headers were generated automatically by the plug in for some reason included hyphens rather than underscores. Annoying but rectified by putting the header name in a sting without hyphens.

    Problem sorted.

    Hello. I know you have solved this 8 month ago but I’m fall in the same problem and you put me to the right way… so thank you!!! I don’t speak english very well and I don’t understand what does it means a

    sting without hyphens

    so forgive me if I write the same thing… but I solved this problem by using this strange character (`) that is not an apostrophe but a backtick. I cannot put an example because this sign is the quote sign but I think you have understand!

    Thank you again. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can reference some items in database but not others’ is closed to new replies.