Jump to content

Darkwoods

Members
  • Posts

    88
  • Joined

  • Last visited

Everything posted by Darkwoods

  1. here is error message im getting Problem with the query: INSERT INTO `changeimage` VALUES ('testname','helix.jpg') Column count doesn't match value count at row 1
  2. in my database i just have 3 column id, name and photo the problem is with my insert into code is when i remove the NOW(), it wont send data to the database the VALUES should only be ('$name','$pic') so i have no idea what im doing wrong! here is the full codes <?php //This is the directory where images will be saved $target = "uploads/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $name=$_POST['name']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("localhost", "**", "**") or die(mysql_error()) ; mysql_select_db("**") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `changeimage` VALUES ('$name',NOW(),'$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> <form enctype="multipart/form-data" action="uploadchangeimage.php" method="POST"> Name: <input type="text" name="name"><br> Photo: <input type="file" name="photo"><br> <input type="submit" value="Add"> </form>
  3. hey.. can anyone that check what i have typed wrong in this code mysql_query("INSERT INTO `changeimage` VALUES ('$name','$pic')") ; it is not sending the data to the database but if i write this way it works fine but the now date shows up in the name column mysql_query("INSERT INTO `changeimage` VALUES ('$name',NOW(),'$pic')") ;
  4. hi i have been looking the whole day on how i can do file upload all the tutorials i get are not working for some reason or to complicated to intergate with my form... i will be adding 2 upload fields one for images and the other one for any type of files (large files) please if you can help... it would be great im so tired of searching on google here is were i want to have my upload form <?php include "inc/header.php"; if(isset($_POST['submit'])) {//begin of if($submit). //global variables $title_en = $_POST['title_en']; $title_ar = $_POST['title_ar']; $en = $_POST['en']; $ar = $_POST['ar']; $cat = $_POST['cat']; //check if (title) field is empty then print error message. if(!$title_en){ //this means If the title is really empty. echo "Error: News title is a required field. Please fill it."; exit(); //exit the script and don't do anything else. }// end of ifdtime //run the query which adds the data gathered from the form into the database $result = mysql_query("INSERT INTO contents (title_en, title_ar, dtime, en, ar, cat) VALUES ('$title_en','$title_ar',NOW(),'$en','$ar','$cat')",$connect); //print success message. echo "<b>Thank you! data added Successfully!"; echo "<meta http-equiv=Refresh content=2;url=index.php>"; }//end of if($submit). // If the form has not been submitted, display it! else {//begin of else ?> <h3>::Add News</h3> <form method="post" action="<?php echo $_SERVER[php_SELF] ?>" enctype="multipart/form-data"> <table border="0" cellspacing="4" cellpadding="4"> <tr> <td>Select Category:</td> <td colspan="2"><select name="cat"><?php $sql = 'SELECT DISTINCT `catname` from `categories`'; $result = @mysql_query($sql,$connect); while ($row = @mysql_fetch_assoc($result)) { echo '<option value="'.$row['id'].'">'.$row['catname'].'</option>'; } ?> </td> </tr> <tr> <td>Title:</td> <td ><input name="title_en" size="40" maxlength="255"></td> <td><input name="title_ar" size="40" maxlength="255"></td> </tr> <tr> <td>Content:</td> <td><textarea name="eng" rows="7" cols="30"></textarea></td> <td><textarea name="ar" rows="7" cols="30"></textarea></td> </tr> <tr> <td colspan="3" class="submit"><input type="submit" name="submit" value="Submit"></td> </tr> </table> </form> <?php }//end of else include "inc/footer.php"; ?> as for the view page i was thinking to have it in this way echo file link only if a file have been uploaded echo image only if an image have been uploaded
  5. what i ment for example to echo 'www.link.com/file.com/whatever.zip'";
  6. hi im trying to intergate with my curently form an simple file upload system... what i want to do is when i upload the file i want it to send the location dir of where the file is uploaded into mmysql database would anyone please help on where to start? thank you
  7. thank you again this code made it work <select name="cat"> <?php $sql = 'SELECT DISTINCT `id`, `catname` from `categories`'; $result = @mysql_query($sql,$connect); while ($row = @mysql_fetch_array($result)) { $selected = ($cat == $row['id']) ? ' selected="selected"' : ''; echo '<option value="'.$row['id'].'"'.$selected.'>'.$row['catname'].'</option>'; } ?>
  8. hi thanks.. no im not getting error the <option value="" is just empty and i would need the value to send it to the database same problem value is empty here is what im getting in HTML ass you can see the value is empty <select name="cat"> <option value="" selected="selected">Home</option><option value="" selected="selected">About Us</option>
  9. thanks guys... but the value is not working
  10. im trying on my edit page to put a select drop down box geting the value and data from the databse i tried this code below but not working and i knew that it wont work anyone who can help plz <select name="cat"> <?php $sql = 'SELECT DISTINCT `catname` from `categories`'; $result = @mysql_query($sql,$connect); while ($row = @mysql_fetch_assoc($result)) { echo '<option value="'.$row['cat'].'" selected="$cat">'.$row['catname'].'</option>'; } ?> here is the whole page code <?php include "inc/header.php"; $id = $_GET['id']; if(isset($_POST['submit'])) { //global variables include "inc/variables.php"; $result = mysql_query("UPDATE contents SET title_en='$title_en', title_ar='$title_ar', en='$en', ar='$ar', cat='$cat' WHERE id='$id' ",$connect); echo "<b>Your post have been added successfully"; echo "<meta http-equiv=Refresh content=2;url=index.php>"; } elseif($id) { $result = mysql_query("SELECT * FROM contents WHERE id='$id' ",$connect); while($row = mysql_fetch_assoc($result)) { $title_ar = $row["title_ar"]; $title_en = $row["title_en"]; $en = $row["en"]; $ar= $row["ar"]; $cat= $row["cat"]; ?> <br> <h3>::Edit News</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> <input type="hidden" name="id" value="<?php echo $row['id']?>"> <table border="0" cellspacing="4" cellpadding="4"> <tr> <td>Select Category:</td> <td colspan="2"> <select name="cat"> <?php $sql = 'SELECT DISTINCT `catname` from `categories`'; $result = @mysql_query($sql,$connect); while ($row = @mysql_fetch_assoc($result)) { echo '<option value="'.$row['cat'].'" selected="$cat">'.$row['catname'].'</option>'; } ?> </select></td> </tr> <tr> <td>Title:</td> <td class="title_en1"><input name="title_en" size="40" maxlength="255" value="<?php echo $title_en; ?>"></td> <td class="title_ar1"><input name="title_ar" size="40" maxlength="255" value="<?php echo $title_ar; ?>"></td> </tr> <tr> <td>Content:</td> <td class="title_en1"><textarea name="en" rows="7" cols="30"><?php echo $en; ?></textarea></td> <td class="title_ar1"><textarea name="ar" rows="7" cols="30"><?php echo $ar; ?></textarea></td> </tr> <tr> <td colspan="3" class="submit"><input type="submit" name="submit" value="Submit"></td> </tr> </table> <?php } //end of while loop }//end else include "inc/footer.php"; ?>
  11. holla... im doing a php news system it is going good so far im tottaly new to PHP so i would need help if anyone could im trying to add data from mysql the data is showing fine but i cant figure out how to make a default $cat to show up im having this code in my index.php and it show up empty if i dont use the $_GET so my question is how can i make a default $cat and if i want to use this code ''ORDER BY id DESC'' how would i do that i tried it with the code below here but it gives me error please your help would be very nice i have been trying the whole day and i can say i have learned a lot in one day but i wont learn more if i dont ask for help $cat = $_GET['cat']; //load contents from the database $sql = "SELECT * FROM `contents` where `cat`='$cat'"; $result = mysql_query($sql, $connect); while ($row = mysql_fetch_array($result)) {
  12. plz anyone help me solve my life problem you know Coppermine a great photo Gallery script i love it... it is the best but i have a little problem on the site i have i have alot of videos and songs so i want it to look nice im asking if you now how i can change the layout on categories what i want is to have diffrent layout on each categorie for example the photo category have its own layout and the audio & video its own category layout plz i need your help in this
×
×
  • 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.