小编use*_*661的帖子

使用PHP向MySQL插入NULL的最佳实践

function save($gmt, $name, $address, $phone, $remark)
{
    $query= "INSERT INTO `user` (`gmt`, `name`, `address`, `phone`, `remark`) VALUES ('$gmt', '$name', '$address', '$phone', '$remark')";
    mysql_query($query);
}
Run Code Online (Sandbox Code Playgroud)

这里的地址,电话和备注可以是NULL值.我需要它,以便当我将null参数传递给我的函数时,它在数据库中存储一个空值(NULL).我需要知道这样做的最佳解决方案是什么.

谢谢.

php mysql null insert

9
推荐指数
2
解决办法
2万
查看次数

获取http url参数而不使用PHP自动解码

我有一个网址

test.php?x=hello+world&y=%00h%00e%00l%00l%00o
Run Code Online (Sandbox Code Playgroud)

当我把它写到文件

file_put_contents('x.txt', $_GET['x']); // -->hello world
file_put_contents('y.txt', $_GET['y']); // -->\0h\0e\0l\0l\0o 
Run Code Online (Sandbox Code Playgroud)

但我需要写它没有编码

file_put_contents('x.txt', ????); // -->hello+world
file_put_contents('y.txt', ????); // -->%00h%00e%00l%00l%00o
Run Code Online (Sandbox Code Playgroud)

我能怎么做?

谢谢

php get http

7
推荐指数
2
解决办法
5168
查看次数

标签 统计

php ×2

get ×1

http ×1

insert ×1

mysql ×1

null ×1