PDA

View Full Version : can you take a look at this code...


Dimava
Thu 16th May '02, 9:10pm
<html>
<head>
<title>News Submission</title>
</head>
<?php include("../templates/header.htm"); ?>
<?
require("config.php");

if ( $date == "") {
// input form
include("templates/news_input.php");
}

if ( $date != "") {
// processing unit
$link = mysql_pconnect( "localhost", $user, $pass );
mysql_select_db( $db, $link );

function uploadProg($filename1,$filename1_name){
$destination="../images/newsimages";
copy($filename1,$destination."/".$filename1_name);
include("templates/uploaded.php");
}

function main(){
}

switch ($action) {
case "uploadProg":
if ($filename1=="none") {
echo("<h1>No File Selected....</h1>");
break;
}
uploadProg($filename1,$filename1_name);
break;
default:
main();
break;
}

$image = ("images/newsimages/".$filename1_name);



$query = "INSERT INTO 'news' ( 'id', 'name', 'date', 'username', 'description', 'source', 'image' ) values( '', $name, $date, $username, $description, $source, $image )";
mysql_query($query);
include("templates/news_added.php");
}

include("../templates/footer.htm");
?>
</html>


I get the picture to upload, but I can't get it to save the stuff into the database

thanks

Dimava

scoutt
Fri 17th May '02, 11:51am
you don't need the ' around the first part of the insert. you need then on the variables


$query = "INSERT INTO news ( id, name, date, username, description, source, image ) values( '', '$name', '$date', '$username', '$description', '$source', '$image' )";

also what verison of php are you using? you might have to use the super global $_REQUEST[]

Dimava
Fri 17th May '02, 3:26pm
thanks, thats just what i needed