Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

image background

Contributor ,
Feb 14, 2007 Feb 14, 2007
I have a php file that i want to add a image background to it. I tried with html code and i could preview it on my web server but when i try view in my browser it just keeps giving me errors like, "unexpected '<' on line 23 , and so on.
How can i add an image as a background in php ?

Thanks everyone
TOPICS
Server side applications
375
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 14, 2007 Feb 14, 2007
For a background image I would create a .css file and link it to the PHP page.

The code would look something like what's below, with the "imagefolder being whatever directory your image is in and the " imagename" being the name of the image. As far as the positioning goes you might need to play around with it a bit.

.pagebg {

background-image: url(imagefolder/imagename.jpg);
background-repeat: no-repeat;
background-position: left top;
}


Hope that helps
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 14, 2007 Feb 14, 2007
Thanks Mds14, this is my code. Where would i place the bg code ?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add a Blog Enty</title>
</head>
<body>
<?php // Script 12.5 - add_entry.php
// This script adds a blog entry to the datadase.

// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

if (isset ($_POST['submit'])) { // Handle the form.

// Connect and select.
if ($dbc = @mysql_connect ('localhost', 'therainb', 'twocats')) {

if (!@mysql_select_db ('test')) {
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}

} else {
die ('<p>Could not connect to MySQL because: <b>' . mysql_error(). '</b></p>');
}

// Define the query.
$query = "INSERT INTO blog_entries (blog_id, title, entry, date_entered) VALUES (0, '{$_POST['title']}', '{$_POST['entry']}', NOW())";

// Execute the query.
if (@mysql_query ($query)) {
print '<p>The blog entry has been added.</p>';
} else {
print "<p>Could not add hte entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}

mysql_close();

}
// Display the form.
?>


<form action="add_entry.php" method="post">
<p>Entry Title: <input type="text" name="title" size="40" maxsize="100" /></p>
<p>Entry Text: <textarea name="entry" columns="40" rows="5"></textarea></p>
<input type="submit" name="submit" value="Add to the Blog!" />
</form>
</body>
</html>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
I wouldn't use what was suggested. Do it this way -

Change

</head>

to -

<style type="text/css">
body {
background-image: url(imagefolder/imagename.jpg);
background-repeat: no-repeat;
}
</style>
</head>


--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"LuisDesigns" <webforumsuser@macromedia.com> wrote in message
news:er0uee$fdu$1@forums.macromedia.com...
> Thanks Mds14, this is my code. Where would i place the bg code ?
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns=" http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> <title>Add a Blog Enty</title>
> </head>
> <body>
> <?php // Script 12.5 - add_entry.php
> // This script adds a blog entry to the datadase.
>
> // Address error handling.
> ini_set ('display_errors', 1);
> error_reporting (E_ALL & ~E_NOTICE);
>
> if (isset ($_POST['submit'])) { // Handle the form.
>
> // Connect and select.
> if ($dbc = @mysql_connect ('localhost', 'therainb', 'twocats')) {
>
> if (!@mysql_select_db ('test')) {
> die ('<p>Could not select the database because: ' . mysql_error() .
> '
</p>');
> }
>
> } else {
> die ('<p>Could not connect to MySQL because: ' . mysql_error().
> '
</p>');
> }
>
> // Define the query.
> $query = "INSERT INTO blog_entries (blog_id, title, entry, date_entered)
> VALUES (0, '{$_POST['title']}', '{$_POST['entry']}', NOW())";
>
> // Execute the query.
> if (@mysql_query ($query)) {
> print '<p>The blog entry has been added.</p>';
> } else {
> print "<p>Could not add hte entry because: " . mysql_error() . ".
> The
> query was $query.</p>";
> }
>
> mysql_close();
>
> }
> // Display the form.
> ?>
>
>
> <form action="add_entry.php" method="post">
> <p>Entry Title: <input type="text" name="title" size="40" maxsize="100"
> /></p>
> <p>Entry Text: <textarea name="entry" columns="40"
> rows="5"></textarea></p>
> <input type="submit" name="submit" value="Add to the Blog!" />
> </form>
> </body>
> </html>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 15, 2007 Feb 15, 2007
hey again. I did what u told me :


here -

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add a Blog Enty</title>
<style type="text/css">
body {
background-image: url( http://i68.photobucket.com/albums/i15/luishicks/newtest00010001.jpg);
background-repeat: no-repeat;
}
</style>
</head>

<body>
<?php // Script 12.5 - add_entry.php
// This script adds a blog entry to the datadase.

// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

if (isset ($_POST['submit'])) { // Handle the form.

// Connect and select.
if ($dbc = @mysql_connect ('localhost', 'therainb', 'twocats')) {

if (!@mysql_select_db ('test')) {
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}

} else {
die ('<p>Could not connect to MySQL because: <b>' . mysql_error(). '</b></p>');
}

// Define the query.
$query = "INSERT INTO blog_entries (blog_id, title, entry, date_entered) VALUES (0, '{$_POST['title']}', '{$_POST['entry']}', NOW())";

// Execute the query.
if (@mysql_query ($query)) {
print '<p>The blog entry has been added.</p>';
} else {
print "<p>Could not add hte entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}

mysql_close();

}
// Display the form.
?>


<form action="add_entry.php" method="post">
<p>Entry Title: <input type="text" name="title" size="40" maxsize="100" /></p>
<p>Entry Text: <textarea name="entry" columns="40" rows="5"></textarea></p>
<input type="submit" name="submit" value="Add to the Blog!" />
</form>
</body>
</html>


but it didn't work.

is that right?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 15, 2007 Feb 15, 2007
LATEST
Never mind. Got it. Should have paid more attention. Your Code worked just fine.
Onemore question. is there a code where when users can click to send a message to a board and when submitted , instead of taking to the "successfully sent page" it takes you to the board show the messages.

here's my example. Of what i don't want.
http://therainbowpride.com/myphptests/add_entry.php


this is the blog:

http://therainbowpride.com/myphptests/view_blog.php

of course i will be removing the edit/delete buttons from the public


ty so much again

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines