douhan5853 2016-05-24 06:04
浏览 8

使用MySQL和PHP,图像名称具有“+”符号时无法保存图像名称

I need one help.i need to save one image name inside database which contains + sysmbol in its name but after saving its creating space at the place of +. I am explaining below the image name.

fmfvweoujrm_G+G image is the image i need to store into data database but after storing i found fmfvweoujrm_G G image.jpg inside database.I am explaining the code below.

$image=$_POST['image'];
$sql=mysqli_query($connect,'INSERT INTO db_restaurant_basic (date,image) values ("'.$date.'","'.$image.'",)');

Here i need whatever the original image name that should store inside database.Please help me.

  • 写回答

1条回答 默认 最新

  • douhuan1257 2016-05-24 06:14
    关注

    It is not necessary to escape + in the database. Instead, most likely, the problem occurs when showing the data from the database.

    Check the content of your database if it really contains the blank or the plus character by using mysql command line utility or some tool like phpMyAdmin.

    If my assumption is true, you are creating an image tag and use the string from the database as the src attribute. When the browser reads the attribute, it converts the + into the blank.

    If so, you need to escape it for the browser when creating the attribute:

    echo '<img src="' . urlencode($imgage) . '">';
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度