Jump to content

$meta.name = str_replace error


mdmartiny

Recommended Posts

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

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>";
		}

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.