Skip to content

Tag: php

Call a PHP variable to another PHP file

I’m trying to pass a variable from a dbh.inc.php to index.php using include_once, But it gives me an error in $con at index.php that it is not defined dbh.inc.php: indux.php: Answer Usually you can access variables from one file to another by including file like: vars.php test.php First of all check it …

AJAX POST submit to PHP – empty POST on arrival at PHP?

I am submitting a POST request via AJAX to my PHP script. The browser tools Network tab shows the POST data has values, on arrival at my PHP script the $_POST value is true, isset() verification is valid, and there should be no problem to assign the $_POST[‘input’] values to my $variables. Yet, my…

separate resulting values from a foreach with commas

I am saving values with add_user_meta within the same meta key. What I need is to separate them with commas when getting them with foreach so I can send them by wp_mail. I need something like this: but when obtaining them directly, it returns them all together and glued. some help? Result: I tried some option…

Simple regex on string

I’m working on a simple mention system and in my PHP script and I need to extract client:6 from the larger text where one or more @mention like @[John Doe (#6)](client:6) will be present. Ex. This is my text how do you like it @John and do you have any thoughts @Jane In php the string will look like. an…

Code Executing on Page Load instead of OnClick

I have a code that gets executed on page load twice, despite adding the code to the ‘Click’ command. I have placed the code ‘alert(“Testing”);’ within the portion of the code pertaining to ‘click(function(evt)’ – grateful if someone can advise if I misunderstood the f…

Accessing php variable from within function scope

I have this code in a codeigniter controller that’s the beginnings of a pagination/sorting feature for a table in the view. I’m passing order_by as a query parameter and then this is part of the controller action: The problem is…I keep getting the error Undefined variable: order_by. Since I&…

Undefined Index Array

I just learning laravel and got this error calling array on route class using foreach but i got error (undefined index) Answer You’re using the wrong variable within the foreach scope. use $post[“title”] instead of $posts[“title”]