Questions tagged [php]

281475 questions
1

votes
1

answer
826

Views

How does loop.parent actually work?

I have a for loop nested in another for loop in my template, and need to grab the index of the outer loop for a generated value in my inner loop. I thought loop.parent would to the trick, but I'm getting an Array to string conversion exception. Am I misreading what little the twig docs are descri...
1

votes
6

answer
91

Views

pass files through php with rename

I have 1600 images, each 256px. These images have been sliced in photoshop from an image that is 10240px x 10240px in to the tiles. Problem is, photoshop has named them image_0001.png, image_0002.png... I would like to rename these in to a usable file name such as image_x_y.png x being tile number...
user1949366
2

votes
3

answer
40

Views

Convert A Date in MySQL

I have a value set in my database as 04/01/2019. I need to construct a script in either php or MySQL that goes through each line in the table that has this value, and convert the string to 2019-04-01. Dates will vary, so 02/01/2019 has to be converted to 2019-02-01, etc. I have been reading for hou...
BCode18
0

votes
1

answer
21

Views

send ajax request with no data, PHP check isset

I have this following code that works at the moment. What I want is to remove the url and process the ajax request on the same page. Since I am not sending any data, how can I have php check when my ajax function is ready to send a request to the database? I'm using jquery mousedown to hold on to...
Joe
0

votes
3

answer
17

Views

Php Static Class and Normal Class

