PHP script breaking rest of HTML document [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
EDIT: SOLVED - Thanks to the comment by #Adam
I have my index.php page, which all included functionality, until now, has worked.
I've written a small script (pasted below), using the Simple HTML DOM library to scrape an external webpage for an element value. This value is stored as $newprice inside the script.
However, when I place the script anywhere in the code, it a) doesn't run, and b) breaks all HTML/PHP/JS code preceding it.
<?php
include_once('../simple_html_dom.php');
$html = file_get_html('https://www.affordrentacar.co.uk/');
$traverse = $html->find('span.offer-price', 0);
$newprice = $traverse->plaintext;
?>
I've copied this script to one of my other PHP pages and tested echoing out the $newprice variable and that works fine. What could be causing this?

try to display errors :
error_reporting( E_ALL^E_NOTICE );
ini_set('display_errors', 1);
can be problem with connections, your local settings don't work with https

Related

Image Source to Include a PHP Input [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am trying to create an image that changes dependent on the genre grabbed from an icecast server, I am pretty sure I have the base code correct I think I've just incorrectly inputted the PHP variable.
<?php
$stats = $core->radioInfo( "http://http://sc.onlyhabbo.net:8124/status-json.xsl" );
?>
<img src=http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif/>
is the full code. Have I inputted the PHP variable incorrectly
Where are the quotes in your Html?
<img src="http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif"/>
UPDATE EVERYBODY
This is now resolved, I decided to go down the CURL route for this, and at first it didn't work until my host raised our CloudLinux Process Limit. I am unsure what the actual issue with this code was, but the CURL route works fine. Thank you for any answers

PHP - Require not loading page [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
When I try to require a file into my HTML, my web page isn't loading anymore.
The file I want to require is empty so it isn't a scripting error.
require_once('required/dbClass.php');
session_start();
$_SESSION['user'] = 'Test User';
$testing=true;
This code above is working just fine and my page is loading as it is supposed to.
But when I try the next code, my page isn't loading anymore
require 'config.php';
require_once('required/dbClass.php');
session_start();
$_SESSION['user'] = 'Test User';
$testing=true;
I don't know what's wrong, I've tried getting an error with error_reporting(E_ALL); but that doesn't display anything.
Did I do something wrong?
Config.php was in a different directory

Error message on my New Blog Post page which I cannot work out [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am in the process of incorporating a Blog Posts section in my website.
However I am receiving an error message on the New Post page which I am unsure of the cause of.
Any help would be greatly appreciated.
I have received the above two Warning Error messages above.
I have also covered parts of the directory because they show names.
This is what the code looks like at the line specified.
<?php
include "cms/posts.php";
?>
Line 155 is the middle line of code.
If there is any more information which is required please let me know.
Thanks!
Reply to comment 1: Hi, I'm not sure why it is trying to open that file as I've never seen or heard of the file "usr/lib/php:/usr/local/lib/php".
Use this code and make sure the file exists:
<?php
include __DIR__ . "/cms/posts.php"; // PHP >= 5.3
include dirname(__FILE__) . "/cms/posts.php"; // PHP < 5.3
?>

Login Functionality not working [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
So I took the login script demonstrated in this tutorial: http://www.9lessons.info/2014/07/ajax-php-login-page.html
However, when I try to run it, I keep getting an incorrect login information error. The database, the table, all of that is correct. I'll look at it again, but I'm sure that's fine.
I haven't changed anything besides the name of the table, and my db info.
Why does the PHP dissapear? Solved
the php at the top of index.php goes away when I look at the source code on a browser
This is a good thing :)
PHP code is processed server-side. The result of that code (which is usually HTML) is then sent to the browser. PHP code itself should never be sent to the browser for a couple of reasons:
It would expose your server-side code to users, which could help them do malicious things.
The browser wouldn't know what to do with it.

Using a PHP location header [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I am trying to use a variable in a PHP location header, but I can't seem to get it to work. What am I doing wrong?
My Code:
$id= 14;
header('Location:collection.php?idollection=$id);
Just by assumptions.. You want to re-direct with a $_GET value based on a variable source?
How about:
$id = 1;
header("Location: collection.php?idollection=".$id);
exit;
Use of the exit will make sure the page will not continue executing after header has been called. Furthermore, make sure that there is no whitespaces or any output prior to the header being called.
Make sure to use double quotes. You used single quotes and actually only used one. Try this:
header("location:collection.php?idcollection=$id");

Categories