Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 730 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

UPDATE Problems

Thread title: UPDATE Problems
Closed Thread  
Page 2 of 3 < 1 2 3 >
    Thread tools Search this thread Display Modes  
03-13-2008, 12:27 AM
#11
Will Green is offline Will Green
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
 
Posts: 9
iTrader: 0 / 0%
 

Will Green is on a distinguished road

  Old

Oh sorry, I didn't realize that (woops!) - here you go:

http://www.tehupload.com/8332424132.png

03-13-2008, 08:58 AM
#12
Gaz is offline Gaz
Gaz's Avatar
Status: Request a custom title
Join date: Apr 2007
Location: UK
Expertise: Code & Programming
Software: Coda, TextMate, Sublime 2
 
Posts: 2,097
iTrader: 26 / 100%
 

Gaz will become famous soon enough Gaz will become famous soon enough

Send a message via Skype™ to Gaz

  Old

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>&nbsp;<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
#13
Will Green is offline Will Green
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
 
Posts: 9
iTrader: 0 / 0%
 

Will Green is on a distinguished road

  Old

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
#14
VernonK is offline VernonK
VernonK's Avatar
Status: Junior Member
Join date: Jan 2007
Location: Western Maryland
Expertise:
Software:
 
Posts: 39
iTrader: 0 / 0%
 

VernonK is on a distinguished road

Send a message via MSN to VernonK

  Old

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
#15
Will Green is offline Will Green
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
 
Posts: 9
iTrader: 0 / 0%
 

Will Green is on a distinguished road

  Old

Thanks for everyone's help, I've fixed it (with the help of all of you!).

03-13-2008, 06:31 PM
#16
Gaz is offline Gaz
Gaz's Avatar
Status: Request a custom title
Join date: Apr 2007
Location: UK
Expertise: Code & Programming
Software: Coda, TextMate, Sublime 2
 
Posts: 2,097
iTrader: 26 / 100%
 

Gaz will become famous soon enough Gaz will become famous soon enough

Send a message via Skype™ to Gaz

  Old

What did you change? Mine should have worked! (It works on my scripts!)

03-13-2008, 07:00 PM
#17
VernonK is offline VernonK
VernonK's Avatar
Status: Junior Member
Join date: Jan 2007
Location: Western Maryland
Expertise:
Software:
 
Posts: 39
iTrader: 0 / 0%
 

VernonK is on a distinguished road

Send a message via MSN to VernonK

  Old

I'm wondering the same thing... what was the problem?

03-13-2008, 10:45 PM
#18
Dentafrice is offline Dentafrice
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
 
Posts: 23
iTrader: 0 / 0%
 

Dentafrice is on a distinguished road

  Old

Originally Posted by Will Green View Post
There's no ID, here's what the phpMyAdmin table looks like for it:
http://www.tehupload.com/12262194349.png
Yay, TehUpload =] My site.

Originally Posted by VernonK View Post
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
#19
VernonK is offline VernonK
VernonK's Avatar
Status: Junior Member
Join date: Jan 2007
Location: Western Maryland
Expertise:
Software:
 
Posts: 39
iTrader: 0 / 0%
 

VernonK is on a distinguished road

Send a message via MSN to VernonK

  Old

Originally Posted by Dentafrice View Post
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
#20
Dentafrice is offline Dentafrice
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
 
Posts: 23
iTrader: 0 / 0%
 

Dentafrice is on a distinguished road

  Old

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

Closed Thread  
Page 2 of 3 < 1 2 3 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed