Can reference some items in database but not others
-
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 * FROMwp_fm_data_1
WHERE user='”.$this_user.”‘ ORDER BYwp_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.
- The topic ‘Can reference some items in database but not others’ is closed to new replies.