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?
- PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in Stack trace:\n#0 [internal function]: img_caption_shortcode()
- UML Sequence diagram auto-numbering in Visual Paradigm
- Multi-line strings in PHP
- Commands out of sync; you can’t run this command now
- How to bind multiple values to a single WPF TextBlock?
- How can I write php code in notepad++?
- Add a Jquery Datepicker to custom field in post edit
- WordPress URL Rewrite not working
- Listing all capabilities in dropdown is returning boolean
- wp_remote_get returns an error for valid URL
- New Plugin Review
- Create custom blocks for bootstrap
- Dynamic page outside WordPress
- jQuery not defined
- dynamic page in WordPress
- Pagination of custom mysql in wordpress
- WordPress wpform plugin submit and get multiple checked value from checkbox [closed]
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- How to retrieve the sender email with wp_mail()?
- WordPress update_post_meta updating with empty meta_value field [closed]
- Can WP plugins access files outside the installation folder?
- Error: Call to a member function get_error_code() on a non-object
- Add class to DIV depending on page loaded
- Adding a user’s ID behind the tag ref link address
- get_the_ID() in the footer returns wrong value
- Syntax issue on rest object’s callback
- Hooks for post saving make a post-new.php to load latest post’s data
- WP_Query multiple post results
- Show field if it has contents on Advanced Custom Fields
- Class for Selected Menu using wp_nav_menu
- Send Array from JS to php file then insert it in wp database through a plugin
- Offer Download Links for Product Images
- Adding image upload in tag section – WordPress plugin development
- WordPress sorting posts by date and title using a dropdown
- How to output the taxonomies that are assigned to each custom post?
- Conditional formatting on data fetched from MYSQL
- opens like sitename.com/URL
- WP_Fatal_Error_Handler OR WP_Error OR try/catch
- How To Tell If a Custom Field Was Made with ACF, Metabox.io, Carbon Fields, Custom Built, etc?
- Plural Forms error in Query Monitor
- Create page in templates for pages or the pages manager?
- Display most popular posts
- wp_nav_menu prints children with parent name
- Does wp_query and query_posts affect website performance? [duplicate]
- Facebook share button only share the_permalink(), without thumbnail, tilte, excerpt, etc
- Woocommerce – Shipping tax class based on cart items not using the highest tax available