Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 7 years ago.
Improve this question
my php code works fine on local server but does not execute on web server
some of the codes are working.
the code is given down and please tell me problem with the code.
<?php
include("/connect.php");
session_start();
$_SESSION['title']="Portfolio | Mactros Inc.";
include("header.php");
?>
<div>
<center>
<font size=7 class="top">
Portfolio<br />
</font>
<font style="color: #aeafb1;">Home -> Portfolio</font>
</center>
</div>
<div style="height: 650px; margin-top: 10px;">
<?php
$sql = "select * from project";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()){
?>
<div class="portfolio">
<center>
<img src="<?php echo $row["pic"]; ?>" class="port">
<font size=5><?php echo $row["name"];?></font><br>
<font><?php echo $row["type"];?></font>
</center>
</div>
<?php }?>
</div><?php include("footer.php");?>
in this code gets executed other gets ignored
<?php
include("/connect.php");
session_start();
$_SESSION['title']="Portfolio | Mactros Inc.";
include("header.php");
?> <div>
<center>
<font size=7 class="top">
Portfolio<br />
</font>
<font style="color: #aeafb1;">Home -> Portfolio</font>
include("/connect.php");
This is an absolute path, I don't think your script is at the root of your filesystem, use a relative path instead, and don't disable errors.
Write this line of code at top of you script file to show errors which are occurring into script.
ini_set('display_errors', 1);
error_reporting(E_ALL);
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have an HTML table populated from a mysql database table via PHP with 8 different values.
I need to open a second page and pass to it any one from the values I click on in order to query another from the database.
So far I can open the second page via href but I could solve the parameter issue.
Can anyone help me on this?
The code:
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
include "ligabd.php";//connects to the server
if(!$l)
{
die("Ligação sem sucesso: ".mysql_error());
}
else
{
$query="SELECT escalao FROM escaloes ORDER BY idescaloes ASC";
$result= mysqli_query($l, $query);
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<table id="t01" align="center">
<br>
<br>
<br>
<br>
<tr>
<td align="center">Escalões</td>
</tr>
<?php
while ($record= mysqli_fetch_array($result))
{
$r=$record['escalao'];
?>
<tr>
<td>
<a href="pag_escalao_mensalidade.php?escalao=">
<?php
echo $record['escalao'];
?>
</a>
</td>
</tr>
<?php
}
}
?>
</table>
</body>
You should use id in your table and use this:
$query="SELECT id, escalao FROM escaloes ORDER BY idescaloes ASC";
...
while ($record=mysqli_fetch_assoc($result)) // Fetch assoc!
...
<?= $record['escalao'] ?>
....
On the second page, you fetch the record again
$query='SELECT * FROM escaloes WHERE id=' . intval( $_GET['id'] );
This is wrong:
<a href="pag_escalao_mensalidade.php?escalao=">
<?php
echo $record['escalao'];
?>
It should be
<a href="pag_escalao_mensalidade.php?escalao=<?php
^^---
echo $record['escalao'];
?>"><?php echo $record['escalao'] ?>
^^^^^^^---
Note the indicated changes
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am having multiple images, for that individual image i am having download button
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<button id='dwn_<? echo $a;?>'>Download</button>
<br>
<? } ?>
</div>
If i click that download button i need to save that corresponding image to my local system.
Kindly give some solution for this.
the easiest way without javascript i think it would ( I edited your code, but i cant try it now)
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<form method="get" action='image_<? echo $a;?>.jpg'>
<button id='dwn_<? echo $a;?>' type="submit">Download</button>
</form>
<br>
<? } ?>
</div>
You can delete the id in button if you only use for download
download.php
.........
<?php
if(isset($_REQUEST) && ($_REQUEST['image_name'])){
$filename = $_REQUEST['image_name'].'.jpg';
// Write download code here
}
display_page.php
............
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<a href="download.php?image_name=<?php echo $a; ?>" >Download</a>
<br>
<? } ?>
</div>
Most easiest way by using html 5
<div>
<?php
for($a=0;$a<5;$a++) { ?>
<img src='image_<? echo $a;?>.jpg'/>
<a href='image_<? echo $a;?>.jpg' download>
<span id='dwn_<? echo $a;?>'>Download</span >
</a>
<br>
<? } ?>
</div>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have this PHP code:
<?php
session_start();
if (!empty($_SESSION['username'])) {
?>
Welcome, <?= $_SESSION['username'] ?>
<br>
<a href='mcLogout.php'>Logout</a>
<?php
} else {
?>
<p class="da">Don't have an account?</p>
<p><a class="lr" href='registrationpage.php'>Register Here</a></p>
<?php
}
?>
The code is display the username of the user who is in the session (logged) and a link to log out. I wish to know how can I give a style to the username using CSS i.e:
"Welcome, <?=$_SESSION['username']?>"
This part of the code.
you could just wrap it in <span> and do some CSS, like:
...
Welcome, <span class="username"><?=$_SESSION['username']?></span>
...
then css:
.username {
color: #D2D8D9;
font-weight: bold;
....
}
what ever comes between wihle echoing are just like any other HTML element.
<h1>" Welcome, " <?= $_SESSION['username'] ?></h1>
or
Welcome, <h1 class="username"><?= $_SESSION['username'] ?></h1>
Just wrap your "Welcome part in a div"
<?php
session_start();
if (!empty($_SESSION['username'])) {
?>
<div class="welcome-user">Welcome, <?= $_SESSION['username'] ?></div>
<br>
<a href='mcLogout.php'>Logout</a>
<?php
} else {
?>
<p class="da">Don't have an account?</p>
<p><a class="lr" href='registrationpage.php'>Register Here</a></p>
<?php
}
?>
You haven't have short tags <? ... ?> Turned on... I think...
Try <?php ... ?> this will do... and instead of <?=$_SESSION['username']; ?> write <?php echo $_SESSION['username']; ?>
This will work...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
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.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Improve this question
I am working on coding this up with a mixture of PHP and HTML but I can't seem to understand why I am getting an eof yet when I exclude the middle php part, it works just fine. i can't seem to understand why it is giving me an error. I compared it to another part of my program and when I looked at a similar page, it works but this one is simply giving me an unexpected eof
Here is the code. Any suggestions?
<!DOCTYPE html>
<?php
require_once( "data.php" );
error_reporting(0);
?>
<html>
<head>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>Course Listings</h1>
</div>
<table class="table">
<?php
foreach( $data as $value )
{
?>
<tr>
<td> <? $value[number] ?> </td>
<td> <? $value[name] ?> </td>
<td> <? $value[instructor] ?> </td>
</tr>
<?
};
?>
</table>
</div>
<script src="http://code.jquery.com/jquery.min.js"></script>
</body>
</html>
The closing bracket of your foreach is not being processed because short tags are disabled. This causes the unexpected eof because php still expects a closing bracket.
Use the standard tag <?php everywhere.
Fred-ii most likely had it right in his comment. if that doesn't completely solve it, replace your <table> contents with this and see if it works. As the other guys mentioned, you may have an issue with <?=
<table class="table">
<?php foreach($data as $value ): ?>
<tr>
<td> <?php echo $value['number']; ?> </td>
<td> <?php echo $value['name']; ?> </td>
<td> <?php echo $value['instructor']; ?></td>
</tr>
<?php endforeach; ?>
</table>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I want to hide element in my website. I have 2 level access (ad,op). If I logged as sp I can acces Buy, Try, List Upload, and Upload. If I logged as ad, I can access Buy, Try, and List Upload. and not logged, can access Buy and Try.
My code : http://pastebin.com/SvZmzmxK
<p style="text-align:justify;"> </p>
<strong>Buy </strong> <strong> Try</strong>
<?php if ($level=='super_admin') {?>
<strong> List Upload</strong></br></p>
<strong> Upload</strong></br></p>
<?php } elseif($level=='admin') {?>
<strong> List Upload</strong></br></p>
<strong> Upload</strong></br></p>
<?php } ?>
Looking at your code, this is probably just what you are looking for:
<?php
if ($level=='super_admin')
echo "<strong> List Upload</strong>";
else if elseif($level=='admin')
echo "<strong> List Upload</strong></br></p>
<strong> Upload</strong></br></p>";
?>
I would recommend putting your php in a format like this (using echo) since it keeps your code easier to read and maintain.
I also advice you to look at your html knowledge: </br> and </p> can't just be used liked that.
You can try like this:
<p style="text-align:justify;"> </p>
<strong>Buy </strong> <?php //Buy for all; ?>
<strong> Try</strong> <?php //Try for all; ?>
<?php if( in_array($level,array('super_admin','admin')) ){ ?>
<strong> List Upload</strong> <?php //Buy|Try|List Upload for ad+sp; ?>
<?php if($level=='admin'): ?>
<strong> Upload</strong> <?php //Upload is only for admin(ad); ?>
<?php endif; ?>
<?php } ?>