NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page location field not updating

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 07-09-2006, 08:37 AM THREAD STARTER               #1 (permalink)
Account Closed
Join Date: Jul 2006
Posts: 81
electricbeat is an unknown quantity at this point
 



location field not updating


When I go to my page called edit.php - to edit a profile. If i edit the location to london, when i view the profile, it goes to 0. I've checked that the field is text and not a number and I just cant see why it is going to 0.

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-2" />
<link rel="stylesheet" href="images/style.css" type="text/css" />
<title>MusicInterests</title>
</head>
<body>
    <div class="content">
        <div class="header_right">
            <div class="top_info">
                <div class="top_info_right">
                    <p><?php include("logged.php"); ?></p>                    
                </div>        
            </div>
                    
            <div class="bar">
                <ul>
                    <li class="slogan">Navigation:</li>
<?php include("navigation.php"); ?>
                
                </ul>
            </div>
        </div>
            
        <div class="logo">
            <h1><a href="#" title="The best music on the net!">Music <span class="red">Interests</span></a></h1>
            <p>What are you listening too?</p>
        </div>
        
        <div class="search_field">
          <?php include("searchform.php"); ?>
        </div>
        
        <div class="newsletter">
            <p>Subscribe for the Newsletter!</p>
        </div>
        
        <div class="subheader">
            <p><?php include("top.php"); ?></p>
        </div>
        
        <div class="left">
            <div class="left_articles">
                <h2>Search</h2>
                <p>
