Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. [quote]is there actually a way of uploading/transferring/copying a file without using the $_FILES[] array?[/quote] No, not in php.
  2. Here's a class from phpclasses.org that may help: http://www.phpclasses.org/browse/package/2759.html
  3. YOu have to actually upload the file using a form with the proper enctype.  This is not easily done via AJAX...the only method I know of uses an iframe.  AJAX is javascript, which means that it is sandboxed and can not access the file system, so AJAX can not directly upload a file.
  4. Use stripslashes (http://www.php.net/stripslashes)
  5. Echo out your query, then place it into phpMyAdmin or MySQL Query Browser and check to make sure that it is executing correctly.
  6. In the $_GET array, because you are using the same variable name for each one of your members, it will overwrite it, so you end up with only the last one. Try naming your inputs Mem[] and point[], which will create subarrays for each in the $_GET array.
  7. If register_globals is not on, then you need to change this: [code]if($Submit){[/code] to [code]if($_POST['Submit']){[/code] Which you should probably do anyway.
  8. That means your query is failing.  Probably because you commented out your query: [code]// Get records in all columns from table where column id equal in $id and put it in $result. //$result=mysql_query("select * from articles where id='$id'");[/code]
  9. You can concatenate the contents of the record with the new contents, or select it out, concatentate in php, then update with the new contents. [code]UPDATE table SET contents = CONCAT(SELECT comment FROM table WHERE id = '$id', ' ', '$newcomments') WHERE id = '$id';[/code] I think that will work, depending on your version of MySQL (> 4.0.11), although I haven't tested it.
  10. You are not exiting from the if statement in the correct place.  Change: [code]<? // Connect database. include("dbConfig.php"); if($Submit){ // Get parameters from form. $id=$_POST['id']; $title=$_POST['title']; $content=$_POST['content']; $filename=$_POST['filename']; mysql_query("update articles set title='$title', content='$content', filename='$filename' where id='$id'"); header("location:edit.php"); // Get id parameter (GET method) from edit.php $id=$_GET['id']; // Get records in all columns from table where column id equal in $id and put it in $result. //$result=mysql_query("select * from articles where id='$id'"); // Split records in $result by table rows and put them in $row. $row=mysql_fetch_assoc($result); } ?>[/code] to: [code]<?php // Connect database. include("dbConfig.php"); if($Submit){ // Get parameters from form. $id=$_POST['id']; $title=$_POST['title']; $content=$_POST['content']; $filename=$_POST['filename']; mysql_query("update articles set title='$title', content='$content', filename='$filename' where id='$id'"); header("location:edit.php"); exit; } // Get id parameter (GET method) from edit.php $id=$_GET['id']; // Get records in all columns from table where column id equal in $id and put it in $result. //$result=mysql_query("select * from articles where id='$id'"); // Split records in $result by table rows and put them in $row. $row=mysql_fetch_assoc($result); ?>[/code]
  11. Use "==" instead of "=". = is an assignment operator, == is a comparison operator.  So when your script executes, the first if statement makes $programming_lanuage equal to "html".
  12. Maybe this will help: [code]$my_items = $_POST['my_items']; $other = $_POST['other']; $other_items = $_POST['other_items']; $link = mysql_connect('localhost', $my_sql_password, $my_sql_username) or die(mysql_error()); $db_selected = mysql_select_db('osiris_thugg') or die(mysql_error()); $query = "SELECT COUNT(item_id) FROM items WHERE owner = '$user_currently_loged' AND item_id IN (" . implode(", ", $my_items) . ")"; $result = mysql_query($query) or die(mysql_error()); $count = mysql_result($result, 0); if ($count != count($my_items)) { echo"One or more of the items selected never did or does not belong to you."; Echo "selected<br>"; print_r(array_values($my_items)); echo"Owned<br>"; echo $count; exit; }[/code]
  13. assuming that that directory actually exists, it looks like you need to remove the trailing slash from the path: [code]php_value session.save_path /home/simba123/public_html/extranet/facebook.com/tmp/[/code] should be: [code]php_value session.save_path /home/simba123/public_html/extranet/facebook.com/tmp[/code]
  14. [code]foreach ($_POST as $key => $value) { if ($key != "Submit") { $$key = mysql_real_escape_string($value); } } $query = " UPDATE contactbook SET first = '$first', last = '$last', address1 = '$address1', address2 = '$address2', city = '$city', state = '$state', zip = '$zip', country = '$country', phone1 = '$phone1', phone2 = '$phone2', email1 = '$email1', email2 = '$email2', website1 = '$website1', website2 = '$website2', notes = '$notes', aim_sn= '$aim_sn', WHERE id = '$id'"; $result = mysql_query($query) or die(mysql_error());[/code]  
  15. It was an example... I would recommend using MySQL's date type.  It's the easiest to work with, especially if you are going to be doing ordering or date manipulation. Aside from that, I would go with varchar, because you are able to store a lot of different formats, including php's unix timestamp (which I think is what redarrow is saying to use INT), but you can also use YYYY-MM-DD if you chose, or any other format.
  16. [code]ALTER TABLE tablename ADD datejoined VARCHAR(255) default="";[/code] Or something similar to that. http://mysql.com/doc/refman/5.0/en/alter-table.html
  17. In order to write a file to a directory, the directory has to have write access enabled for the user that is writing to it.  Generally, if the web server is writing, then you can get away with either 744 or 764, depending on how the groups are set up, if at all. Try setting up the permissions as 764 or 777 and reducing them until you are no longer able to achieve what you want, then decide if that is too high for your comfort.
  18. To do a progress bar you have to know one of two things:  the total time the script will take to execute before it executes, so you can then take the time elapsed and compare it to the time needed and give a percentage...or you need a way to measure the progress of the script, so if the script has finished 20% of itself, then you let the user know that.
  19. I think if you do a chmod to 744 on the directory it will enable read/write/execute for the owner, and read only for all others.
  20. Use array_intersect (http://www.php.net/array_intersect) or array_diff (http://www.php.net/array_diff). [code]$a1 = array(1, 2, 3, 4, 5, 6); $a2 = array(1, 2, 3, 4, 5); if(count(array_intersect($a2, $a1)) == count($a2)) { echo"right"; } else { echo"wrong"; } if (count(array_diff($a2, $a1)) == 0) { echo"right"; } else { echo"wrong"; } [/code]
  21. Are you using Windows or *nix?  Apache or IIS?
  22. Check out bin2hex (http://www.php.net/bin2hex), pack (http://www.php.net/pack), and unpack (http://www.php.net/unpack). Unpack will probably help the most, depending on how the actual encoding is done.
  23. Sorry, wrong SQL syntax.  Your query should be: [code]SELECT * FROM reply LEFT JOIN users ON reply.poster = users.username WHERE topicid='$topicid' AND groupid='$id'[/code]
  24. Try this: [code]<?php session_start(); if ($_SESSION['logged'] != "yes"){ echo "Please login!"; exit; } mysql_connect("localhost", "_real", "hidden") or die(mysql_error()); mysql_select_db("_real") or die(mysql_error()); $username = $_SESSION['username']; $id = $_GET['id']; $topicid = $_GET['topicid']; $query = "SELECT * FROM reply LEFT JOIN users where reply.poster = users.username WHERE topicid='$topicid' AND groupid='$id'"; $result = mysql_query($query) or die(mysql_error()); echo " <table border=\"0\" cellspacing=\"1\" cellpadding=\"1\">"; while($main = mysql_fetch_array($result)) { echo ' <tr> <td style="text-align: center; border:1px solid black;" width="100"> <b>' . $main['poster'] . '</b><br> <img src="' . $main['avatar'] . '"><br> Posts: <b>' . $main['posts'] . '</b> </td> <td style="border:1px solid black;" width="450"> Posted On: <i>' . $main['time'] . '</i><hr> ' . $main['message'] . ' </td> </tr>'; } echo "</table>";[/code] You were using the same user info for all of the replies.
  25. If you are using php5 or greater, above that line, put this line: [code]date_default_timezone_set("Europe/London");[/code] Which should elminate the error.
×
×
  • 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.