Jump to content

pouncer

Members
  • Posts

    324
  • Joined

  • Last visited

    Never

Everything posted by pouncer

  1. at the top of the page i have require_once("../php_classes/class_login.php"); and that class_login has all the connect/select db stuff in there. i checked the $cat value too, it doesn't change :s i am stumped :s
  2. $create_str = "CREATE TABLE $cat (item_id INT not null auto_increment primary key, image_URL text)"; $cre = mysql_query($create_str); is there something wrong with my code, because it just doesn't create the table :s
  3. Say I do a query: "SELECT * FROM products WHERE name='DVD'"; Let's say it returns, 70 results. My page has like page_number extension like: www.mysite.com/products.php?page=1 I only want to display 10 results on 1 page, next 10 on page 2, next 10 on page 3, etc.. How can I code this guys? I'm sure someone here can help me
  4. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order, forum_name, description) VALUES('1', 'ghgfj', 'hjhj') $tot = mysql_num_rows(mysql_query("SELECT * FROM forum_name")); $tot = $tot + 1; $sql = mysql_query("INSERT INTO forum_name (order, forum_name, description) VALUES('$tot', '$Forum_Name', '$Forum_Desc')") or die (mysql_error()); any one see why the error?
  5. echo " <tr> <td>$name</td> <td>$desc</td> <td> <select name=select> $i = 0; while ($i < $total) { <option>$i</option> $i++; } </select> </td> </tr>"; it displays the drop down boxes, but with no data, why not?
  6. i just went back to my code and used $row = mysql_fetch_assoc($results);
  7. ok thanks it prints the all now but i get error Warning: mysql_field_name() [function.mysql-field-name]: Field 7 is invalid for MySQL result index 7 in Warning: mysql_field_name() [function.mysql-field-name]: Field 7 is invalid for MySQL result index 8 in etc.. etc.. up to index 12 line 214 which is $name = mysql_field_name($results, $i); ?
  8. $results = mysql_query("SELECT * FROM $cat WHERE item_id='$item_id'"); $num = mysql_num_fields($results); $row = mysql_fetch_row($results); $i = 0; while ($i < $num) { $name = mysql_field_name($results, $i); $data = $row[$name]; echo $name . " - " . $data; echo "<br>"; $i++; }; It just echos the field names, but not the data: item_id - image_URL - title - media - director - cast - description - why is this?
  9. $name = "{$_SESSION['Username']}_images"; $dir = "../collection_items/" . $name; if(!is_dir($dir)) mkdir($dir); $_accepted_extensions = array('.jpg', '.bmp', '.gif', '.JPG', '.BMP', '.GIF'); $tmp = pathinfo($_FILES['imageupload']['name']); $filename = $_FILES['imageupload']['name']; if ($filename != "") { if (!in_array('.' . $tmp['extension'], $_accepted_extensions)) { echo "The image you attempted to upload is of the wrong file type."; } else { $target_path = $dir . "/"; $nm = basename($_FILES['imageupload']['name']); $target_path = $target_path . $nm; if (move_uploaded_file($_FILES['imageupload']['tmp_name'], $target_path)) { echo "success!"; } else echo "There was an error uploading the image, please try again."; } } else { echo "You can specify an exclusive image later."; } How do i change it so it checks if the same filename already exists. if so, i want it to add a random 10 digit number to the end of the file and upload it!
  10. perfect, thanks. The images are items, when they click on Manage, it will take the user to that items manage page where they can edit the info for that particular item. boo_lolly, using a while loop ok, but what about the $i ?
  11. This is my table code: echo "<table width=90% cellpadding=0 cellspacing=10 border=0 align=center>"; echo "<tr>"; echo "<th></th>"; echo "<th></th>"; echo "<th></th>"; echo "</tr>"; for ($i = 1; $row = mysql_fetch_array($qry, MYSQL_ASSOC); $i++) { $item_id = $row['item_id']; $cat = $row['category']; $_item = new uniqueItem($item_id, $cat); $img = $_item->getImageURL(); if ($img != "") $image = "../" . $img; else $image = "../index_images/create_avatar.gif"; if($i % 4 == 0) echo "<tr>"; echo "<td align=center><img src=\"$image\"><br>itemid: $item_id<a href=\"manageitem.php?item_id=$item_id\">Manage</a></td>"; if($i % 4 == 0) echo "</tr>"; } echo "</table>"; But from this image: http://img249.imageshack.us/my.php?image=errorqw9.jpg something is not right. the itemid should be like: 7,8,9,10.. etcwhy do my images appear in the wrong order, they appear in: 9,8,7,10 :s
  12. isnt there any way to just echo the directory name then, in the file browse box, when i click the submit button?
  13. hmmm, yea i wanted to check it before i hit the submit. hmm, sounds a bit complex to me.
  14. <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <input name="imageupload" type="file" size="70"> How do I actually check if the user actualled clicked the browse button and selected a file? because, before i hit the submit button i want to check if the user actually select a file to upload
  15. perfect thorpe, thank you buddy.
  16. Thanks alot guys. Should the code be if(is_dir(../collection/$name))
  17. im in member.php which is inside a folder called 'member' i have a folder called 'collection' which is outside this member directory. i want to create a folder inside the 'collection' folder based on the username, e.g, $_SESSION['Username'] . "_images"; so that will be like: john_images folder. i want to actually check if the folder 'john_images' doesn't already exist though. can soemone please show me how it can be done?
  18. I tried this $results = mysql_query("SELECT * FROM $cat"); $num = mysql_num_fields($results); $i = 0; while ($i < $num) { $name = mysql_field_name($results, $i); $txtbox = "txt_" . $name; if ($name != 'item_id' && $name != 'image_URL') { echo $_POST['$txtbox']; } $i++; }; the: echo $_POST['$txtbox']; it doesnt seem to work, anyone see what im doing wrong?
  19. Yes. These tables are category tables, like movies,dvds,cars etc. Users can add new fields to these tables. Now I have created a form for the users, by looping the table. Now I just need to insert the data when users fill the form in, into the table.
  20. no mate. i don't mean like that. sorry i wasn't clear enough. The fields are not a fixed set of fields, I've created forms for users to add/delete fields to the tables etc. So i can't do as you have posted incase users add new fields which means I will have to add a new $_POST variable. So the code I posted creates the form by looping the $cat table and outputting a text box for each field in that $cat table. I think i need to now loop the $cat table again, and get the field names and then somehow check the post like $_POST['txt_$name']; but that didnt work I tried something like: if (isset($_POST['Add_item'])) { echo "Clicked on add item<br>"; $results = mysql_query("SELECT * FROM $cat"); $num = mysql_num_fields($results); $i = 0; while ($i < $num) { $name = mysql_field_name($results, $i); if ($name != 'item_id' && $name != 'image_URL') { echo $_POST['txt_.$name']; } $i++; }; } but it just echos; Clicked on add item it should echo the contents of each field which i filled in.
  21. No. That code I posted creates the text boxes in the form, on the page, for every single field in the $cat table. Now when I fill the form out, I need to somehow check each fields data with the $_POST and do the necessary insert into my table. I'm not sure how to loop through it and get each fields $_POST though.
  22. I create my form bu php code, creating a textbox for each field in my table: $results = mysql_query("SELECT * FROM $cat"); $num = mysql_num_fields($results); $i = 0; while ($i < $num) { $name = mysql_field_name($results, $i); if ($name != 'item_id' && $name != 'image_URL') { echo $name . ":<br>"; echo "<input name=\"txt_" . $name . "\" type=\"text\" id=\"txt_" . $name . "\" size=\"60\"\>"; echo "<br><br>"; } $i++; }; echo " <input class=\"style74\" name=\"Add_item\" type=\"submit\" id=\"Save_Item\" value=\"Add item\">"; So for e.g, if there was a field called 'title' in the table, it would create a textbox with name 'txt_title' But now I need to insert the record into the form, when they fill the form in. How do i get all the $_POST's from the text boxes? can someone please help me.
  23. hmm mate, do i need a loop or anything? what about the mysql_query ?
  24. i have a table called 'dvds' can someone show me a loop to echo all the field names and their data type (like INT, VARCHAR etc)?
×
×
  • 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.