You are not inside instance of class to use $this. Try this, it will work
require_once 'models/Request.php'; $req = new Request; if(isset($_POST['submit'])){ $data = [ 'reqBy' => $_POST['reqBy'], 'off' => $_POST['off'], 'prob' => $_POST['prob'] ]; echo "<pre>"; print_r($data); echo "</pre>"; if($req->addRequest($data)){ //This is the line where it points the error echo 'Sucess'; }else{ echo 'Something'; } } ?>
Related Posts:
- PHP – exit or return which is better?
- PHP Fatal error: Using $this when not in object context
- Where to get php_mcrypt.dll for PHP 7.2?
- When do I use the PHP constant “PHP_EOL”?
- How to use PHP’s password_hash to hash and verify passwords
- PHP password_hash(), password_verify()
- PHP &$string – What does this mean?
- PHP Notice: Undefined offset: 1 with array when reading data
- PHP – Failed to open stream : No such file or directory
- Weird PHP error: ‘Can’t use function return value in write context’
- Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes)
- Simplest way to profile a PHP script
- Popup window in PHP?
- Subtract 1 day with PHP
- Warning: session_start(): Cannot send session cookie – headers already sent by (output started at [duplicate]
- PHP – Indirect modification of overloaded property
- “Maximum function nesting level of ‘100’ reached” after adding a new filter
- apache cpu over 70% on localhost
- Fatal error: Call to undefined method WP_Error::get_item_quantity()
- Fatal Error relating to sessions.php
- wp_ob_end_flush_all and wp_suspend_cache_addition()
- Why “Call to a member function on a non-object” in plugin only?
- fatal error call to undefined function get_header in index.php on line 1
- Getting error when using wp_insert_post()
- Fatal Errors on pluggable.php
- Syntax error in a shortcode function
- Fatal errors to undefined function in theme 404.php file [closed]
- PHP Helper Class to create shortcodes
- wordpress admin part is not accesbile after server shifting
- Error while loading wordpress site “Fatal error: Uncaught Error: Call to undefined function twentytwentyone_the_html_classes() in /home
- Replace old theme that understand old css (vcex_icon_box css_animation)
- Connecting to upstream failed
- Fatal error: wp-settings.php on line 199
- Reduce Stock Based on Custom Variation Field Rather than Attribute (Working Script)
- Fatal Error cannot log into wordpress and website disappeared
- pages disable after wordpress update
- Importing demo data in Multisite
- WordPress error on my website
- Changed URl in General Settings now WordPress site doesnt work
- Plugin Breaking WordPress Login
- WordPress won’t display errors at all
- WP white screen of death after duping a site that works fine on same server
- Catchable fatal error in appcloud free theme by Tokokoo
- How to fix ‘Call to undefined function do_settings()’ error?
- is_plugin_active() not defined on active plugin, in the thumbnails.php file
- White Screen When Includding A Folder With PHP Files
- Front-end major break after upgrade PHP 8.0 [closed]
- kali php problem [closed]
- Divi – add title to mobile menu button
- Why is the response on localhost so slow?
- How to fix Fatal error: Cannot redeclare get_cli_args() in class-wp-importer.php
- WordPress critical error after trying to update to 6.2 – Fatal error: Allowed memory size of 268435456 bytes exhausted
- Error message not appearing in error email or in the error log
- Why PHP Parse unmachet after update to PHP8?
- “Object-cache.php” disables wp_cron and even disables my entire site, and keeps reappearing by itself again after I delete it
- PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in Stack trace:\n#0 [internal function]: img_caption_shortcode()
- Override a function defined in wp-includes/comment-template.php
- Get the URL of the page from which an ajax request has been launched within ajax callback
- Edit the_category (); for a hierarchical display
- Wrapping a Sidebar within
- JSON REST API WordPress only showing first 10 categories
- How do I modify the custom footer text and get theme version number to show in wordpress admin?
- Category title output before opening title tag
- unable to use ‘new WP_Query’ in AJAX call
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- User register hook is not working in woocomerce register form
- My WordPress site when down after installing a plugin and now all I get is a simple white screen [closed]
- Access a particular field in an array
- Notice: Uninitialized string offset: 0 in social sharing mu-plugin
- Password minimum length in personal subscription [closed]
- Show meta box only for default page template
- Illegal string offset in PHP function
- echo something inside a shortcode
- Hide a div when tags doesnt exist [duplicate]
- admin-ajax Firing Error 400 When Logged In
- WordPress template page name displayed on screen
- Need to put a script above tag in header.php – WP 5.7.1
- Display related posts without a plugin
- How to add API security keys into JS of wordpress securely
- How to use a custom hook
- Search WordPress using static html page
- How to check if the current page is at a specified path in the URL?
- How to use html inside a functions.php code?
- Multiple meta_key in one global $wpdb;
- Nested “do” and “add” Actions is possible?
- Can’t access site after making changes to the functions.php [closed]
- Hide HTML element (by class or ID) with PHP
- Deprecated: Function create_function() is deprecated [closed]
- Featured or last post with a different WordPress style without plugin
- “Call to a member function have_posts() on array” error on have_posts();
- Replace Woocommerce “add to cart” to be “Download” button [closed]
- displaying content that includes shortcodes within an echo
- JS value to PHP variable to change div background color with PHP If else statement
- wp_force_remove_style’ not found
- Update a buggy installation
- Error – ‘create_function is deprecated’ [closed]
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- Why is my custom post type not being activated on plug-in activation?
- How to get post permalink url without a href
- How to fix “Object of class WP_Term could not be converted to string”?