FAQ Database Discussion Community


update MySQL row based on values passed on URL using PHP

php,html,mysql,php-5.3
I am trying to update a Mysql row based on value passed to url of a page. But i am getting an error Notice: Undefined index: id_store in C:\xampp\htdocs\store\php\update.php on line 29 when i submit the button in html form. Here is my code: <?php require 'db.php'; if(isset($_GET['id_store'])){ $id_store=$_GET['id_store']; $sql...

How do you trigger session garbage collection in PHP < 5.4?

php,session,php-5.3
I need to force session garbage collection to trigger in PHP, and I'm using version 5.3.3. I see in PHP 5.4, you can call: SessionHandler::gc() What is the best method to get the same result given the PHP version I am using?...

Export an array in .csv using

php,csv,php-5.3,export-to-csv,php-5.4
I have a problem with my .csv. So I tried to generate a .csv from an array using php. In the view I have : <form id="form_logistique" action="myroute" method="post"> <div class="form-group " style="float: left;"> <label class="control-label" for="" style="display: inline-block; padding-right: 20px;">Date min</label> <input type="text" id="date_min" name="date_min.name" value="date_min" placeholder="Date min" class="form-control...

ltrim function doesn't work as expected ? php

php,php-5.3,php-5.4,php-5.5
I am using ltrim function. I run this code : echo ltrim("looooooooooooooooooooooooongWord","long"); i expect to get this word : looooooooooooooooooooooooongWord but it prints Word. what's the problem ? Edit: I thought it remove the word long, but it appears it remove the l,o,n,g characters ! ...

How to always run php in console interactively way not to exit?

php-5.3
I am in debian7.8+php5.3 . [email protected]:/home/debian# php -a Interactive mode enabled <?php echo "hello"; ?> No reaction when to click enter ,to click ctrl+D can get the output: hello But it will exit from php Interactive mode into debian console. [email protected]:/home/debian# How to always run php in console interactively way...

How to show a div depending on the numbers of games

javascript,php,jquery,jquery-ui,php-5.3
I have a question and I can't resolve it. Can you help me please? So my php code : $aTicketsGames = array(134, 137, 165, 136, 177, 181, 190); $b_isRapidGame = false; if(in_array($i_jeu, $aTicketsGames)){ $b_isRapidGame = true; } In .js after click on the button I do : if(obj.google_analytics.is_rapid_game == true){...

Change status in ajax on selectbox

javascript,php,jquery,ajax,php-5.3
I have a question, So ,this code work fine only for the first select box and I dont understand why. For first select box update on database work fine but If I tried to change the statut for the second select box the status remain unchanged. Can you help me?...

How to shield a javascript string in php

javascript,php,jquery,php-5.3
I have a problem with my javascript string in php. So I tried to add a string to a variable in switch but I get error : $blocPub = '<script type="text/javascript"> var rdads=new String(Math.random()).substring (2, 11); document.write('<sc'+'ript type="text/javascript" src="http://test.com?sdsds?bhhj'+rdads+'dsdsdsdsds"></sc'+'ript>'); </script>'; The error is in document.write. Exist a method to ecranate...

PHP days difference calculation error

php,date,php-5.3
I have a PHP code to calculate the number of days between two specific dates. The difference should not count Sundays and Saturdays. Also, I have an array of dates, which includes holidays, which also need to be skipped. I gave the starting date as 01-05-2015 and ending date as...

Can't get code to work in PHP 5.5.9 [closed]

php,forms,validation,php-5.3,php-5.5
This code works fine in PHP 5.3, but I can't figure out what to do to make it working in PHP 5.5.9 on a LAMP server. I have tried searching around, but haven't found any solution. Any ideas of to fix it? So; the users sees the from correctly, without...

D2l first time signature is matched but next time, it displays authenticated signature?

php,api,zend-framework2,php-5.3,desire2learn
I am trying to integrate the Desire2Learn (D2L) sandbox with my app. I created an API for a D2L request. The first time, the signature is matched, but after logging out of D2L and trying once again, it then displays an authenticated signature. But when I quit and restart my...

Select with datetime from database

php,mysql,sql,php-5.3
I have a problem with my select : I have a form with 2 text boxes : date_min and date_max. This dates come in controller : 2015-05-15 Now in database my dates : c_win like this : 2015-08-20 21:20:20 In the query I do : if ($date_min != '' &&...

How to do replace multiple times ? php

php,string,replace,str-replace,php-5.3
I want to replace word1 with word2 and word2 with word1 for this string : word1 word2 here is what i want to do : 1.replace word1 with word2 => I get : word2 word2 2.replace word2 with word1 => I should get word2 word1 . but I get this...

Store and Retrieve JPG in Mysql using PHP

php,mysql,blob,php-5.3
I am trying to store jpg images into MySQL database , The insertion works but I am unable to display the results. here is MySQL table definition: drop table if exists product_image; create table product_image( id_img int not null primary key auto_increment, name varchar(512), img LONGBLOB NOT NULL, id_product int...

Set and use variable outside of function in PHP

php,wordpress,php-5.3,gravity-forms-plugin
I have a function that passes sales information to a third-party service via a SOAP API, and returns an array with the results. I need to take a specific key from that array, set is as a variable or somehow use it outside of that function in other code. I'm...

Display Image on nth iteration php

php,php-5.3
I am developing an app where I want to show 1 image at a time every 5th tweet, I have 18 images in total. Once all images display I want to reset to image 1. Tweets saving is done, but problem is displaying image, Suppose I have 122 tweets on...

How to get values separated with comma from database using PHP

php,database,php-5.3,php-5.2
I have four files named comma separated in one field in database like this file1,file2,file3,file4. It may change depending on files uploading. User can upload maximum 4 files, minimum one file. But I was not able to get it. I used explode but it's taking too long. I am using...

Populate a textbox based on selectbox ajax php mysql

php,jquery,mysql,ajax,php-5.3
I have a question. So I tried to populate the value of a textbox based on selectbox. My HTML: <form id="form_gift" action="myAction" method="post"> <div class="form-group"> <label for="">Gift</label> <select id="statusSelect" name="{{ form_gift.gift.name }}" class="form-control" onChange="getPrix()"> {% for key,category in form_gift.gift.choices %} <option value="{{ key }}"> {{ category }} </option> {% endfor...

Converting Block of code Into Function

php,mysql,codeigniter,php-5.3
I have those few lines of code: $array_to_filter // this array is unfiltered array_filter($array_to_filter, function($v){return array_filter($v) == array();}); $c = function($v){ return array_filter($v) != array(); }; $filtered_array = array_filter($airbnb, $c); print_r($filtered_array); // this is filtered array! Now I will be using this piece of code alot in my code and...

Update session in symfony2 for shoppingg cart

php,symfony2,symfony-2.1,php-5.3,symfony-2.3
I have the following code : public function addAction(Request $request){ //Get submited data // Get Value from session $sessionVal = $this->get('session')->get('aBasket'); // Append value to retrieved array. $aBasket = $request->request->all(); if(count($sessionVal) > 0) { foreach ($sessionVal as $key=>$value) { if($aBasket['product_id'] == $sessionVal[$key]['product_id']) { $sessionVal[$key]['product_quantity'] = $sessionVal[$key]['product_quantity'] + $aBasket['product_quantity'];...

Modifying new code to support PHP5.3

php,wordpress,php-5.3,php-5.5
I'm using Roots.io wordpress starter theme. It's coded for PHP 5.5 but the server I'm posting the site on is running PHP 5.3 I need to change this code to be supported by the PHP on the server, but don't know how. function asset_path($filename) { $dist_path = get_template_directory_uri() . DIST_DIR;...

what is wrong in this statement php doctrine

php,doctrine2,doctrine,php-5.3
I'm trying make a validation in my db using doctrine where I just need to make this statement in SQL like, Select * from usuarios where usuario_email = someEmail After I click the submit button from my form, I instantiate the class UsuarioDao, from a script that includes bootstrap.php (from...

Logical Operators and Precedence

php,logic,php-5.3,logical-operators
So I just did some random test and understand the fundamentals of Precedence and the || and or operators but I'm having trouble understanding why $f changes: $f = 0 || 1; if ($f === 1){ echo "TRUE - $f"; }else{ echo "FALSE - $f"; } $f = 0 or...