php

MySQL update, skip blank fields with PDO

Deadly 提交于 2021-02-18 17:07:57
问题 I would like to update a MySQL row via the form below. The form works great as is but, if I leave a field blank, it changes the field in MySQL to blank as well. I would like to update the sql but skip over any fields that are blank. I have read a few ways of doing this but they didn't seem logical. I.e. using if statements in the sql string itself. (Having MySQL do the work that should be done in PHP). if($_SERVER['REQUEST_METHOD'] != 'POST') { echo '<form method="post" action=""> ID: <input

Whitespace in a database field is not removed by trim()

点点圈 提交于 2021-02-18 16:58:06
问题 I have some whitespace at the begining of a paragraph in a text field in MySQL. Using trim($var_text_field) in PHP or TRIM(text_field) in MySQL statements does absolutely nothing. What could this whitespace be and how do I remove it by code? If I go into the database and backspace it out, it saves properly. It's just not being removed via the trim() functions. 回答1: function UberTrim($s) { $s = preg_replace('/\xA0/u', ' ', $s); // strips UTF-8 NBSP: "\xC2\xA0" $s = trim($s); return $s; } The

RSA-OAEP SHA-512 Encrypt / Decrypt from Javascriptwebcrypt api to PHP openssl?

痴心易碎 提交于 2021-02-18 16:57:51
问题 I've been rather busy trying to get a secure exchange established between a browserclient, using the webcrypto api and PHP server using openssl. I've broken down things as much as I can. I wrote some javascript to generate a keypair, print out the values private and public, encrypt a simple string and print it out as well. I've copied the values straight to a simple php script. Trying to decode it with the values from the javascipt. Encoding and decoding works properly in the javascript (as

generating a random code in php?

荒凉一梦 提交于 2021-02-18 15:48:48
问题 i know this might seem silly, but i want to generate a random code of 8 characetrs, only numbers or letters using php. i needs this to generate a password for each user that signs up, thanks 回答1: I would rather use md5 to generate passwords But you can use something like this if you want a custom: function createRandomPassword() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $pass = '' ; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars,

linux下安装php扩展pdo_oci和oci8

假装没事ソ 提交于 2021-02-18 15:47:14
此次安装扩展耗费了我大半天的时间,特此记录其中的安装过程,希望这篇教程能够帮助到大家,避免大家在安装的过程中少走弯路。 CentOS服务器上已有相关环境:apache2、 php 7 需要安装:1. oracle 客户端、2.oci8扩展、3.pdo_oci扩展 一、安装Oracle客户端 Oracle客户端可以在oracle官网下载(https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html) 选择这上面这两个安装包,下载到/usr/local/src 然后解压: unzip instantclient-basic-linux.x64-11.2.0.4.0.zip unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip 然后进入到解压后的目录:cd instantclient_11_2/将下面的三个文件作一下连接 ln -s libnnz11.so libnnz.so ln -s libclntsh.so.11.1 libclntsh.so ln -s libocci.so.11.1 libocci.so 然后将解压后的目录移动到 /usr/local/lib目录下,并易名为‘instantclient' mv ./instantclient_11_2

Allow a page to only load in an iframe

谁说胖子不能爱 提交于 2021-02-18 15:12:33
问题 How can I allow my PHP file to only load in an iframe ? For example: Prevent direct access: example.com/Loader.php Allow iframe access: <iframe name="TEST" src="Example.com/Loader.php"></iframe> 回答1: You wouldn't use PHP for that. Try javascript. if(window==window.top) { // not in an iframe } 回答2: Supposing that you have file file1.php that have an iframe within and this iframe point to file2.php code supposed for the file file1.php : <iframe src="file2.php" width="500" height="100"></iframe>

Allow a page to only load in an iframe

孤街浪徒 提交于 2021-02-18 15:06:31
问题 How can I allow my PHP file to only load in an iframe ? For example: Prevent direct access: example.com/Loader.php Allow iframe access: <iframe name="TEST" src="Example.com/Loader.php"></iframe> 回答1: You wouldn't use PHP for that. Try javascript. if(window==window.top) { // not in an iframe } 回答2: Supposing that you have file file1.php that have an iframe within and this iframe point to file2.php code supposed for the file file1.php : <iframe src="file2.php" width="500" height="100"></iframe>

Allow a page to only load in an iframe

走远了吗. 提交于 2021-02-18 15:04:27
问题 How can I allow my PHP file to only load in an iframe ? For example: Prevent direct access: example.com/Loader.php Allow iframe access: <iframe name="TEST" src="Example.com/Loader.php"></iframe> 回答1: You wouldn't use PHP for that. Try javascript. if(window==window.top) { // not in an iframe } 回答2: Supposing that you have file file1.php that have an iframe within and this iframe point to file2.php code supposed for the file file1.php : <iframe src="file2.php" width="500" height="100"></iframe>

趣图:MySQL = 没压岁钱了

爱⌒轻易说出口 提交于 2021-02-18 13:18:10
程序员的成长之路 互联网/程序员/技术/资料共享 关注 阅读本文大概需要 2.8 分钟。 辛丑牛年来了,祝大家新春快乐 MySQL = 没压岁钱了 ↓↓↓ 我是真的没有压岁钱收了 还能收的盆友都收到多少呀?来说说呗 <END> 推荐阅读: 微信昵称加「福」字,最新官方攻略来了! 微信官宣:5000W个微信红包封面,可以秀一波了!! 5T技术资源大放送!包括但不限于:C/C++,Linux,Python,Java,PHP,人工智能,单片机,树莓派,等等。在公众号内回复「 2048 」,即可免费获取!! 微信扫描二维码,关注我的公众号 朕已阅 本文分享自微信公众号 - 程序员的成长之路(cxydczzl)。 如有侵权,请联系 support@oschina.cn 删除。 本文参与“ OSC源创计划 ”,欢迎正在阅读的你也加入,一起分享。 来源: oschina 链接: https://my.oschina.net/u/4581745/blog/4953799

Really Simple Affiliate Program

烈酒焚心 提交于 2021-02-18 12:48:48
问题 I'm pretty new to PHP and MySQL. I'm interested in setting up a very simple affiliate program. It basically needs to be setup so that when someone clicks on the affiliate link it stays with the user until he/she signs up with my website. So for example, I want to create some nice looking webpages that my affiliates could use to advertise my site. The URLs would look something like this (ideally). www.mysite.com/splash1.php?userid=Joe So in this case, my affiliate, Joe, could use www.mysite