|
|
|
|
Thread title: UPDATE Problems |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
03-13-2008, 12:27 AM
|
#1
|
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
Posts: 9
|
|
|
03-13-2008, 10:45 PM
|
#2
|
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
Posts: 23
|
Originally Posted by Will Green
|
Yay, TehUpload =] My site.
Originally Posted by VernonK
That's pretty much what we've been doing... Do this...
PHP Code:
<?php echo $s; //echo the query out ?>
Then take that query string and go to phpMyAdmin. Click on the SQL tab at the top and then paste the query string in and hit go. What happens?
I would really love to see what the actual query string looks like. There isn't anything wrong with the sample query structure's we've given... that's the strange thing.
One thing I did notice just now... you don't have a Primary Key set on the settings table. Each table should have a primary key field.
|
Not every table needs a primary key,
In relational database design, a unique key or primary key is a candidate key to uniquely identify each row in a table
|
If there is just one row, I do believe that you do not need a primary key. As that just organizes it and identifies the row, otherwise it would just be like finding a needle in a haystack?
The problem may have been you didn't have a row in the first place, which would mean it would not update anything, and just display blank fields.
Did you end up creating a row inside of that table?
|
|
03-14-2008, 12:23 AM
|
#3
|
Status: Junior Member
Join date: Jan 2007
Location: Western Maryland
Expertise:
Software:
Posts: 39
|
Originally Posted by Dentafrice
Not every table needs a primary key
|
According to W3C they do. Check towards the bottom...
Primary Keys and Auto Increment Fields
Each table should have a primary key field.
|
Of course I'm not a stickler guy though so hope it doesn't come across that way.
|
|
03-14-2008, 12:31 AM
|
#4
|
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
Posts: 23
|
Same, I don't mean to sound that way either.
Well usually tables do have more then one row, which would have a need for a primary key.
If it is just going to be a one row field, I don't see a need for it? :P
|
|
03-14-2008, 03:20 AM
|
#5
|
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
Posts: 20
|
W3C standards say you need a primary key, and sometimes it does show when you get a random error concerning it, but for the most part, you don't need one, I don't use one, and you definitely don't need one for one-record tables
|
|
03-14-2008, 03:52 AM
|
#6
|
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
Posts: 9
|
Originally Posted by Charlay
W3C standards say you need a primary key, and sometimes it does show when you get a random error concerning it, but for the most part, you don't need one, I don't use one, and you definitely don't need one for one-record tables
|
For those who are wondering why this code worked but yours didnt;
I never checked the DB to see if they updated, I just relied on the echo's that displayed the information. Therefore, if that had an error in it then I thouht it diet worked. Lazy move by me, I know.
Thank you so much everyone who helped me out, and trust me - you're going to be seeing more PHP question threads from me.
|
|
03-13-2008, 08:58 AM
|
#7
|
Status: Request a custom title
Join date: Apr 2007
Location: UK
Expertise: Code & Programming
Software: Coda, TextMate, Sublime 2
Posts: 2,097
|
Take a back up of your original code and try the following:
PHP Code:
<?php
include("site_config.php"); if ( isset($_POST['submit']) ) { $title = addslashes(trim($_POST["title"])); $status = addslashes(trim($_POST["status"])); $logo = addslashes(trim($_POST["logo"])); $offline = addslashes(trim($_POST["offline"])); $left = addslashes(trim($_POST["left_logo"])); $s = " UPDATE settings SET title = '$title', status = '$status', main_logo = '$logo', offline_text = '$offline', logo_left = '$left_logo' "; mysql_query($s) or die(mysql_error()); $selectDatabase = $mysql_query("SELECT * FROM settings"); $row = mysql_fetch_array($selectDatabase); }
?>
<form action="" method="post"> <h2>site title - <span>this is the title your browser displays for your website.</span></h2><br /> <input class="textbox" name="title" type="text" value="<?php echo $row["title"];?>"/> <h2>site status - <span>this declares whther your site is online or offline.</span></h2><br /> <input name="status" type="radio" value="offline">Offline</input> <input name="status" type="radio" value="online">Online</input> <h2>offline notice - <span>this is the message users see when the website is set to offline.</span></h2> <textarea class="textarea" name="offline" type="text"><?php echo $row["offline_text"]; ?></textarea> <h2>main logo - <span>this is your sites main logo.</span></h2> <input class="textbox" name="logo" type="text" value="<?php echo $row["main_logo"]; ?>"/> <h2>semi-main logo - <span>this is your sites semi-main logo. its the bigger logo seen on the left of each page.</span></h2><br /> <input class="textbox" name="left_logo" type="text" value="<?php echo $row["logo_left"]; ?>"/> <br /><br /> <input type="submit" value="edit settings" name="submit" class="submit" /> </form>
|
|
03-13-2008, 02:17 PM
|
#8
|
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
Posts: 9
|
No, that didn't work.
Seeing as none of these codes are working, could someone post an example of how they would update a mySQL entry/entries using HTML?
|
|
03-13-2008, 03:39 PM
|
#9
|
Status: Junior Member
Join date: Jan 2007
Location: Western Maryland
Expertise:
Software:
Posts: 39
|
That's pretty much what we've been doing... Do this...
PHP Code:
<?php echo $s; //echo the query out ?>
Then take that query string and go to phpMyAdmin. Click on the SQL tab at the top and then paste the query string in and hit go. What happens?
I would really love to see what the actual query string looks like. There isn't anything wrong with the sample query structure's we've given... that's the strange thing.
One thing I did notice just now... you don't have a Primary Key set on the settings table. Each table should have a primary key field.
|
|
03-13-2008, 05:07 PM
|
#10
|
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
Posts: 9
|
Thanks for everyone's help, I've fixed it (with the help of all of you!).
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|