CREATE TABLE `s_news` (
id int(10) NOT NULL,
news_id int(10) NOT NULL,
username varchar(10) NOT NULL,
newscat varchar(10) NOT NULL,
img varchar(100) NOT NULL,
newstitle varchar(225) NOT NULL,
fullnews longtext NOT NULL,
datetime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)
ALTER TABLE videos
ADD PRIMARY KEY (id);
<?php
if(isset($_POST['post']))
{
$p_username = $suname;
$p_img = $_FILES['img']['name'];
$p_ttle = $_POST['posttitle'];
$p_cat = $_POST['cat'];
$p_title = htmlspecialchars($p_ttle);
$p_po = $_POST['fullpost'];
$p_p = htmlspecialchars($p_po);
$p_id = rand(0000,9999);
$query1 = mysql_query("INSERT INTO `s_news`(news_id,username,newscat,img,newstitle,fullnews)VALUES('$p_id','$p_username','$p_cat','$p_img','$p_title','$p_p')");
if($query1){
$newname_image = $p_id.".jpg";
move_uploaded_file($_FILES['img']['tmp_name'],'../newspic/'.$newname_image);
$OUTPUT_MESSAGE = "Your news is been uploaded....Thanks";
}
else
{
$OUTPUT_MESSAGE = "We have a problem uploading you post. See Admin";
}
}
?>
I am new to php, I wrote this little code to upload some data. I've tried it in my xammp server, it works perfectly as I want it to. When I uploaded it to an online server, the SELECT query works fine but the INSERT query does not work. It does not insert at all.
Aucun commentaire:
Enregistrer un commentaire