Hi, i been working on this codes but i keep getting broken links for the pictures.
Im using apache.
Need help for this please.
I think its just the codes in my index.php is wrong and i do not know what is the solution.
Code for my addstar.php - <?php
-
$HOST = 'localhost';
-
$USERNAME = 'root';
-
$PASSWORD = '';
-
$DB = 'c203';
-
-
$link = mysqli_connect($HOST,$USERNAME,$PASSWORD,$DB) or die(mysqli_connect_error());
-
$sql = "SELECT name,birthday,nationality,age,biography,picture FROM stars";
-
$result = mysqli_query($link, $sql) or die(mysqli_error($link));
-
?>
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-
<title>StarGazer</title>
-
</head>
-
<body>
-
<h1>StarGazer</h1>
-
<hr />
-
<h2>Welcome</h2>
-
<table border='1' cellpadding='0' cellspacing='0'>
-
<?php
-
while($row=mysqli_fetch_assoc($result)){
-
echo "<tr>";
-
echo "<td>".$row['picture']."</td>";
-
echo "<img src='picture/" ;
-
echo "</tr>";
-
-
-
//use $row and IMG SRC
-
}
-
-
-
-
?>
-
</table>
-
</body>
-
</html>
Codes for my index.php - <?php
-
// find the code that only do INSERT
-
$name = $_POST['name'];
-
$birthday = $_POST['birthday'];
-
$nationality = $_POST['nationality'];
-
$age = $_POST['age'];
-
$biography = $_POST['biography'];
-
-
$target_path = "uploads/";
-
$target_path = $target_path . basename( $_FILES['upfile']['name']);
-
if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path . basename ( $_FILES['upfile']['name']))) {
-
echo "The file ". basename( $_FILES['upfile']['name']). " has been uploaded. Please click <a href=index.php>here </a> ";
-
}
-
else{
-
echo "There was an error uploading the file, please try again!";
-
}
-
-
-
$host = 'localhost';
-
$username = 'root';
-
$password = '';
-
$db = 'c203';
-
-
$link = mysqli_connect($host,$username,$password,$db);{
-
$query = "INSERT INTO stars(name,birthday, nationality,age,biography,picture)
-
VALUES('$name','$birthday','$nationality','$age','$biography','$target_path')";
-
$result = mysqli_query($link, $query) or die(mysqli_error($link));
-
}
-
-
$message = "Name : " . $name . "<br />";
-
$message1 = "Birthday : " . $birthday . "<br />";
-
$message2 = "Nationality : " . $nationality . "<br />";
-
$message3 = "Age : " . $age. "<br />";
-
$message4 = "Biography : " . $biography . "<br />";
-
-
-
-
-
?>
8 2289 Frinavale 9,735
Recognized Expert Moderator Expert
Are you retrieving a picture from the database or are you retrieving the path/url to the picture from the database?
In your addstar.php, on line 26 you need to add a ">" to close the img HTML tag.
It should be: -
echo "<img src='picture' />" ;
Or if you are retrieving the url to the picture from the database...it should be: -
echo "<img src='".$row['picture']."' />" ;
-Frinny
Hi Frinny, tks for the codes.. it works !!! It displays out the picture, just that i need to find how to constraint it into a table. >.<
Frinavale 9,735
Recognized Expert Moderator Expert
Umm what do you mean "constraint it into a table"?
There can be constraint for a table that restricts the data values that can be added to a table..??
-Frinny
Cos now the pictures all are displayed according to the original size....
I want them to have a fixed size for every uploads...
i tried using html method, the width and height thingy but failed..so confusing
I guess i cant fix it till now... lol
Frinavale 9,735
Recognized Expert Moderator Expert
I think I know what you're looking for.
Right now your images are different sizes. Some of them are large and some are small.
You could either use the HTML img tag to resize the image to the desired size like this: -
$imgHeight = '150px';
-
$imgWidth = '150px';
-
echo "<img src='".$row['picture']."' style='height:".$imgHeight."; width:".$imgWidth." />" ;
Or you could resize (scale) the actual image that exists on the server using PhP. You could do this resizing when the image is uploaded, or you could do this resizing in a PhP page dedicated to sending images to the browser. If you resize the images on the server then you may be saving time and resources for when the image is downloaded and displayed in the browser.
-Frinny
Hmmm,the code doesnt work >.<
the picture now has become this :
<img src='uploads/images.jpg' style='height:1 50px; width:150px />
uploads/images.jpg
<img src='uploads/images.jpg' style='height:1 50px; width:150px />
uploads/images.jpg
Frinavale 9,735
Recognized Expert Moderator Expert
That would probably be because I forgot to close the string I supplied as the style attribute...I should have posted: -
$imgHeight = '150px';
-
$imgWidth = '150px';
-
echo "<img src='".$row['picture']."' style='height:".$imgHeight."; width:".$imgWidth."' />"
......
You should always double check to make sure that your HTML is valid.
-Frinny
ic... i really need to buck up in learning all this.. tks a million Frinny :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steve |
last post by:
Hello, I am writing a script that calls a URL and reads the resulting
HTML into a function that strips out everthing and returns ONLY the
links, this is so that I can build a link index of various pages.
I have been programming in PHP for over 2 years now and have never
encountered a problem like the one I am having now. To me this seems
like it should be just about the simplest thing in the world, but I
must admit I'm stumped BIG TIME!...
|
by: Razzel |
last post by:
I created this as a test:
#include <time.h>
main(){
printf(X1: %s\n", putim());
printf(X2: %s\n", putim());
}
putim() {
time_t t;
time(&t);
return(ctime(&t));
|
by: Craig Cockburn |
last post by:
I have a tool which tells me the number of times that visitors attempt
to access a link from my site to an external site and what the response
code received was. In the event of the remote site returning an error
code, they are not sent to the remote site - why bother, it wouldn't
work!
Since I have over 1000 external links, this allows me to locate the
broken links that people see the most often and fix those first.
Conventional link...
|
by: vbgunz |
last post by:
Hello!
this is the main error:
http://img406.imageshack.us/img406/5218/screenshotxchmerror1ae.png
navigation link images broken here:
http://img406.imageshack.us/img406/2822/screenshotxchmv12python24docum.png
when I first open up the docs, the main page and Global Module Index
links in the tree are unaccessible. They give me errors. While
|
by: Josema |
last post by:
Hi,
Im making an asyncronous application that will detect broken links inside a
web site.
the question is that i have a tree view in my windows form application, and
when a person enters a url and click in the button "search broken links" the
application starts visit this page, get the html content and then try to
visit each link inside this content and again the same, until the complete
web site been analized...
| |
by: atombee |
last post by:
Hi- this is the project that will not end! (sure you've all been there). I had originally purchased a php/css nav bar for the client, but it was buggy as hell, so I decided to do in css, in which I am still a novice, I am afraid.
You can see the sample nav bar at www.tangerine-sky.com/horizontal_nav.html (I am pasting source code below)
It's very simple, has the css included in the page ... works fine on a mac, okay on firefox on a PC but...
|
by: preetkanwal0678 |
last post by:
Hello all,
Am working on PYTHON +BRANWAVE(framework)
Actually am Trying 2 make a tree menu using d both. Am not able 2 target the (.tmpl) files and not getting how 2 make frames in .tmpl file...
Can anyone get me a demo screen 4 d same showing a tree on the left and when we click any link in the tree, corresponding page(.tmpl) page opens up on right...
This is a simple Tree Example>>>>>>> file name="mytreeapp.py"
import...
|
by: Giampaolo Rodola' |
last post by:
Hi there,
I would like to know if such function would be correct for verifying
if a link is broken and/or circular.
def isvalidlink(path):
assert os.path.islink(path)
try:
os.stat(path)
except os.error:
return 1
|
by: John Dalberg |
last post by:
Every link on the web I tested to download the C# snippets links to page on
MS's which is broken. Anyone knows a download link which work?
Broken page:
http://msdn.microsoft.com/vstudio/downloads/codesnippets/default.aspx
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |