php echo is not working in html - php

I am having some trouble getting a php value into a bootstrap button which is in html
This is my code:
<html>
<head>
<title>Samples</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>
<body>
<?php echo "Samples"; ?> Stuff
</body>
</html>
So instead of the button saying "Samples Stuff" - the button just simple says "Stuff". It is important that the button takes a php value as eventually I will be putting a db value in the button - but I can't even get the basics working
Why is it not working?

Are you running a locally hosted server. If not, you probably should install XAMPP. Ensure the file has a .php extension, I don't see any other reason why a simple echo would not work.

Make sure that the file extension ends with .php. Also make sure that your php/apache is configured correctly.
Try and look at your error logs and see if anything is there

Firstly ensure that your file extension is .php secondly make sure you run .php files on a php enabled webserver. Simply viewing php files on your browser will not actually compile the php. This is done in the back-end on your server.

Related

Forms in PHP not displaying

Using this exact code I've been able to create text fields in HTML, but when I convert (rename) the file to PHP the field dissapears. Why does this happen and how do I stop it?
Code:
<!DOCTYPE html>
<html>
<head>
<title>StatsCalc V1</title>
<link rel="stylesheet" type="text/css" href="Buttons.css">
<link rel="icon" type="image/png" href="favicon.ico">
<link href='http://fonts.googleapis.com/css?family=Raleway:500' rel='stylesheet' type='text/css'>
</head>
<body>
<form>
<input type="text" class="writies" name="writy1" />
</form>
</body>
</html>
make a new file index.php write in it the bellow code and if it shows something you have php installed if not you don't have.
To have php installed you either install manually apache + php or you download a ready made application like xampp or ampps or easyphp which will provide you with everything you need to begin learning php.
tutorial for install of course you can choose any other.
<?php
phpinfo();

Symfony "Welcome page" seems incomplete

I thought I have Symfony all up and running ok on the VM machine I've been trying to set up. However after following the instructions on this link:
http://symfony.com/doc/current/book/installation.html#configuration-and-setup
I'm not getting reassuring 'welcome' page in the screenshot. Instead, I just see an empty page with 'Homepage.' written in the corner. The underlying HTML is:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Welcome!</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
</head>
<body>
Homepage.
<div id="sfwdtc2fded" class="sf-toolbar" style="display: none"></div>
<script>
/* [editor's note: the JS code of the toolbar has been removed] */
</script>
</body>
</html>
I get exactly the same whether I go to: http://localhost/app.php or http://localhost/app_dev.php
Does anyone know what could be causing this? The link http://localhost:8000/config.php works perfectly and I have no errors there (just one recommendation to install INTL extension but I don't suppose that's the problem).
You've probably installed Symfony 2.6, which had an AppBundle delivering your this page. You can comment the line registering the AppBundle in app/AppKernel.php to see the demo homepage.
I had the same problem and solved it by running
composer require symfony/framework-bundle
and it seems to have solved me problem.

codesleeve asset pipeline not compiling or concatenating except on local

I am using Codesleeve Asset Pipeline in Laravel 4 to serve my css and js files.
Unfortunately it does not want to compile bootstrap in a staging environment.
This is the config:
'paths' => array(
'app/assets/javascripts',
'app/assets/stylesheets',
'app/assets/images',
'lib/assets/javascripts',
'lib/assets/stylesheets',
'lib/assets/images',
'provider/assets/javascripts',
'provider/assets/stylesheets',
'provider/assets/images',
'vendor/twitter/bootstrap/less/',
'vendor/twitter/bootstrap/js/',
),
Those 3 lines are the only ones changed.
On my local instance it works fine, I get one css file including all of bootstrap and my own stuff, and one js file with jquery and the bootstrap plugins I asked for.
But on the staging server, I get this:
<link href="http://website.net/assets/vendor/twitter/bootstrap/less/bootstrap.less" rel="stylesheet" type="text/css">
<link href="http://website.net/assets/application.css" rel="stylesheet" type="text/css">
<script src="http://website.net/assets/jquery.min.js" ></script>
<script src="http://website.net/assets/vendor/twitter/bootstrap/js/button.js" ></script>
<script src="http://website.net/assets/vendor/twitter/bootstrap/js/dropdown.js" ></script>
<script src="http://website.net/assets/application.js" ></script>
I think that the asset pipeline is not even trying to concatenate or compile anything.
It turned out that the minifier was barfing on bootstrap 3's css, and not producing the file. However no error was thrown.
You need to add your staging server on the config asset-pipeline so it also compiles on this stage.

Joomla 2.5 not loading JS scripts through article?

In Joomla 2.5 I have installed DirectPHP, which I have used extensively in Joomla 1.6 to embed PHP in Joomla articles. It works very well. I usually just for one include in the article, like this:
<?php
include "my_cool_script.php";
?>
Then I make my code in my_cool_script.php. One thing I often do is include more JS or CSS scripts in the page, right through the article, but putting the following lines in my_cool_script.php:
<link rel="stylesheet" type="text/css" media="screen" href="/scripts/css/dark-hive/jquery-ui-1.8.21.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/scripts/css/ui.jqgrid.css" />
<script src="/scripts/js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="/scripts/js/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<script src="/scripts/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="/scripts/js/jquery.jqGrid.src.js" type="text/javascript"></script>
This has always worked in the past, with Joomla 1.6. Now in the Joomla 2.5 install. The rest of the PHP and HTML is loading in the article, and there aren't any errors on the page as far as loading the scripts. I look at the HTML code and I can see the above lines written to the page, but I cannot access any of the jQuery functions, like the script was not loaded. I get an error when I try to use any jQuery syntax. I know this script was working, because I just moved it from another site, running joomla 1.5 to the new one, 2.5.
Does anyone know anything about why the scripts aren't loading?
EDIT
Well i guess the script was loading, but it didn't like that used the $ symbol. I changed them all to jQuery and it works.
I am not sure exactly why, but perhaps in my installation there is some conflict, and the $ symbol is being recognized as it usually does, signifying that we are dong jQuery. So I changed all the $ to jQuery in my PHP scripts and all the jQuery seems to be working now.
Mootools (Joomla's javascript default framework until version 2.5) also uses '$', so it's very easy to run into some complications if you're unaware you're running scripts relying on both frameworks side to side.
Having said that, you could use 'jQuery' instead of '$' and release '$' for everyone else using the jQuery.noConflict(); command.
Cheers.

Yii is not auto including jquery

I have a strange problem with Yii & Jquery:
When I open a page which uses ajax/jquery on localhost Yii does automatically add asset include calls to the of the page:
<link rel="stylesheet" type="text/css" href="/PATH/assets/f72b359d/style.css" />
<script type="text/javascript" src="/PATH/assets/2e442e1a/jquery.js"></script>
<script type="text/javascript" src="/PATH/assets/2e442e1a/jquery.cookie.js"></script>
However when I run same code on the server Yii does not do it hense no Jquery available.
I'd appreciate if someone could direct to a way to solve it.
It seems like you're not registering jQuery in the correct way. You must add the following line in /protected/views/layout/main.php before </head> tag:
<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>
It will load jQuery automatically. Remember, if the YII_DEBUG flag is on it will load non-minified version, when deactivated (on production) it will load minified version. Hope this will fix your problem.
If all is working on your local machine it might be a permission problems
Have you checked that /assets is writable on your server ?
Yii publishes the assets it needs at runtime in this directory

Categories