mdmartiny Posted April 1, 2012 Share Posted April 1, 2012 I am using a script that get the field names from a table in a database. It works, however, when I try to remove the underscore(_) from the name. I get an error message. Parse error: syntax error, unexpected '=' in C:\xampp\htdocs\CMS\admin\includes\get_table.php on line 76 This is the section of code that I am using it with $i = 2; while ($i < mysql_num_fields($fieldnamesquery_result)) { $meta = mysql_fetch_field($fieldnamesquery_result, $i); // This is the line of code that I am having problems with $meta.name = str_replace("_", " ", $meta.name); if (!$meta) { echo "No information available"; } $tablecolumn .= "<p>" . $meta->name . ":<input type='text' name='" . $meta->name . "' id='" . $meta->name . "'/></p>"; $i++; Link to comment https://forums.phpfreaks.com/topic/260119-metaname-str_replace-error/ Share on other sites More sharing options...
smerny Posted April 1, 2012 Share Posted April 1, 2012 $meta.name should be $meta->name Link to comment https://forums.phpfreaks.com/topic/260119-metaname-str_replace-error/#findComment-1333208 Share on other sites More sharing options...
mdmartiny Posted April 1, 2012 Author Share Posted April 1, 2012 Now I have another question. I want to have a field that would allow someone to upload an image to the server. Is there a way using this method that I could change the one field type to file. By doing something like if($meta == 'image') { $tablecolumn .= "<p>" . $meta->name . ":<input TYPE='file' name='" . $meta->name . "' id='" . $meta->name . "'/></p>"; } Link to comment https://forums.phpfreaks.com/topic/260119-metaname-str_replace-error/#findComment-1333209 Share on other sites More sharing options...
Drummin Posted April 1, 2012 Share Posted April 1, 2012 The FORM tag would need to be modified adding enctype="multipart/form-data". <form method="post" action="" enctype="multipart/form-data"> Link to comment https://forums.phpfreaks.com/topic/260119-metaname-str_replace-error/#findComment-1333219 Share on other sites More sharing options...
mdmartiny Posted April 1, 2012 Author Share Posted April 1, 2012 What I am trying to do is get a field that will allow me to upload an image. I have it doing that for me but it is also giving me an extra field for the same name. How do I remove the extra field that I do not need? $i = 2; while ($i < mysql_num_fields($fieldnamesquery_result)) { $meta = mysql_fetch_field($fieldnamesquery_result, $i); $meta2 = mysql_fetch_field($fieldnamesquery_result, $i); $meta2->name = str_replace("_", " ", $meta2->name); if ($meta->name == 'image') { $tablecolumn .= "<p>" . $meta2->name . ":<input TYPE='file' name='" . $meta->name . "' id='" . $meta->name . "'/></p>"; } $tablecolumn .= "<p>" . $meta2->name . ":<input type='text' name='" . $meta->name . "' id='" . $meta->name . "'/></p>"; $i++; } I have added a screenshot of what I am talking about Link to comment https://forums.phpfreaks.com/topic/260119-metaname-str_replace-error/#findComment-1333303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.