Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PHP Warning: Use of undefined constant Type

Explorer ,
Jan 09, 2023 Jan 09, 2023

Hi
I have run to check error logs on my coding. 
However, it appears 

PHP Warning:  Use of undefined constant Type 

 

May i know does it mean?
Since the files only works in localhost, when i tried in server, error appears.

1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 10, 2023 Jan 10, 2023

What version of php are you running on your local server and what version are you running on the remote server?

 

I see in the select query you are using a lower case p for your product table name whereas your database table l think uses a capital P for Products  Try to be consistant otherwise any minor deviation could cause issues. Think about if youre getting the id from the url parameter. If you have problems hard code an id in the query string as a test or echo the id out to see if it contains

...
Translate
Explorer ,
Jan 09, 2023 Jan 09, 2023
PHP Warning:  Use of undefined constant Type - assumed 'Type' (this will throw an Error in a future version of PHP) 
PHP Warning:  Use of undefined constant Type - a
PHP Warning:  Use of undefined constant Typename - assumed 'Typename' 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2023 Jan 09, 2023

See https://stackoverflow.com/questions/2941169/what-does-the-php-error-message-notice-use-of-undefined-.... or use Bing to search.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2023 Jan 09, 2023

i have a problem on different display between in localhost and server.
Screen Shot 2023-01-09 at 19.54.36.pngexpand image
The coding seem has no error appears, the website run normal in localhost.

Screen Shot 2023-01-09 at 19.55.15.pngexpand image
But when i uploaded the files in server, i dont understand why the page cannot run as normal in localhost.

Screen Shot 2023-01-09 at 19.56.48.pngexpand image


 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2023 Jan 09, 2023

Please supply the URL to the site.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2023 Jan 09, 2023

japanfavorite.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2023 Jan 09, 2023

the problem is, when i try to put the unique product details without PHP coding, the page works normal.
so probably there are so mistakes in php coding. However, i have no idea where i did wrong

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2023 Jan 09, 2023

Screen Shot 2023-01-09 at 20.42.26.pngexpand image

Here is the screenshot of the database.
the product detail is chosen from here.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 09, 2023 Jan 09, 2023

The code is probably looking for a string ' ' Try wrapping [id] in a string in your $_GET method ['id']

 

$id = $_GET['id']

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 10, 2023 Jan 10, 2023

Thanks for your suggestion.
However, the coding only works in localhost. When i upload the files to the server, then the content cannot be shown.

HiuChing26169588pka2_0-1673350922523.pngexpand image


I have asked the server side, is there any error mistake. However, they said they cannot find out any problem from server.
So im wondering is there any differnt code needed when we use under server.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 10, 2023 Jan 10, 2023

What version of php are you running on your local server and what version are you running on the remote server?

 

I see in the select query you are using a lower case p for your product table name whereas your database table l think uses a capital P for Products  Try to be consistant otherwise any minor deviation could cause issues. Think about if youre getting the id from the url parameter. If you have problems hard code an id in the query string as a test or echo the id out to see if it contains anything.

 

Also l would wrap ALL of your database column names in string tags - $row['Pic'] , $row['Pic1'] etc  - php is not forgiving, anything missing and the page will usually die.

 

Check if the version of php on the remote server is compatible with the short php echo statement that your code uses.

 

The page is being parsed as it outputs the skeleton html code structure so something within the php is not correct or your remote server is not set up correctly to output php.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 10, 2023 Jan 10, 2023
LATEST

Something in that list of suggestions seems to be correct, care to share what it was?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines