| | |
Script errors
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 140
Reputation:
Solved Threads: 2
Hi,
Firstly apologies as i shouldnt have set a previous thread as solved.
The following script should:
1. get record with id of 1 and display in text box
2. after user changes it, it is written to mysql
3. the screen informs user that this has been achieved
Firstly apologies as i shouldnt have set a previous thread as solved.
The following script should:
1. get record with id of 1 and display in text box
2. after user changes it, it is written to mysql
3. the screen informs user that this has been achieved
PHP Syntax (Toggle Plain Text)
<?php $result = mysql_query("select * from indexinfo where id = 1"); $row = mysql_fetch_assoc($result); if ( isset( $_POST['send'] ) ) { // The author's details have been updated. $title = $_POST['Title']; $subtitle = $_POST['Subtitle']; $content = $_POST['Content']; $author = $_POST['Author']; $date = $_POST['Date']; $id = $_POST['id']; $sql = "UPDATE `indexinfo` SET `Title` = '$title', `Subtitle` = '$subtitle', `Content` = '$content', `Author` = '$author', `Date` = '$date' WHERE `id` = '$id'"; if (mysql_query($sql)) { echo '<p>Author details updated.</p>'; } else { echo '<p>Error updating author details: ' . mysql_error() . '</p>'; } ?> <form action="#" method="post"> <p>Edit the author:</p> <label>Title: <input type="text" name="Title" value="<?php echo $title; ?>" /></label><br /> <label>Subtitle: <input type="text" name="Subtitle" value="<?php echo $subtitle; ?>" /></label><br /> <label>Content: <TEXTAREA name="Content" ROWS=10 COLS=100><?php echo $content; ?></TEXTAREA><br /> <label>Author: <input type="text" name="Author" value="<?php echo $author; ?>" /></label><br /> <label>Date: <input type="text" name="Date" value="<?php echo $date; ?>" /></label><br /> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <input type="submit" value="Submit" name="send" /></p> </form> <?php } else { ?> <form action="#" method="post"> <p>Edit the author:</p> <label>Title: <input type="text" name="Title" /></label><br /> <label>Subtitle: <input type="text" name="Subtitle" /></label><br /> <label>Content: <TEXTAREA name="Content" ROWS=10 COLS=100></TEXTAREA><br /> <label>Author: <input type="text" name="Author" /></label><br /> <label>Date: <input type="text" name="Date" /></label><br /> <input type="hidden" name="id" /> <input type="submit" value="Submit" name="send" /></p> </form> <?php } ?>
Hi there,
You don't actually have a problem statement in your post, so I'm not really sure where you are going wrong.
But, I notice that after querying the database at the top of the file, you don't do anything with the $row variable, which is why you aren't seeing anything in your form the first time you load the page.
Hope this helped
You don't actually have a problem statement in your post, so I'm not really sure where you are going wrong.
But, I notice that after querying the database at the top of the file, you don't do anything with the $row variable, which is why you aren't seeing anything in your form the first time you load the page.
Hope this helped
$me = new Person();
if (isset($_COOKIE)){
$me->eat($_COOKIE);
} else { $me->starve(); }
if (isset($_COOKIE)){
$me->eat($_COOKIE);
} else { $me->starve(); }
What do you mean as in if you haven't submitted the form you still get the row updated message?
Posts should be like mini-skirts, long enough to cover enough, but not too long that you cover too much.
My Liveperson: http://liveperson.com/josh-connerty/
My Liveperson: http://liveperson.com/josh-connerty/
•
•
•
•
The form itself displays each of the headers.... title, subtitle, content, author and date..... but it doesnt echo the data that is held in the mysql database.
On changing the cell information and clicking submit, a success message is given, but the row in the database is not updated.
php Syntax (Toggle Plain Text)
$query = mysql_query("QUERY") or die( "UPDATE ERROR:" . mysql_error() ); // QUERY being the update query you have been using.
Posts should be like mini-skirts, long enough to cover enough, but not too long that you cover too much.
My Liveperson: http://liveperson.com/josh-connerty/
My Liveperson: http://liveperson.com/josh-connerty/
![]() |
Similar Threads
- image resize script errors (PHP)
- Errors in my Javascript (JavaScript / DHTML / AJAX)
- This is really starting to piss me off... (Internet Explorer Script Error) (Windows NT / 2000 / XP)
- can anyone help me to debug this script (Perl)
- Java script errors with IE & Mozilla (Web Browsers)
- Logon script errors (Windows NT / 2000 / XP)
- script errors? (Windows NT / 2000 / XP)
- My CGI Script gives me this error...What am I missing? (Perl)
- Internet Explorer script error (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: Dropdown not showing in table
- Next Thread: PHP Object method extension
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





