/    Sign up×
Community /Pin to ProfileBookmark

php edit database file not pulling data through

Hi,

My CMS edit files isn’t pulling through the data from the databaes intothe form fields – so that the user can edit the information………

whats missing?


——–

<?php

$Link = @mysql_connect(‘mydata’, ‘mydata’, mydata);
if (!$Link) {
exit(‘<p>Unable to connect to the ‘ .
‘database server at this time.</p>’);
}

if (!@mysql_select_db(‘mydata’)) {
exit(‘<p>Unable to locate the PartyCo ‘ .
‘database at this time.</p>’);
}

if (isset($_POST[‘party_title’])):
// if details have been submitted

$party_title = $_POST[‘party_title’];
$description = $_
POST[‘description’];
$price = $_POST[‘price’];
$size = $_
POST[‘size’];
$thumbnail = $_POST[‘thumbnail’];
$venue = $_
POST[‘venue’];
$includes = $_POST[‘includes’];
$dates_prices = $_
POST[‘dates_prices’];
$times = $_POST[‘times’];
$venue_info = $_
POST[‘venue_info’];
$menu = $_POST[‘menu’];
$id = $_
POST[‘party’];
$sql = “UPDATE christmas SET
party_title=’$party_title’,
description=’$description’,
price=’$price’,
size=’$size’,
thumbnail=’$thumbnail’,
venue=’$venue’,
includes=’$includes’,
dates_prices=’$dates_prices’,
times=’$times’,
venue_info=’$venue_info’,
menu=’$menu’
WHERE party=’$party'”;
if (@mysql_query($sql)) {
echo ‘<p>Party details updated.</p>’;
} else {
echo ‘<p>Error updating details: ‘ .
mysql_error() . ‘</p>’;
}

?>

<p><a href=”christmas.php”>Return to parties list</a></p>

<?php
else:

$party = $_GET[‘party’];
$christmas = @mysql_query(
“SELECT party_title, description, price, size, thumbnail, venue, includes, dates_prices, times, venue_info, menu FROM christmas WHERE party=’$party'”);
if (!$christmas) {
exit(‘<p>Error fetching christmas details: ‘ .
mysql_error() . ‘</p>’);
}

$christmas = mysql_fetch_array($christmas);

$party_title = $christmas[‘party_title’];
$description = $christmas[‘description’];
$price = $christmas[‘price’];
$size = $christmas[‘size’];
$thumbnail = $christmas[‘thumbnail’];
$venue = $christmas[‘venue’];
$includes = $christmas[‘includes’];
$dates_prices = $christmas[‘dates_prices’];
$times = $christmas[‘times’];
$venue_info = $christmas[‘venue_info’];
$menu = $christmas[‘menu’];

// convert special characters for safe use
// as HTML attributes.

$party_title = htmlspecialchars($party_title);
$description = htmlspecialchars($description);
$price = htmlspecialchars($price);
$size = htmlspecialchars($size);
$thumbnail = htmlspecialchars($size);
$venue = htmlspecialchars($size);
$includes = htmlspecialchars($includes);
$dates_prices = htmlspecialchars($dates_prices);
$times = htmlspecialchars($times);
$venue_info = htmlspecialchars($venue_info);
$menu = htmlspecialchars($menu);

?>

<form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=”post”>
<h2>Edit the party:</h2>
<table cellspacing=”3″ cellpadding=”0″ border=”0″ style=”margin:10px 0 0 0;”>
<tr><td class=”formHeader”>Party Name:</td><td><input type=”text” style=”width:330px;” name=”party_title” value=”<?php echo $party_title; ?>” /></td></tr>
<tr><td class=”formHeader”>Price:</td><td><input type=”text” style=”width:330px;” name=”price” value=”<?php echo $price; ?>” /></td></tr>
<tr><td class=”formHeader”>Size:</td><td><input type=”text” style=”width:330px;” name=”size” value=”<?php echo $size; ?>” /></td></tr>
<tr><td class=”formHeader”>thumbnail:</td><td><input type=”text” style=”width:330px;” name=”thumbnail” value=”<?php echo $thumbnail; ?>” /></td></tr>
<tr><td class=”formHeader”>venue:</td><td><textarea cols=”39″ rows=”8″ name=”venue” value=”<?php echo $venue; ?>”></textarea></td></td></tr>
<tr><td class=”formHeader”>includes:</td><td><textarea cols=”39″ rows=”8″ name=”includes” value=”<?php echo $includes; ?>”></textarea></td></tr>
<tr><td class=”formHeader”>dates &amp; prices:</td><td><textarea type=”text” cols=”39″ rows=”8″ name=”dates_prices” value=”<?php echo $dates_prices; ?>”></textarea></td></tr>
<tr><td class=”formHeader”>times:</td><td><textarea type=”text” name=”times” cols=”39″ rows=”8″ value=”<?php echo $times; ?>”></textarea></td></tr>
<tr><td class=”formHeader”>venue info:</td><td><textarea type=”text” cols=”39″ rows=”8″ name=”venue_info” value=”<?php echo $venue_info; ?>”></textarea></td></tr>
<tr><td class=”formHeader”>menu:</td><td><textarea type=”text” cols=”39″ rows=”8″ name=”menu” value=”<?php echo $menu; ?>”></textarea></td></tr>
<tr><td colspan=”2″><input type=”hidden” name=”party” value=”<?php echo $party; ?>” /></td></tr>
<tr><td align=”right” colspan=”2″><input type=”submit” value=”update event” /></td></tr>
</table>
</form>

<?php endif; ?>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@aarondmauthorJun 24.2010 — the page that sends to this page which grabs 'party' field (id) from my database - i think this is where the problem is as when i go the the above page - and type in and 'party' id of 1 - the data is displayed..........so maybye the link isnt passing the right information...............

<?php

$Link = mysql_connect("myinfo", "myinfo", "myinfo") or die(mysql_error());

mysql_select_db("myinfo") or die(mysql_error());

$query = @mysql_query('SELECT party, party_title FROM christmas');

if (!$query) {

exit('<p>Error retrieving events from database!<br/>'.

'Error: ' . mysql_error() . '</p>');

}

while ($christmas = mysql_fetch_array($query)) {

$party = $christmas['party'];

$name = htmlspecialchars($christmas['party_title']);

echo "<p>$name ".

"<a href='editparty.php?party=$party_title'>Edit</a> ".

"<a href='deleteparty.php?party=$party_title'>Delete</a></p>";

}

?>


thanks
×

Success!

Help @aarondm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...