$export = db::get($data); foreach ($export as $user) { // } echo "Totol User: " . $export->count(); Hello, I have a problem. I'm pulling array() with db::get($data). Then I want to show the total number of records with a function such as $export->count(). Is there an example suitable for this struct...
Huseyin Yilmaz
-4

votes
0

answer
22

Views

Google Authentication or My Own Login System? [on hold]

I haven’t really seen a question like this asked, but correct me if I’m wrong. I’m trying to implement a login system to my website so users can log in. My main goal is when users login, they have different pages available to them in the websites navbar (For example, staff members will have...
AbSaintDane
0

votes
2

answer
16

Views

php edit and save word and excel files

I am trying to build a module which will manage following features: Upload MS Word or MS Excel file View and Edit the Uploaded MS Word or MS Excel file Save and Re-Upload the same file with latest changes I want to know is this possible using PHP? Is there any plugin that I can use to achieve these...
StormTrooper
-4

votes
0

answer
21

Views

Learning process - website tracking hours for multiple users [on hold]

Im kinda new to it all - css, html, sql and php. But Im learning, and I`m dedicated for now. I have put up a website for testing and learning, with username/password log in, and where username is assigned for session when logged in. When you log in to mainpage, you can put in the date and hours work...
Per Askeladden
0

votes
1

answer
15

Views

How do I subscribe/publish messages to an mqtt over websockets broker in PHP?

I'm looking for a way to publish/subscribe messages/channels to a RabbitMQ mqtt over websockets broker from php, and I can't find any code, or any good libraries out there. I found https://github.com/bluerhinos/phpMQTT but it looks like that's for MQTT, and not for MQTT-over-websockets, plus it look...
SudoPlz
-3

votes
0

answer
17

Views

Stripe chargeback prevention [on hold]

We have implemented all checks (Address, CVC, Zip etc.), despite that we are bing hit with chargebacks. We also have radar in place and we even manually check customers, payments and activities. We offer digital services. Win rate on stripe is 0%. Compare that to paypal we have 100% win rate. Stripe...
Sunny
0

votes
0

answer
16

Views

PHP setcookie function not honoring httponly or secure arguments

I have no idea why this is happening or how to fix it. I can run this: setcookie('cookie_name', 1, time()+86400*365*2, "/", ".domain.com", false, false); And I get this in the response headers when I load the script: cookie_name=1; expires=Fri, 19-Feb-2021 19:08:57 GMT; Max-Age=63072000; path=/; dom...
SublymeRick
0

votes
0

answer
3

Views

use “when” in nested yii2 EachValidator

is there a way to use the when attribute in nested EachValidator? Here is my rule but it does not work: [['list'], 'each', 'rule' => ['required', 'when' => function ($model) {return false;}, 'whenClient' => "function (attribute, value) {return false;}"]], I want to test if I can avoid required valid...
EvilKarter
0

votes
0

answer
6

Views

Displaying SQL row in PHP-based webpage based on selection from drop-down menu

Hi I'm trying to create a web-page that selects and displays the SQL row connected to the selected name from a drop-down menu. I've gotten everything to work except actually displaying the row when selected by the drop-down, here is some code I've cobbled together from various sources including Stac...
Dakota Sitton
0

votes
0

answer
5

Views

PHP Site and NodeJS Websocket Application behind the same Nginx server/config

I have a development server that is running Nginx and serving a PHP website. Below is the working nginx config. cat /etc/nginx/nginx.conf user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; # multi_accept on; } http {...
Andrew Odendaal
0

votes
0

answer
2

Views

Accessing Wrapping Wordpress Shortcode Content From Another Shortcode

I have two plugins. A core plugin used provide store information and an inventory plugin that retrieve inventory from any given store within a database. The core plugin has a shortcode called store, it can be passed in a specific store's id or if not passed in within the shortcode it uses a default...
Sebastian Flores
1

votes
0

answer
9

Views

How do I add a custom field to products in specific category

I'm trying to add a custom field to the single product page for products in a specific category. I'm having problems with the conditional logic tho. This is what I've got so far: function cfwc_create_custom_field() { global $product; $terms = get_the_terms( $product->get_id(), 'product_cat' ); if (i...
Paudun
1

votes
1

answer
317

Views

Attempting to learn mysqli prepared statements; what am I doing wrong?

Here's the error I'm getting... Failed to prepare statement: (1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?.Pages WHERE slug='?'' at line 1 And here's my code... require_once("../database/config.php"); $...
Samuel Stiles
1

votes
1

answer
1.4k

Views

Rscript does not work when invoked in PHP but does from Command Prompt

I am trying to execute an R script from my PHP page using the exec function. I have set the environment variables in Windows and Rscript works fine on the command prompt. However on the PHP page it says, " 'Rscript' is not recognized as an internal or external command, operable program or batch file...
user1523478
1

votes
2

answer
2.4k

Views

PHP DomDocument appendChild to end of root

I've got an XML formatted like so foo 1 bar 2 And I've created a new element with info from a form. When I do $dom->appendChild($newthing), it's appended to the end of the document, after . Like this foo 1 bar 2 bar 2 Obviously I want my new element to be a child of the root element, not after it....
ejfrancis
1

votes
3

answer
1.6k

Views

jquery click to hide and show another button

I have two buttons set as hidden : I have a jquery where I check some conditions fetched from the database. Either one of the button will be shown and that depends on if the condition is 1 or 0..That means when I click any of the button it must get hidden and the other one must shown up..? But it's...
user2605321
1

votes
2

answer
1.6k

Views

Alternative to enum in PHP

Is there an alternative to using enums in PHP? I only ask because in C# I have methods that return an emum, but in PHP nothing similar exists. Here are some possible return types from a fictitious method: function login() { // logged in // log in failed verify account // log in failed account suspen...
James Jeffery
1

votes
1

answer
3k

Views

PDO: How can I run multiple prepared statements in a transaction?

Using PDO, I am trying to run two prepared statements within a transaction. I only want the second prepared statement to run if the first one executes successfully and vice versa. //Open Database Connection $dbh = new PDO("mysql:host=$host;dbname=$dbname", $user, $pwd); //Set Error Handling $dbh->se...
zeckdude
1

votes
1

answer
7.3k

Views

php hash() with sha512 showing different results for same value [closed]

Enter Current Password this is my script. when i try this:
RatDon
1

votes
1

answer
189

Views

FlaggedRevs requires running …/mediawiki/maintenance/update.php from command line

What is required to run it? Because if it is run from browser address line it gives a message This script must be run from the command line What does it mean? After I do this stuff in windows command line: C:Program Files>cd C:\inetpub\wwwroot\mediawiki\maintenance C:\inetpub\wwwroot\mediawiki\main...
d689p
1

votes
1

answer
158

Views

Select date from another table

I really need your help. Please help me out to get this to work. I have these two tables, the relation between them is the user_id. I accomplished to select who I follow and to display their images into my wall. However, I have this strange issue: the photos are sorted by DESC as i want, but they ar...
user2660611
1

votes
1

answer
40

Views

Which is the prime module for creating a form in drupal?

What is the best module to use for Drupal? I just go through Web forms and also Entity forms modules. As with everything in Drupal, there are Pros and Cons to using these modules also, so I was just wondering when to use these modules? Anybody have any better suggestions?
Jetson John
1

votes
1

answer
900

Views

Using AWS services to create subdomains on the fly to host a site on S3

INFO: I am working on an app built in php which facilitates users to create HTML templates and publish them on web.As the templates would be static I thought of using amazon S3 for storing them as it can host static websites and has good infrastructure overall for the application.br/> QUERY: I am fa...
KillABug
1

votes
2

answer
220

Views

php calling function dynamically with @ symbol

I want to call the mysql_connect function dynamically with the @ symbol, depending on if the user is an admin or not (to supress error messages): //User is an admin: mysql_connect(...) //User is not an admin: @mysql_connect(...) I have tried this: //MODE_ADMIN is true or false private static func...
Ilyssis
1

votes
3

answer
654

Views

I have hash my password, but when I login, it does not recognize

Previously i have hash my password with this $password = hash('sha256' , $salt.$password_arr[$i]); and in config.php , i have this code to salt the password $salt = '[email protected]'; So my sql database display the hash code when i register a new pass into it, im happy with t...
nickee89
1

votes
1

answer
72

Views

my php is returning null when values are passed to it

my php is returning null when values are passed to it i checked it with chrome's plugin POSTMAN... i am unable to figure out the problem :\ This is my code i am trying to update the database by sending values from my android code(which is okay):-
Harekam Singh
1

votes
1

answer
1.6k

Views

how to specify redirection ZF2 constructor?

I am working on login module in my current project. For accessing profile page user must logged in. For that i am checking login status against session in constructor. if user not logged in page should redirect to log in page. following is psedo code. use Zend\Mvc\Controller\AbstractActionController...
g v s vinayak
1

votes
2

answer
1.2k

Views

Query cache in yii

If I want to use Query Caching as in the tutorial here : Yii Query Caching Guide whether I should have a update_time field in every table? $dependency = new CDbCacheDependency('SELECT MAX(update_time) FROM tbl_post'); Is the field must exist to be able to use the query cache?
Bertho Joris
1

votes
3

answer
1.9k

Views

Regex to replace spaces and brackets with underscore

I have some strings in the following formats: this is a string This is a string This is a (string) This is a string and i want a regex convert it to the following: this_is_a_string with no leading I have the following using preg_replace which is getting me almost all of the way: preg_replace('/[^A-...
Marty Wallace
1

votes
3

answer
3.4k

Views

Is my Bcrypt encryption safe enough?

I am working on a project which needs a very advanced security system when it comes to saving passwords etc. So my question is, is this way to save passwords safe enough? This is the way I programmed: When a user registers, a salt will be created out of the following details: An unique user ID (prim...
Jan Willem
1

votes
1

answer
61

Views

DB pulling Function with PHP

I am very new to programming with PHP and am working on a fun little game to help myself learn. I got some code help from others on pulling a character's stats from the DB but am having trouble getting it to work. I just get "server error" when I try to run it right now. The Database information is...
Mike Kellogg
1

votes
3

answer
192

Views

PHP Array issue when trying to auto select dropdown

Note: $i is set earlier in the code and there are 25 drop down boxes, the array shows the first 5 have values, so I need to set those drop downs to selected and show the relevant value. I have an array that contains the following: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => [6] => [7...
Homer_J
1

votes
1

answer
1.4k

Views

simplexml_load_string not parsing my XML string. Charset issue?

I'm using the following PHP code to read XML data from NOAA's tide reporting station API: $rawxml = file_get_contents( "http://opendap.co-ops.nos.noaa.gov/axis/webservices/activestations/" ."response.jsp?v=2&format=xml&Submit=Submit" ); $rawxml = utf8_encode($rawxml); $ob = simplexml_load_string($ra...
Chris Rae
1

votes
7

answer
8.2k

Views

Charset UTF-8 not working on <?php contact form

I am trying to make utf-8 work when receives the email. When the form is filled up the characters shows as codes if is ç/Ç shows &$ Ex: Avançado shows Avan&$ado I Tried using the " header('Content-Type: text/html;charset=UTF-8'); " but still not working please help me thank you so much... This is...
Patrick Sterza
1

votes
1

answer
2.6k

Views

Doctrine Mapping Exception in Zend Framework 2's Project while using hydrator

I am trying to implement doctrine hydrator in my zend 2 project. I am using doctrine's official documentation I am getting two warning and one error. Following is the warning at top of page. Warning: Missing argument 2 for DoctrineModule\Stdlib\Hydrator\DoctrineObject::__construct(), called in /pat...
regeint
1

votes
3

answer
2.7k

Views

For Loop Inside Switch Statement in PHP

I have certain ranges saved in array with price at index [3] and discount type at index [4] (%, fixed). Anyone buying within those ranges should get available discount. My Current Problem is range of an array could be of any count, for example here in variable $a, there is 4 nested array, but in ce...
Johny Bravo

View additional questions