I have an HTML template that is populated with information from a database and echo'd to user as a complete page. Inside one of the fields that is echo'd I tried to insert some php code e.g. but hello doesn't appear to the user, and when I check the source, it is red (nothing appears on the users screen). why would this be? I though that as long as you have a .php file you can embed php code no problem with html. Don't ask why I have the php code stored in a database, it's complicated!
关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率

已采纳
从数据库中检索时,在HTML中嵌入PHP代码不起作用
收起
- 写回答
- 好问题 0 提建议
- 关注问题
微信扫一扫
点击复制链接分享
- 邀请回答
- 编辑 收藏 删除 结题
- 收藏 举报
1条回答 默认 最新
- 关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率
doujiaci7976 2013-06-08 03:12关注You would need to use PHP's
eval()
function, please be careful with this though as it can pose a security risk.You should really address the underlying issue of why you are storing PHP code in a database.
本回答被题主选为最佳回答 , 对您是否有帮助呢? 本回答被专家选为最佳回答 , 对您是否有帮助呢? 本回答被题主和专家选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏举报微信扫一扫
点击复制链接分享
编辑预览轻敲空格完成输入- 显示为
- 卡片
- 标题
- 链接
评论按下Enter换行,Ctrl+Enter发表内容
编辑
预览

轻敲空格完成输入
- 显示为
- 卡片
- 标题
- 链接
报告相同问题?
提交
- 2014-07-16 14:39回答 1 已采纳 A few things: You need to properly open that div tag. You need to select a database using mysql_
- 2016-07-25 04:22回答 1 已采纳 You can do something like htmlentities for encoding and saving it to DB: htmlentities($textareaCo
- 2017-02-13 06:28回答 1 已采纳 According to wpdb::get_results, you can use ARRAY_N wpdb::get_results( string $query = null, s
- 2022-04-30 07:55在这个项目中,`index.jsp` 是主页面,它使用JavaServer Pages(JSP)技术,这是一种动态网页制作语言,允许在HTML中嵌入Java代码,实现服务器端的动态渲染。前端资源通常包括`css`文件夹中的CSS(Cascading Style ...
- 2018-07-31 12:18回答 1 已采纳 I'm thinking that you are working on editing users in your system. You would like to have the abi
- 2016-03-18 22:58回答 3 已采纳 Change if($row = mysqli_fetch_array($result)) { to if(mysqli_num_rows($result) > 0) { Upd
- 2019-04-05 23:00回答 1 已采纳 You return only a single record in the JSON data because you do not iterate through the recordset.
- 2020-10-29 17:28PHP是一种广泛使用的开源脚本语言,它特别适合于Web开发,并能嵌入HTML中使用。而MySQL是一种流行的开源关系型数据库管理系统(RDBMS),其主要目标是为各种应用提供高性能的数据管理。 在Web开发中,经常需要将PHP...
- 2014-05-08 03:19回答 1 已采纳 You can't include php code in javascript , the first is executed on the server side, the second is
- 2015-07-16 15:54回答 1 已采纳 For your form, I suggest the following: <?php session_start(); ?> <!doctype html> <
- 2016-10-12 02:44回答 1 已采纳 You can start with changing $reg= $this->var; to `$req=$var´ or assign ´$var´ to ´$this->var
- 2023-07-04 01:5625号底片~的博客 PHP:查询数据库,并将数据传给前端(在script中直接嵌套php语句)
- 2023-07-20 15:29该压缩包文件“基于PHP的jQuery配合数据库完成的时间线功能代码.zip”包含了使用PHP和jQuery技术来实现一个基于数据库的时间线功能的代码示例。时间线功能通常用于展示按照时间顺序排列的事件或数据,常见于新闻网站...
- 2023-06-06 14:49当其他用户访问时,PHP脚本会从数据库中检索这些留言并显示在页面上。 【数据库设计】 在这个入门级PHP留言板中,数据库用于存储用户的留言信息。一般会有一个名为`messages`的表,包含字段如`id`(唯一标识符)、...
- 2021-05-23 23:31标题中的“OnlineShop”指的是一个在线商店项目,这个项目在前端使用了HTML和CSS技术,而在服务器端则采用了PHP编程语言。这样的组合是常见的Web开发架构,HTML负责页面的结构,CSS负责样式设计,而PHP则处理服务器...
- 没有解决我的问题, 去提问
联系我们(工作时间:8:30-22:00)
400-660-0108kefu@csdn.net在线客服
- 京ICP备19004658号
- 经营性网站备案信息
公安备案号11010502030143
- 营业执照
- 北京互联网违法和不良信息举报中心
- 家长监护
- 中国互联网举报中心
- 网络110报警服务
- Chrome商店下载
- 账号管理规范
- 版权与免责声明
- 版权申诉
- 出版物许可证
- ©1999-2025北京创新乐知网络技术有限公司