Jump to content

dark22horse

Members
  • Posts

    64
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dark22horse's Achievements

Member

Member (2/5)

0

Reputation

  1. Cheers guys, can u believe I have been looking at that for 1.5 hours. changing little bits, but didnt notice it! My other problem has been resolved!
  2. K cheers, that cleared that problem up. However when I update the name and nickname get wiped, even though something is there when I try to update them.
  3. Hi guys, Just trying a simple update form, but its not working. Parse error: syntax error, unexpected T_VARIABLE, expecting ']' in C:\Program Files\xampp\htdocs\Poker\uploader3.php on line 26 <html> <head> <title>Uploaded</title> </head> <body style="margin:0;"> <? require_once("mysql_config.php"); $id = $_POST['id']; $name=$_POST['name']; $nickname=$_POST['nickname']; $first=$_POST['first']; $second=$_POST['second']; $buy_in=$_POST['buy_in']; $won=$_POST['won']; $profit_loss=$_POST["profit_loss"]; $played=$_POST['played']; $win_ratio=$_POST['win_ratio']; $top_2_ratio=$_POST['top_2_ratio"]; $average_return=$_POST["average_return"]; **problem here ** $sql_string = "UPDATE player SET name='$name', nickname='$nickname', first='$first', second='$second', buy_in='$buy_in', won='$won', profit_loss='$profit_loss', played='$played', win_ratio='$win_ratio', top_2_ratio='$top_2_ratio', average_return='$average_return'"." WHERE id='$id'"; mysql_query($sql_string) OR die(mysql_error()); $ok = mysql_query($sql_string); if($ok){ echo "<h2>all is good, upload another</h2>"; } else { echo "<h2>check the string".$sql_string."</h2>"; } ?> <a href="update.php"> Click here to update another player</a> </BODY> </html>
  4. cheers guys, it had plesk or something, found it on there! I guess after hours working on it, the simple things are always complicated!
  5. how would i change the chmod in ftp then? that is how i am upping the site?
  6. where would I do this on phpadmin? or another one?
  7. Hi guys, I have run into a bit of a problem, on my sql server a script runs and updates everything, but when I put it live, it hasnt <html> <head> <title>Uploaded</title> <link href="images/CliftonMotors.css" rel="stylesheet" type="text/css"> </head> <body style="margin:0;"> <TABLE WIDTH=775 height="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0> <TR> <TD height="89" COLSPAN=2> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="374"><img src="images/toplogo2.gif" width=374 height=89 alt=""></td> <td> <TABLE width="401" BORDER=0 CELLPADDING=0 CELLSPACING=0> <TR> <TD COLSPAN=11> <IMG SRC="images/jd_b038_02.gif" WIDTH=401 HEIGHT=40 ALT=""></TD> </TR> <TR> <TD><a href="index.php"><IMG SRC="images/home.gif" ALT="" WIDTH=51 HEIGHT=49 border="0"></a></TD> <TD><IMG SRC="images/navspacer2.gif" WIDTH=1 HEIGHT=49 ALT=""></TD> <TD><a href="Cars.php"><IMG SRC="images/CliftonMotorSales.gif" ALT="" WIDTH=121 HEIGHT=49 border="0"></a></TD> <TD><IMG SRC="images/navspacer2.gif" WIDTH=1 HEIGHT=49 ALT=""></TD> <TD><a href="Repairs.html"><IMG SRC="images/CliftonMotors.gif" ALT="" WIDTH=92 HEIGHT=49 border="0"></a></TD> <TD><IMG SRC="images/navspacer2.gif" WIDTH=1 HEIGHT=49 ALT=""></TD> <TD><a href="Location.html"><IMG SRC="images/location.gif" ALT="" WIDTH=66 HEIGHT=49 border="0"></a></TD> <TD><IMG SRC="images/navspacer2.gif" WIDTH=1 HEIGHT=49 ALT=""></TD> <TD><a href="Feedback.html"><IMG SRC="images/feedback.gif" ALT="" WIDTH=66 HEIGHT=49 border="0"></a></TD> <TD><IMG SRC="images/navspacer2.gif" WIDTH=1 HEIGHT=49 ALT=""></TD> </TR> </TABLE></td> </tr> </table></TD> </TR> <TR> <TD valign="top" background="images/pixi_1.gif"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td><TABLE width="553" BORDER=0 CELLPADDING=0 CELLSPACING=0> </TABLE></td> </tr> <tr> <td height="18" background="images/pixi_grey.gif" style="padding-left:40;padding-top:5;padding-right:35;"><h1> Updating Stock</h1></td> </tr> <tr> <td style="padding-left:40;padding-top:25; padding-right:35;padding-bottom:25;"> <? 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']); $id = $_POST['id']; $price = $_POST['price']; $key_description = $_POST['key_description']; $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); [color=red]if(move_uploaded_file($_FILES['photo']['tmp_name'], $target_path)) { [/color] $sql_string = "UPDATE car SET price='$price', key_description='$key_description', 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()); $ok = mysql_query($sql_string); if($ok){ echo "<h2>all is good, upload another</h2>"; } else { echo "<h2>check the string".$sql_string."</h2>"; } } else{ $sql_string = "UPDATE car SET price='$price', key_description='$key_description', description='$description', car_of_the_week='$car_of_the_week', status1='$status1'"." WHERE id='$id'"; $ok = mysql_query($sql_string); if($ok){ echo "<h2>The car has been updated succesfully</h2>"; } else { echo "<h2>error updating car</h2>"; } } ?> <a href="update.php"> Click here to update another car </a> </tr> </table></TD> </TR> <TR> <TD background="images/pixi_2.gif" height="37" COLSPAN=2 style="padding-left:40;">© Copyright 2007. Clifton Motors. </TD> </TR> <TR> <TD height="7" COLSPAN=2 background="images/pixi_grey.gif"><IMG SRC="images/spacer.gif" WIDTH=775 HEIGHT=7 ALT=""></TD> </TR> </TABLE> </BODY> </html> I have highlighted the error Warning: move_uploaded_file(uploads/clio2.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /var/www/vhosts/clifton-motors.co.uk/httpdocs/uploader3.php on line 78 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php1JHaqH' to 'uploads/clio2.jpg' in /var/www/vhosts/clifton-motors.co.uk/httpdocs/uploader3.php on line 78 the errors im getting
  8. From the books I have read, it says do this because it makes searching easy? is that correct? or shall I just stick it in the house table?
  9. Hi guys, Im starting a new project, just to help me get to grips with php and mysql! I was hoping that some one could check my table designs, as im not sure they are quite right. House// House ID - Auto inc + unique photo ID User ID summary tenure Type ID Price bedrooms Reception rooms bathrooms county town/city condition floor plan details post code location type chain features map User// user ID Username password email photos// Photo ID photo type// Type ID Type Is this normalised? I think I have done some of it, but not done this for a while, so cant quite remember!
  10. Cheers for your help guys. I got it working sort of! I have put in a if statement, where it detects if a file has been uploaded. If it has then I run the script to input the file. else it doesnt update the pictures. My only problem now, is that i need to do it for multiple photos fields, as I have 4. Anyone suggest a way, without writing hundreds of if statements? <? 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); $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{ $sql_string = "UPDATE car SET price='$price', description='$description', car_of_the_week='$car_of_the_week', status1='$status1'"." WHERE id='$id'"; } ?>
  11. no didnt work. I have no problem updating the information if the user wants to update the photos, but If they dont then it doesnt work. I want them to just be able to upload the text lines, if they dont need to update the photos.
  12. K here it is <? print_r($_GET); $id=$_GET['id']; //connect to mysql //change user and password to your mySQL name and password mysql_connect("localhost","root",""); //select which database you want to edit mysql_select_db("car"); $query = "select * from car WHERE id = '$id' "; $result = mysql_query($query); $num = mysql_num_rows($result); $i = 0; while ($i<$num) { $row= mysql_fetch_array($result, MYSQL_ASSOC); $price= $row['price']; $description= $row['description']; $photo= $row['photo']; $photo1= $row['photo1']; $photo2= $row['photo2']; $photo3= $row['photo3']; $car_of_the_week= $row['car_of_the_week']; $status1= $row['status1']; $id=$_GET['id']; echo "$photo"; $target_path = "uploads/"; $photo = $target_path . basename( $_FILES['photo']['name']); ?> <html> <body> <form enctype="multipart/form-data" action="uploader3.php" method="POST"> <table width='100%' border='1'> <tr> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> <td>ID</td> <td><input type='text' name='id' value='<?php print "$id";?>'> </td> <td>Price</td> <td><input type='text' name='price' value='<?php print "$price";?>'> </td> <td>Description</td> <td><input type='text' name='description' value='<?php echo "$description";?>'> </td> <td>Photo</td> <td><input name="photo" type="file" value='<?php print "$photo";?>'> </td> <td>Photo1</td> <td><input name="photo1" type="file" /></td> <td>Photo2</td> <td><input name="photo2" type="file" /></td> <td><input name="photo3" type="file" /></td> <td>Car of the Week</td> <td><input type="text" name="car_of_the_week" length="20" value ='<?php print "$car_of_the_week";?>'></td> <td>Status</td> <td><input type="text" name="status1" length="20" value = "jjjj"/></td> <td><input type="submit" value="Upload Files" /></td> </tr> </table> </form> <? ++$i; } ?> </BODY> </html> And uploader3.php <? 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!"; } ?>
  13. It didnt work I think it may be because the file array comes up with this, so it is not empty, [photo] => Array ( [name] => [type] => [tmp_name] => [error] => 4 => 0
  14. 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!"; } ?>
  15. 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!"; } ?>
×
×
  • 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.