Unstoppable Domains

Cannot find anything wrong with this at all! Please Help

Spacemail by SpaceshipSpacemail by Spaceship
Watch

PoorDoggie

Soon to be RICHdoggie!VIP Member
Impact
18
I bet its really simple. Anyway the message that pops up is "Something Wrong" which means the mysql query isn't working, but I cannot find anything wrong with anything. :(

Please help! :'(

PHP:
<?php

// edit.php! :) woo!

include "../../config.php";

if($_POST['url']){
  // posted the form...
  $id = $_REQUEST['id'];
  $name = $_POST['name'];
  $url = $_POST['url'];
  $category = $_POST['category'];
  $description = $_POST['description'];
  $keywords = $_POST['keywords'];
  $image = $_POST['image'];
  $tallbanner = $_POST['tall_banner'];
  $longbanner = $_POST['long_banner'];

  $sql = "UPDATE pd_shops SET name='$name', description='$description', keywords='$keywords', url='$url', category='$category', image='$image', tall_banner='$tallbanner', wide_banner='$widebanner' WHERE id='$id'";
  $result = mysql_query($sql);
  if($result){
    $message = "Successfully Changed!";
  }
  else{
    $message = "Something Wrong! :-(";
  }
}

if(isset($_REQUEST['id']) && !isset($_POST['id'])){
  $id = $_REQUEST['id'];
}

$sql = "SELECT * FROM pd_shops WHERE id='$id'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);

$name = $row['name'];
$url = $row['url'];
$category = $row['category'];
$description = $row['description'];
$keywords = $row['keywords'];
$image = $row['image'];
$tallbanner = $row['tall_banner'];
$widebanner = $row['wide_banner'];

if(isset($message)){
  $script = "yes";
}
else{
  $script = "no";
}

?>
<html>
  <head>
    <title>Admin Page</title>
    <style>
      body{
        font-family: arial, tahoma, serif;
      }
    </style>
    <?php
    
      if($script == "yes"){
        echo "<script>
            alert('$message');
          </script>";
      }

    ?>
  </head>
  <body>
    <table>
      <tr>
        <td colspan="2" align="center"><b>Admin Center</b></td>
      </tr>
      <tr>
        <td width="200"><a href="../categories/index.php">Categories</a></td>
        <td rowspan="2">
          <form method="post" action="edit.php?id=<?php echo $id; ?>">
            <table>
              <tr>
                <td colspan="2" align="center"><b>EDIT "<?php echo $name; ?>"</b></td>
              </tr>
              <tr>
                <td>Name:</td>
                <td><input name="name" value="<?php echo $name; ?>" /></td>
              </tr>
              <tr>
                <td>Url:</td>
                <td><input name="url" value="<?php echo $url; ?>" /> - <a href="<?php echo $url; ?>" target="_blank">OPEN IN NEW WINDOW</a></td>
              </tr>
              <tr>
                <td>Category:</td>
                <td>
                  <?php

                    // this is where the clever bit comes in... la la la
                    echo '<select name="category">';
                    $sql = "SELECT * FROM pd_categories ORDER BY name ASC";
                    $result = mysql_query($sql);
                    while($row = mysql_fetch_array($result)){
                      echo '<option value="';
                      echo $row['id'];
                      if($category == $row['id']){
                        echo '" selected>';
                      }
                      else{
                        echo '">';
                      }
                      echo $row['name'];
                      echo '</option>';
                    }
                    echo '</select>';

                  ?>
                </td>
              </tr>
              <tr>
                <td>Description:</td>
                <td><textarea name="description"><?php echo $description; ?></textarea></td>
              </tr>
              <tr>
                <td>Keywords:</td>
                <td><input name="keywords" value="<?php echo $keywords; ?>" /></td>
              </tr>
              <tr>
                <td>Image:</td>
                <td><input name="image" value="<?php echo $image; ?>" /></td>
              </tr>
              <tr>
                <td></td>
                <td><?php
                  if(!empty($image)){
                    echo '<img src="'.$image.'" />';
                  }
                  else{
                    echo '<font color="red">NO IMAGE!</font>';
                  }
                ?></td>
              </tr>
              <tr>
                <td>Tall Banner</td>
                <td><input name="tall_banner" value="<?php echo $tallbanner; ?>" /></td>
              </tr>
              <tr>
                <td></td>
                <td><?php
                  if(!empty($tallbanner)){
                    echo '<img src="'.$tallbanner.'" />';
                  }
                  else{
                    echo '<font color="red">NO TALL BANNER!</font>';
                  }
                ?></td>
              </tr>
              <tr>
                <td>Wide Banner</td>
                <td><input name="long_banner" value="<?php echo $longbanner; ?>" /></td>
              </tr>
              <tr>
                <td></td>
                <td><?php
                  if(!empty($longbanner)){
                    echo '<img src="'.$longbanner.'" />';
                  }
                  else{
                    echo '<font color="red">NO WIDE BANNER!</font>';
                  }
                ?></td>
              </tr>
              <tr>
                <td></td>
                <td><input type="hidden" name="id" value="<?php echo $id; ?>" /><input type="submit" value="Submit" /></td>
              </tr>
            </table>
          </form>
        </td>
      </tr>
      <tr>
        <td><a href="index.php">Shops</a></td>
      </tr>
    </table>
  </body>
</html>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
You sure the table names are correct?
 
0
•••
echo the $sql variable, paste into the 'sql' window of phpmyadmin and you'll see instantly what the problem is.

Lux
 
0
•••
You need to first put where it says something wrong :( you need to add code to output your error message, because if you don't know what is wrong it is hard to fix it.
 
0
•••
PHP:
  $sql = "UPDATE pd_shops SET name='".$name."', description='".$description."', keywords='".$keywords."', url='".$url."', category='".$category."', image='".$image."', tall_banner='".$tallbanner."', wide_banner='".$widebanner."' WHERE id='".$id."'";
  $result = mysql_query($sql);
  if(!$result){
    $message = "Error: Couldn't update DB";
  }
  else{
    $message = "Successfully Changed!";
  }
}

Try that.

iNod
 
0
•••
thanks for all the help. Will try outputting the sql code and trying it in phpmyadmin.
 
0
•••
heh! :( forgot I changed one of the column headings :red: feel so stupid! :(

Thanks everyone! :)
 
0
•••
lol. No Problem. Happens to the best of us. Even myself sometimes I forget to do something with SQL Querys and it drives me nuts. I just ask on here and look at it and realise what I did wrong.

Sometimes I make a new topic but while writing it I figure out what I did wrong as well..

But what ever works :)

iNod
 
0
•••
To get an error message like phpmyadmin gives you just add in mySQL_error() into your query code. So you should have this:

mysql_query($query) or die ( mySQL_error());
 
0
•••
paaaaaaaaaa said:
To get an error message like phpmyadmin gives you just add in mySQL_error() into your query code. So you should have this:

mysql_query($query) or die ( mySQL_error());
yes but usually, I always get my queries right, or "Something Wrong" means that I look through, and spot a variable I have messed up or something.

Thanks everyone again! :)
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back