Jump to content

[SOLVED] Displaying information in a update form


dark22horse

Recommended Posts

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

I am giving up trying to put the file into the file type.  I am trying to write an if statement. 

It hasnt worked, but this is what I am trying to do.

 

If $photo = error4 (no file has been uploaded)

Run the script that doesnt include the upload files

 

else Run the script that includes the upload file. 

 

I have attempted the script below, but it doesnt work. 

 

 

 

<?
require_once("mysql_config.php");

$target_path = $target_path . basename( $_FILES['photo']['name']); 
$_FILES['photo']['tmp_name'];

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['photo']['name']); 


if(move_uploaded_file($_FILES['photo']['tmp_name'], $target_path)) {

$id = $_POST['id'];
$price = $_POST['price'];
$description = $_POST['description'];
$photo = $_FILES['photo']['name'];
$photo1 = $_FILES['photo1']['name'];
$photo2 = $_FILES['photo2']['name'];
$photo3 = $_FILES['photo3']['name'];
$car_of_the_week = $_POST['car_of_the_week'];
$status1 = $_POST['status1'];

$id = mysql_real_escape_string($id);
$price = mysql_real_escape_string($price);
$description = mysql_real_escape_string($description);
$car_of_the_week = mysql_real_escape_string(car_of_the_week);
$status1 = mysql_real_escape_string($status1);


if($photo=""){
      $sql_string = "UPDATE car SET price='$price', description='$description', car_of_the_week='$car_of_the_week', status1='$status1'"." WHERE id='$id'";

} else {
      $sql_string = "UPDATE car SET price='$price', description='$description', photo='$photo', photo1='$photo1', photo2='$photo2', photo3='$photo3', car_of_the_week='$car_of_the_week', status1='$status1'"." WHERE id='$id'";
}
mysql_query($sql_string) OR die(mysql_error());

echo "<br/>SQL STRING WE WANT TO RUN: ".$sql_string;

echo "db connection: ".$dbconn;
echo "table connection: ".$table;

$ok = mysql_query($sql_string);

echo "OK: ".$ok;


if($ok){
	echo "<h2>all is good, upload another</h2>";
} else {
	echo "<h2>check the string".$sql_string."</h2>";
}
} else{

echo "There was an error uploading the file, please try again!";

}




?>

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.