My PHP/SQL script does not work on the new table I cloned but works perfectly fine on the table I copied the new table from using this:
SELECT * INTO slide FROM news
Here's my insert form:
<div class="the-form" style="width:100%;">
<form class="userTrans" method="post">
<input type="hidden" name="act_userTrans" value="__insertNews_">
<p>
<label for="title">Title:</label>
<input type="text" name="title" id="title">
</p>
<p>
<label for="type">News Type:</label>
<input type="text" name="type" id="type">
</p>
<p>
<label for="autor">Author:</label>
<input type="text" name="autor" id="autor">
</p>
<input type="text" name="text2" id="text2">
<p class="form-footer">
<button class="button userTrans" style="background-color: #DB6D1D;">Publish News</button>
</p>
</form>
</div>
And here's my edit form:
<div class="the-form" style="width:100%;">
<form class="userTrans" method="post">
<input type="hidden" name="act_userTrans" value="__updateNews_">
<p>
<label for="title">Title:</label>
<input type="text" name="title" id="title" value="<?=$edit[title]?>"/>
</p>
<p>
<label for="type">News Type:</label>
<input type="text" name="type" id="type" value="<?=$edit[type]?>"/>
</p>
<p>
<label for="autor">Author:</label>
<input type="text" name="autor" id="autor" value="<?=$edit[autor]?>"/>
</p>
<input type="text" name="text2" id="text2" value="">
<input type="hidden" name="id" value="<?=$edit[id]?>">
<p class="form-footer">
<button class="button userTrans" style="background-color: #DB6D1D;">Publish News</button>
</p>
</form>
</div>
Here's my process for updating & inserting my two different forms:
if($activity == "__insertNews_")
{
$title = htmlspecialchars($_POST['title']);
$autor = htmlspecialchars($_POST['autor']);
$type = (int)$_POST['type'];
if(empty($_POST['type']) || empty($_POST['autor']) || empty($_POST['title']) || empty($_POST['text2']))
{
echo response(0,'Fill up all the forms.',0);
exit();
}
//echo $_POST[text2];
$news = mssql_query("INSERT INTO DB1.dbo.news (title,text,type,autor) VALUES ('$title','$_POST[text2]','$type','$autor') ");
echo response(1,'Publishing '.$title.' success!',0);
}
if($activity == "__updateNews_")
{
$title = htmlspecialchars($_POST['title']);
$autor = htmlspecialchars($_POST['autor']);
if(empty($_POST['autor']) || empty($_POST['title']))
{
echo response(0,'Fill up all the forms.',0);
exit();
}
$news = mssql_query("UPDATE DB1.dbo.news set title='$title',autor='$autor' WHERE id='$id' ");
echo response(1,'Editing '.$title.' success!',0);
}
So using those scripts above and i was able to INSERT & UPDATE any contents on dbo.news
However, when I change DB1.dbo.news to the new table I created ( DB1.dbo.slide ) the "INSERT" won't work.
I tried to add data using the same form & processing script, the "INSERT" won't work on dbo.slide but when I test it on dbo.news I'm able to insert data. I also tested UPDATE, and it's working on both dbo.slide and dbo.news.
Now I'm wondering, why is it that the SAME script for INSERT is working on other table but it does not work on the new one (dbo.slide). It's literally confusing because I did not change any codes, I just changed the table I'm inserting the data into and the INSERT function stopped working.
What's the best way to debug this and find out what is causing this issue?