473,670 Members | 2,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help for broken link

9 New Member
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
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $HOST = 'localhost';
  3. $USERNAME = 'root';
  4. $PASSWORD = '';
  5. $DB = 'c203';
  6.  
  7. $link = mysqli_connect($HOST,$USERNAME,$PASSWORD,$DB) or die(mysqli_connect_error());
  8. $sql = "SELECT name,birthday,nationality,age,biography,picture FROM stars";
  9. $result = mysqli_query($link, $sql) or die(mysqli_error($link));
  10. ?>
  11. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  12. <html>
  13.     <head>
  14.         <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  15.         <title>StarGazer</title>
  16.     </head>
  17.     <body>
  18.         <h1>StarGazer</h1>
  19.         <hr />
  20.         <h2>Welcome</h2>
  21.         <table border='1' cellpadding='0' cellspacing='0'>
  22. <?php
  23.     while($row=mysqli_fetch_assoc($result)){
  24.         echo "<tr>";
  25.         echo "<td>".$row['picture']."</td>";  
  26.         echo "<img src='picture/" ;
  27.         echo "</tr>";    
  28.  
  29.  
  30.         //use $row and IMG SRC
  31.     }
  32.  
  33.  
  34.  
  35. ?>        
  36.         </table>
  37.     </body>
  38. </html>
Codes for my index.php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // find the code that only do INSERT
  3. $name = $_POST['name'];
  4. $birthday = $_POST['birthday'];
  5. $nationality = $_POST['nationality'];
  6. $age = $_POST['age'];
  7. $biography = $_POST['biography'];
  8.  
  9.     $target_path = "uploads/";
  10.     $target_path = $target_path . basename( $_FILES['upfile']['name']); 
  11.     if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path . basename ( $_FILES['upfile']['name']))) {
  12.         echo "The file ".  basename( $_FILES['upfile']['name']). " has been uploaded. Please click <a href=index.php>here </a> ";
  13.     }
  14.     else{
  15.     echo "There was an error uploading the file, please try again!";
  16.         }
  17.  
  18.  
  19.     $host = 'localhost';
  20.     $username = 'root';
  21.     $password = '';
  22.     $db = 'c203';
  23.  
  24.     $link = mysqli_connect($host,$username,$password,$db);{
  25.     $query = "INSERT INTO stars(name,birthday, nationality,age,biography,picture) 
  26.     VALUES('$name','$birthday','$nationality','$age','$biography','$target_path')";
  27.     $result = mysqli_query($link, $query) or die(mysqli_error($link));
  28.         }     
  29.  
  30.     $message = "Name : " . $name . "<br />";
  31.     $message1 = "Birthday : " . $birthday . "<br />";
  32.     $message2 = "Nationality : " . $nationality . "<br />";
  33.     $message3 = "Age : " . $age. "<br />";
  34.     $message4 = "Biography : " . $biography . "<br />";
  35.  
  36.  
  37.  
  38.  
  39. ?>
Jan 5 '10 #1
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:
Expand|Select|Wrap|Line Numbers
  1. echo "<img src='picture' />" ;
Or if you are retrieving the url to the picture from the database...it should be:
Expand|Select|Wrap|Line Numbers
  1. echo "<img src='".$row['picture']."' />" ;
-Frinny
Jan 5 '10 #2
punk86
9 New Member
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. >.<
Jan 6 '10 #3
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
Jan 6 '10 #4
punk86
9 New Member
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
Jan 6 '10 #5
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:
Expand|Select|Wrap|Line Numbers
  1. $imgHeight = '150px';
  2. $imgWidth = '150px';
  3. 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
Jan 6 '10 #6
punk86
9 New Member
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
Jan 6 '10 #7
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:
Expand|Select|Wrap|Line Numbers
  1. $imgHeight = '150px';
  2. $imgWidth = '150px';
  3. echo "<img src='".$row['picture']."' style='height:".$imgHeight."; width:".$imgWidth."' />" 
......

You should always double check to make sure that your HTML is valid.

-Frinny
Jan 6 '10 #8
punk86
9 New Member
ic... i really need to buck up in learning all this.. tks a million Frinny :)
Jan 6 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3690
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!...
17
2197
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));
28
3218
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...
2
1591
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
0
1234
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...
1
1795
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...
0
1431
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...
3
4133
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
0
888
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
0
8471
marktang
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...
0
8386
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,...
1
8592
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,...
0
7421
agi2029
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...
1
6216
isladogs
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...
0
5686
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();...
0
4393
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1795
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.