[Solved] There’s no syntax error but php returns error [closed]

Introduction

When coding in PHP, it can be frustrating when you have written a script and there are no syntax errors, but the script still returns an error. This can be a difficult problem to solve, as it can be difficult to identify the source of the error. This article will provide an overview of the possible causes of this issue and provide some tips on how to troubleshoot and resolve it.

Solution

The most likely cause of this issue is that the code is trying to access a resource that does not exist or is not accessible. This could be a file, database, or other resource. Check the code to make sure that the resource is valid and accessible. If the resource is valid, then check the permissions to make sure that the code has the necessary access to the resource.


Without your actual code file, the following answer is shooting in the dark;

.. Getting onto it, however, it would appear that you copied this code from an external source, such as something like jsfiddle or some blog. The point here, is that sometimes when such copies are made, there are hidden characters in the text of that copy.

The presence of this hidden character usually always breaks any code on that line, especially in php.

.. And here is my recommendation for you. Delete the entire line 13. Re-type it out from scratch. If your problem still persists, that is not the issue.

3

solved There’s no syntax error but php returns error [closed]


If you’re getting an error from PHP but there’s no syntax error, it can be difficult to figure out what’s causing the problem. Fortunately, there are a few steps you can take to help you troubleshoot the issue and get your code running smoothly again.

The first step is to check your code for any typos or other errors. Even if you don’t see any syntax errors, it’s possible that there are some typos or other mistakes that are causing the problem. Make sure to double-check your code and look for any potential issues.

Next, you should check your server’s error logs. These logs can provide valuable information about what’s causing the error. If you’re using a shared hosting provider, you may need to contact their support team to get access to the logs. Once you have access to the logs, you can look for any errors that are related to your code.

Finally, you should check your code for any potential conflicts with other scripts or plugins. If you’re using a plugin or other script, make sure that it’s compatible with your version of PHP. If there are any conflicts, you may need to update the plugin or script to a newer version.

By following these steps, you should be able to identify and fix any issues that are causing the error in your code. Once you’ve identified and fixed the issue, you should be able to get your code running smoothly again.