Jump to content

What's wrong with this query?


soltek

Recommended Posts

Hey!

 

I've spent an hour and a haldf - lulz indeed - trying to figure out what's wrong with my code, but I couldnt.

Could you take a look?

 

<? 
include("db.php");
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
$id = (int)$_GET['id']; 
$res = "SELECT * FROM tvshows WHERE id = '$id'";
$result = mysql_query($res) or die(mysql_error());

while($row = mysql_fetch_array($result)){
  $show = $row[show];
  $episode = $row[episode];
  $title = $row[title];
  $airdate = $row[airdate];
  $numero = $row[id];
}
?>
</head>
<body>
<div style="background-color: #b1b2b2;width:300px;float:left;">
<h1>Adding entries:</h1>
<div id="preview"></div>
        <div id="formbox"> 

            <form name="form" id="form" action="submit-edit.php" method="post">

                <ul id="ngothastyle3">

                    <li>

                        <label>Show</label>
                       <input type="hidden" name="numero" class="" value="<? echo $numero; ?>" maxlength="40" />
                        <input type="text" name="show" class="" value="<? echo $show; ?>" maxlength="40" />

                    </li>

                    <li>

                        <label>Episode</label>

                        <input type="text" name="episode" class="" value="<? echo $episode; ?>" maxlength="40" />

                    </li>

                    <li>

                        <label>Title</label>

                        <input type="text" name="title" class="" value="<? echo $title; ?>" maxlength="40" />

                    </li>

                    <li>

                        <label>Airdate</label>

                        <input type="text" name="airdate" class="" value="<? echo $airdate; ?>" maxlength="40" />


                    </li>

                    <li>

                        <label> </label>

                        <input type="submit" value="Submit">

                    </li>

                </ul>

            </form>           
 </div> 

</div>


<div style="clear:both;"></div>
</body>
</html>

 

 

Edit file:

 

<?php
include("db.php");
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$numero= (int)$_POST['numero'];
$show=mysql_real_escape_string($_POST['show']);
$episode=mysql_real_escape_string($_POST['episode']);
$title=mysql_real_escape_string($_POST['title']);
$airdate=mysql_real_escape_string($_POST['airdate']);
if(strlen($episode)>0)
{

///THIS PART ///
$sql = "UPDATE tvshows SET id = '" . $numero . "', show = '" . $show . "', episode = '" . $episode . "', title = '" . $title . "', airdate = '" . $airdate . "' WHERE id = '" . $numero . "'";
/////

echo "<h2>Thank You !</h2>";
echo "Job done";
}else{
echo "hmmm... something is wrong.";
}
}
?>

 

I've been messing around and I think the problem is somewhere in the query in red, the bold part.

If you could give me a hand, I'll drink for you  :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.