<?
ob_start
();
include(
"config.php");
if (
$logged[username])
{
// the user is logged in!  We continue...
if (!$_POST[update])
{
// the form hasn't been submitted.  We continue...
$profile mysql_query("SELECT * from users where username = '$logged[username]'");
$profile mysql_fetch_array($profile);

// the above lines get the information so that it can be displayed in the html form.
echo("
<form method=\"POST\">

Location:<br />
<input type=\"text\" size=\"25\" maxlength=\"25\" name=\"location\" value=\"
$profile[location]\"><br />
Email Address:<br />
<input size=\"25\"  name=\"email\" value=\"
$profile[email]\"><br />
<br />

<b>Song one</b><br>
Artist - <input size=\"25\"  name=\"artist1\" value=\"
$profile[artist1]\"> Song - <input size=\"25\"  name=\"song1\" value=\"$profile[song1]\"><br />
<b>Song two</b><br>
Artist - <input size=\"25\"  name=\"artist2\" value=\"
$profile[artist2]\"> Song - <input size=\"25\"  name=\"song2\" value=\"$profile[song2]\"><br>
<b>Song three</b><br>
Artist - <input size=\"25\"  name=\"artist3\" value=\"
$profile[artist3]\"> Song - <input size=\"25\"  name=\"song3\" value=\"$profile[song3]\"><br>
<b>Song four</b><br>
Artist - <input size=\"25\"  name=\"artist4\" value=\"
$profile[artist4]\"> Song - <input size=\"25\"  name=\"song4\" value=\"$profile[song4]\"><br>
<b>Song five</b><br>
Artist - <input size=\"25\"  name=\"artist5\" value=\"
$profile[artist5]\"> Song - <input size=\"25\"  name=\"song5\" value=\"$profile[song5]\"><br>
<b>Song six</b><br>
Artist - <input size=\"25\"  name=\"artist6\" value=\"
$profile[artist6]\"> Song - <input size=\"25\"  name=\"song6\" value=\"$profile[song6]\"><br>
<b>Song seven</b><br>
Artist - <input size=\"25\"  name=\"artist7\" value=\"
$profile[artist7]\"> Song - <input size=\"25\"  name=\"song7\" value=\"$profile[song7]\"><br>
<b>Song eight</b><br>
Artist - <input size=\"25\"  name=\"artist8\" value=\"
$profile[artist8]\"> Song - <input size=\"25\"  name=\"song8\" value=\"$profile[song8]\"><br>
<b>Song nine</b><br>
Artist - <input size=\"25\"  name=\"artist9\" value=\"
$profile[artist9]\"> Song - <input size=\"25\"  name=\"song9\" value=\"$profile[song9]\"><br>
<b>Song ten</b><br>
Artist - <input size=\"25\"  name=\"artist10\" value=\"
$profile[artist10]\"> Song - <input size=\"25\"  name=\"song10\" value=\"$profile[song10]\"><br>

<br /><input type=\"submit\" name=\"update\" value=\"Update\">

</form>
"
);
}
else
{

$email htmlspecialchars($_POST[email]);
    if (!
eregi ('^[A-Za-z0-9\._-]+@([A-Za-z][A-Za-z0-9-]{1,62})(\.[A-Za-z][A-Za-z0-9-]{1,62})+$'stripslashes(trim($email)))){
                
$problem TRUE;
            }
            if (!
$problem){
$location htmlspecialchars($_POST[location]);
$artist1 htmlspecialchars($_POST[artist1]);
$song1 htmlspecialchars($_POST[song1]);
$artist2 htmlspecialchars($_POST[artist2]);
$song2 htmlspecialchars($_POST[song2]);
$artist3 htmlspecialchars($_POST[artist3]);
$song3 htmlspecialchars($_POST[song3]);
$artist4 htmlspecialchars($_POST[artist4]);
????: NamePros.com http://www.namepros.com/programming/215111-location-field-not-updating.html
$song4 htmlspecialchars($_POST[song4]);
$artist5 htmlspecialchars($_POST[artist5]);
$song5 htmlspecialchars($_POST[song5]);
$artist6 htmlspecialchars($_POST[artist6]);
$song6 htmlspecialchars($_POST[song6]);
$artist7 htmlspecialchars($_POST[artist4]);
$song7 htmlspecialchars($_POST[song7]);
$artist8 htmlspecialchars($_POST[artist8]);
$song8 htmlspecialchars($_POST[song8]);
$artist9 htmlspecialchars($_POST[artist9]);
$song9 htmlspecialchars($_POST[song9]);
$artist10 htmlspecialchars($_POST[artist10]);
$song10 htmlspecialchars($_POST[song10]);

if(
$location=NULL|$email==NULL|$artist1==NULL|$song1==NULL|$artist2==NULL|$son  g2==NULL|$artist3==NULL|$song3==NULL|$artist4==NULL|$song4==NULL|$artist5==NUL  L|$song5==NULL|$artist6==NULL|$song6==NULL|$artist7==NULL|$song7==NULL|$artist  8==NULL|$song8==NULL|$artist9==NULL|$song9==NULL|$artist10==NULL|$song10==NULL  ) {
//checks to make sure no fields were left blank
echo "<font color=\"red\">A field was left blank or you did not enter all your songs.<br /><br />
<a href=\"#\" onClick=\"history.go(-1)\">Click here to go back</a>
</font>
"
;
}else{


// the above lines get rid of all html.

echo ("Your profile has been updated!");
$update mysql_query("Update users set email = '$email',
location = '
$location', artist1 = '$artist1', song1 = '$song1', artist2 = '$artist2', song2 = '$song2', artist3 = '$artist3', song3 = '$song3', artist4 = '$artist4', song4 = '$song4', artist5 = '$artist5', song5 = '$song5', artist6 = '$artist6', song6 = '$song6', artist7 = '$artist7', song7 = '$song7', artist8 = '$artist8', song8 = '$song8', artist9 = '$artist9', song9 = '$song9', artist10 = '$artist10', song10 = '$song10' where username = '$logged[username]'");
                }
            }else{
                echo 
'Invalid Email';
????: NamePros.com http://www.namepros.com/showthread.php?t=215111
            }
        }
}else{
// updates the information in the database.
}
?>
</p>
            </div>
        </div>    
        <div class="right">
                        
            <div class="rt"></div>
            <div class="right_articles">
                <p><b>Most viewed</b><br />The most viewed tool allows you too find the 30 most viewed profiles on musicinterests!</p>
            </div>
            <div class="rt"></div>
            <div class="right_articles">
                <p><b>Links</b><br />
                <?php include("links.php"); ?></p>
            </div>
            <div class="rt"></div>
            <div class="right_articles">
                <p><?php include("sponsor.php"); ?></p>
            </div>
        </div>    
        <div class="footer">
            <p><?php include("footer.php"); ?></p>
        </div>
    </div>
</body>
</html>
electricbeat is offline  
Old 07-09-2006, 08:51 AM   #2 (permalink)
NamePros Member
 
CreedFeed's Avatar
Join Date: Apr 2006
Posts: 186
CreedFeed is on a distinguished road
 



What is the field type? Once in awhile when I have problems with a script I will output variables as the page runs to see where the var is changing. For example, I'll add

Code:
echo "<h1>Before submit = ".$_POST['location']."</h1>";
in various places in the code. That way you can see where the location variable is changing (substitute variable names in there as your script progresses). So in your code for example I would add the output code right before you issue your SQL query to see what the variable is before updating your database row. If the variable is correct, then it has to be a problem with your actual database or error in your query string resulting it to update to 0.
CreedFeed is offline  
Closed Thread


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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 02:56 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger