You are here: Re: the script wont work and i cant find anything wrong please help « PHP Programming Language « IT news, forums, messages
Re: the script wont work and i cant find anything wrong please help

Posted by so many sites so little time on 11/24/06 12:40

Alright so im trying that and still no luck the string defines home_id
as home_id={$_GET['id']}' so can i because the collumn i want to select
from is home_id can i say
$query = "SELECT home_id FROM home WHERE home_id={$_GET['id']}; or does
it need to stay wildcard?
Brent Palmer wrote:
> "so many sites so little time" <kkddrpg@gmail.com> wrote in message
> news:1164336448.477402.134570@45g2000cws.googlegroups.com...
> > nope
> > not working
> > petersprc wrote:
> >> Try "select * from home" instead of "from home_id"...?
> >>
> >> > $query = "SELECT * FROM home_id WHERE home_id={$_GET['id']}";
> >>
> >> so many sites so little time wrote:
> >> > all right so the script is pretty simple it goes it retrives what the
> >> > id of the post is and it lets you edit it well no it doesnt.
> >> >
> >> > now if you go to www.kirewire.com/pp2/index/php you will see a number 1
> >> > that is the value of collumn home_id which is set to auto increment ect
> >> > ect
> >> >
> >> > but this script which gets the id of home_id of a row and lets you edit
> >> > it does not work for somereason...
> >> >
> >> >
> >> > if (isset ($_POST['submit'])) { // Handle the form.
> >> >
> >> > // Define the query.
> >> > $query = "UPDATE home SET header='{$_POST['header']}',
> >> > body='{$_POST['body']}' WHERE home_id={$_POST['id']}";
> >> > $r = mysql_query ($query); // Execute the query.
> >> >
> >> > // Report on the result.
> >> > if (mysql_affected_rows() == 1) {
> >> > print '<p>The blog entry has been updated.</p>';
> >> > } else {
> >> > print "<p>Could update the entry because: <b>" . mysql_error() .
> >> > "</b>. The query was $query.</p>";
> >> > }
> >> >
> >> > } else { // Display the entry in a form.
> >> >
> >> > // Check for a valid entry ID in the URL.
> >> > if (is_numeric ($_GET['id']) ) {
> >> >
> >> > // Define the query.
> >> > $query = "SELECT * FROM home_id WHERE home_id={$_GET['id']}";
> >> > if ($r = mysql_query ($query)) { // Run the query.
> >> >
> >> > $row = mysql_fetch_array ($r); // Retrieve the information.
> >> >
> >> > // Make the form.
> >> > print '<form action="update_site.php" method="post">
> >> > <p>Header: <input type="text" name="header" size="40" maxsize="100"
> >> > value="' . $row['header'] . '" /></p>
> >> > <p>Body: <textarea name="body" columns="40" rows="5">' . $row['body']
> >> > . '</textarea></p>
> >> > <input type="hidden" name="id" value="' . $_GET['id'] . '" />
> >> > <input type="submit" name="submit" value="Update your Website!" />
> >> > </form>';
> >> >
> >> > } else { // Couldn't get the information.
> >> > print "<p>Could retrieve the entry because: <b>" . mysql_error() .
> >> > "</b>. The query was $query.</p>";
> >> > }
> >> >
> >> > } else { // No ID set.
> >> > print '<p><b>You must have made a mistake in using this
> >> > page.</b></p>';
> >> > }
> >> >
> >> > } // End of main IF.
> >> >
> >> > mysql_close(); // Close the database connection.
> >> >
> >> > ?>
> >> >
> >> > to see what you get go to www.kirewire.com/pp2/update_site.php
> >> >
> >> > could you please help, thanks, and have a happy thanksgiving
> >
>
> To me petersprc was on the right track. This may not be your main problem
> but you still need to fix this part.
> "SELECT * FROM home_id WHERE home_id" -> "SELECT * FROM home WHERE home_id"
> You should be selecting from a table.
>
> Regards,
>
> Brent Palmer.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация