Jump to content

Recommended Posts

Hello all,

 

I'm trying to allow users who have logged in to be able to update information that's in a database. On the display page, the user can select "edit" and it should take them to a page where they can edit the information set for the program. Here's the display page"

<?php
require_once("db_connx.php");
$result = mysql_query("SELECT * FROM `Content_Calendar` ORDER BY Program") or die($myQuery."<br/><br/>".mysql_error());

while($row = mysql_fetch_array($result)){
$program = $row['Program'];
echo "<h2>" . $row['Program'] . "</h2>";
echo "<p>" . $row['Description'] . "</p>";
echo "<p><strong> On-Air: </strong>" .$row['Production'] . "<br />";
echo "<p> <strong>Promotion: </strong> " .$row['Promotion'] . "<br />";
echo "<p><strong> Online: </strong>" .$row['Web'] . "<br />";
echo "<p><strong> In the Community: </strong>" .$row['Community'] . "<br />";
echo "<a href=\"edit_record_form.php?idi={$program}\">Edit> </a>";
}
require_once("db_connx_close.php");
?>

It appears to take them to the right link. Problem is, it's not display any information at all. Here's the code I have for that:

<?php require_once("db_connx.php");

$program = $_GET['program'];

$sql_rec = “Select * from Content_Calendar where program = “.$program.””;

$row=$mysql_fetch_array($result);

$program= $row[‘program’];

$air_date = $row[‘air_date'];

$description = $row[‘description’];

$production = $row[‘production'];

$promotion = $row[‘promotions’];
$community = $row[‘community'];

$web = $row[‘web’];

$row = ‘’;

?>

<html>

<head>

<title>Update Program Form</title>

</head>

<body>

<form method=”post” action=”update_record.php”>

Program : <br/>

<input type=”text” name=”name” value=”<?php echo “’. $program.’”;?>”>

Air Date<br/>
<input type=”text” name=”name” value=”<?php echo “’. $air_date.’”;?>”>

Description: <br />
<textarea name=”description”><?php echo “’. $description.’”;?> </textarea>

On-Air: <br />
<textarea name=”description”><?php echo “’. $production.’”;?> </textarea>

Promotion: <br />
<textarea name=”description”><?php echo “’. $promotion.’”;?> </textarea>

Community: <br />
<textarea name=”description”><?php echo “’. $community.’”;?> </textarea>
Web: <br />
<textarea name=”description”><?php echo “’. $web.’”;?> </textarea>


<input type=”submit” value=”Submit Record” >

</form>

Any ideas on why this isn't working?

Link to comment
https://forums.phpfreaks.com/topic/287746-updating-database-information/
Share on other sites

what debugging have you done to find out where the problem is at?

 

are the links correct and with the expected idi values in them? is your code in edit_record_form.php using the correct get variable? is your code in edit_record_form.php throwing a php syntax error, due to the smart/curly quotes in it from where ever you copied it from? do you even have php's error reporting set full on so that php syntax errors would be reported?

I have error reporting turned on in my init file using error_reporting( E_ALL & ~E_NOTICE). I've had issues with another page that I was able to figure out thanks to this.

 

The links appear to be correct. It's the full length that's in the code plus the program name. Before I posted, it was going to a wrong link....in that instance, it was bring up my 404 error page. I made the corrections and now the page is just blank.

 

I'm going to values seem to be correct (I've copied  a lot from the add form I created and that works fine. I'll go back and check to make sure.

php syntax errors won't be reported in your main file by settings in that file or included into that file since the code never runs to modify the settings. the error_reporting/display_errors settings must be set before the page is even requested to show syntax errors in your main file, so the settings must be in a php.ini or a .htaccess file (only when php is running as an apache module.) by having the settings in a php.ini/.htaccess file, you don't need to remember to put them into your code for debugging and remember to remove them when you put your code onto a live server.

 

also, error reporting should be E_ALL. by hiding notices messages (the setting you posted) you are missing out on getting php to help you with things like typo errors that cause mismatched variables...

Your edit link is this

echo "<a href=\"edit_record_form.php?idi={$program}\">Edit> </a>";

The program is being passed to edit_record_form.php via the idi query string parameter.

 

However in edit_record_form.php you are using   $_GET['program']  this should be  $_GET['idi'] 

 

The next issue (which I think maybe caused by copy and pasting the code) is the use of magic quotes  “ ”  or  ‘ ’  in your code. Using these types of quotes to define strings/array keys will cause errors. You need to use normal straight quotes   " "  or   ' '   

 

Probably better to post to the source instead of some website about it.

Every mysql_* related item has a large pink warning.

http://www.php.net/manual/en/function.mysql-query.php

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.