Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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