Jump to content

Tuskony

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Tuskony's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey guys, I have a form where people can upload up to 5 images. I have it down so you can only upload images etc. But the issue I am having is that if a user uploads a file that's too big, or of the wrong type (IE Not a picture) it is actually uploaded to the file server THEN determined it's invalid. Is there anyway I can get the browser to limit what size of files will even be attempted to get uploaded? I hope this makes sense! Thanks
  2. Ok cool it does work. However how would I incorporate a where clause in there? A SQL query can't have 2 where clauses can it? I need to select the 2nd user name WHERE users.AccID = truck_image_comments.CommentBy
  3. Hey guys, I have 3 tables I am joining in a query. One is a table with user information, the other is a Report table, and one one is a comments table. What I am doing is allowing users to report a comment or picture for abuse. So when I am on my admin page I want to see what comments have been reported and who they were reported by. I am also looking to display information about the comment etc. Anyway my problem lies within my joins. I am already returning the UserName column of the person who reported the comment but I also want to return the UserName of the person who wrote the comment that reported. Can I mod the following query to make this happen? SELECT CRID, CID, ReportByAccID, Date, UserName, CommentBy, Comment, DateTime FROM CommentReports LEFT JOIN users ON CommentReports.ReportByAccID = users.AccID LEFT JOIN truck_image_comments ON CommentReports.CID = truck_image_comments.ComID ORDER BY CRID; IE Can I do something like UserName2 = users.UserName where users.AccID = truck_image_comments.CommentBy; Thanks!
  4. PHP doesn't support mysql_real_query() and the like? I used those functions in all my C++ apps.
  5. I'll do that thanks!!! This is an old redhat server I setup YEARS ago. Looks like I need to upgrade MySQL as well. My version doesn't support mysql_real_query() lol.
  6. I have a class defined as: define('DEF_HOST', 'localhost'); define('DEF_USER', 'MyUserName'); define('DEF_PASS', 'MyPassword'); define('DEF_DB', 'MyDatabase'); class CDatabase { private $db_user_name; .... } That line, private $db_user_name, gives me the following error: Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /usr/share/pear/xxxxxx/CDatabase.php on line 10
  7. How do I do this? I tried to search but I couldn't find a suitable answer. I have a website that has galleries and such and some of the pictures are stored on remote servers like photobucket etc. When I scale the pictures down, or show them in full I'd like to know their heights and widths. Any help is greatly appreciated!
  8. I just need to look at the code in php tags ... <? include("db.php"); $UserName = ""; $PassWord = ""; $isLogged = true; if(isset($HTTP_COOKIE_VARS["UserName"]) && isset($HTTP_COOKIE_VARS["PassWord"])) { $UserName = $HTTP_COOKIE_VARS["UserName"]; $PassWord = $HTTP_COOKIE_VARS["PassWord"]; } if(mysql_connect($db_host, $UserName, $PassWord) === false || ($UserName == "" || $PassWord == "")) $isLogged = false; else mysql_select_db($db_name); $item_id = $HTTP_POST_VARS["id"]; //$item_id gets used as a flag for when a new item is created. if($item_id != "" && $isLogged == true) { $name = $HTTP_POST_VARS["name"]; $price = $HTTP_POST_VARS["price"]; $summary = $HTTP_POST_VARS["summary"]; $description = $HTTP_POST_VARS["description"]; $ordre = $HTTP_POST_VARS["ordre"]; if($ordre == "") $ordre = "0"; $update = "update items set ordre = ordre + 1 where ordre >= " . $ordre; mysql_query($update); $insert = "insert into items (name, price, summary, description, ordre) values (" . "'" . $name . "', " . $price . ", " . "'" . $summary . "', " . "'" . $description . "', " . $ordre . ")"; mysql_query($insert); $item_id = mysql_insert_id(); if(isset($HTTP_POST_FILES)) { if(is_uploaded_file($HTTP_POST_FILES["thumbnail"]["tmp_name"])) { $file_handle = fopen($HTTP_POST_FILES["thumbnail"]["tmp_name"], "rb"); $thumbnail = $HTTP_POST_FILES["thumbnail"]["name"]; $file_bytes = addslashes(fread($file_handle, filesize($HTTP_POST_FILES["thumbnail"]["tmp_name"]))); $update = "update items set " . "thumbnail = '" . $file_bytes . "' " . "where id = " . $item_id; mysql_query($update); unlink($HTTP_POST_FILES["thumbnail"]["tmp_name"]); } if(is_uploaded_file($HTTP_POST_FILES["image"]["tmp_name"])) { $file_handle = fopen($HTTP_POST_FILES["image"]["tmp_name"], "rb"); $image = $HTTP_POST_FILES["image"]["name"]; $file_bytes = addslashes(fread($file_handle, filesize($HTTP_POST_FILES["image"]["tmp_name"]))); $update = "update items set " . "image = '" . $file_bytes . "' " . "where id = " . $item_id; mysql_query($update); unlink($HTTP_POST_FILES["image"]["tmp_name"]); } } } $select = "select id from items order by ordre"; $ids = mysql_query($select); while(($id = mysql_fetch_assoc($ids)) && $isLogged == true) { $item_id = $HTTP_POST_VARS["id_" . $id["id"]]; //If the item was modified, save it. if($item_id != "" && $item_id > 0) { $name = $HTTP_POST_VARS["name_" . $id["id"]]; $price = $HTTP_POST_VARS["price_" . $id["id"]]; $summary = $HTTP_POST_VARS["summary_" . $id["id"]]; $description = $HTTP_POST_VARS["description_" . $id["id"]]; $ordre = $HTTP_POST_VARS["ordre_" . $id["id"]]; $update = "update items set " . "name = '" . $name . "', " . "price = " . $price . ", " . "summary = '" . $summary . "', " . "description = '" . $description . "', " . "ordre = " . $ordre . " " . "where id = " . $item_id; mysql_query($update); //Were any files uploaded? if(isset($HTTP_POST_FILES)) { if(is_uploaded_file($HTTP_POST_FILES["thumbnail_" . $item_id]["tmp_name"])) { $file_handle = fopen($HTTP_POST_FILES["thumbnail_" . $item_id]["tmp_name"], "rb"); $thumbnail = $HTTP_POST_FILES["thumbnail_" . $item_id]["name"]; $file_bytes = addslashes(fread($file_handle, filesize($HTTP_POST_FILES["thumbnail_" . $item_id]["tmp_name"]))); $update = "update items set " . "thumbnail = '" . $file_bytes . "' " . "where id = " . $item_id; mysql_query($update); unlink($HTTP_POST_FILES["thumbnail_" . $item_id]["tmp_name"]); } if(is_uploaded_file($HTTP_POST_FILES["image_" . $item_id]["tmp_name"])) { $file_handle = fopen($HTTP_POST_FILES["image_" . $item_id]["tmp_name"], "rb"); $image = $HTTP_POST_FILES["image_" . $item_id]["name"]; $file_bytes = addslashes(fread($file_handle, filesize($HTTP_POST_FILES["image_" . $item_id]["tmp_name"]))); $update = "update items set " . "image = '" . $file_bytes . "' " . "where id = " . $item_id; mysql_query($update); unlink($HTTP_POST_FILES["image_" . $item_id]["tmp_name"]); } } } //Delete items. if($item_id != "" && $item_id < 0) { $delete = "delete from items where id = " . (-$item_id); mysql_query($delete); unlink("./images/item_" . (-$item_id) . "_thumbnail.jpg"); unlink("./images/item_" . (-$item_id) . "_image.jpg"); } } $select = "select * from items order by ordre"; $items = mysql_query($select); ?> <html> <head> <title>item shopping cart edit</title> <script> function NewImage(id) { var File; var Image; var Save; if(id != null) { eval('File = document.cart.image_' + id + ';'); eval('Image = document.images.image_file_' + id + ';'); } else { File = document.cart.image; Image = document.images.image_file; } if(File.value != '') { Image.src = File.value; save_item(id); } } function NewThumb(id) { var File; var Image; var Save; if(id != null) { eval('File = document.cart.thumbnail_' + id + ';'); eval('Image = document.images.thumbnail_file_' + id + ';'); } else { File = document.cart.thumbnail; Image = document.images.thumbnail_file; } if(File.value != '') { Image.src = File.value; save_item(id); } } function save_item(id) { if(id != null) eval('document.cart.id_' + id + '.value = ' + id + ';'); else document.cart.id.value = 0; } function delete_item(id) { eval('document.cart.id_' + id + '.value = ' + (-id) + ';'); document.cart.submit(); } function logout() { document.cookie = 'UserName='; document.cookie = 'PassWord='; document.cart.submit(); } </script> </head> <body <? if($HTTP_POST_VARS["id"] != "") { ?>onload="document.cart.ordre.value = ''; document.cart.submit();"<? } ?>> <form enctype="multipart/form-data" method="post" name="cart"> <input type="hidden" name="ordre" value="<?= $HTTP_POST_VARS["ordre"] ?>" /> <table align="center"> <? if((mysql_num_rows($items) == 0 || $HTTP_POST_VARS["ordre"] != "") && $HTTP_POST_VARS["id"] == "" && $isLogged == true) { ?> <input type="hidden" name="id" /> <tr> <td valign="top"> <table> <tr> <td>item name: </td> <td><input type="text" name="name" onchange="save_item();" /></td> </tr> <tr> <td>price: </td> <td><input type="text" name="price" onchange="save_item();" /></td> </tr> <tr> <td>summary: </td> <td><textarea name="summary" onchange="save_item();"></textarea></td> </tr> <tr> <td>description: </td> <td><textarea name="description" onchange="save_item();"></textarea></td> </td> </tr> <tr> <td> <input type="button" value="save" onclick="document.cart.submit();"/> <input type="button" value="cancel" onclick="document.cart.ordre.value = ''; document.cart.id.value = ''; document.cart.submit();"/> <input type="button" value="log out" onclick="logout();" /> <br /><br /></td> </tr> </table> </td> <td align="right" valign="top" nowrap> thumbnail: <input type="file" name="thumbnail" onchange="NewThumb();" /> <br /> <img name="thumbnail_file" /> <br /> image: <input type="file" name="image" onchange="NewImage();" /> <br /> <img name="image_file" /> </td> </tr> <? } ?> <? while(($item = mysql_fetch_assoc($items)) && ($HTTP_POST_VARS["id"] == null) && ($isLogged == true)) { $item_id = $item["id"]; $name = $item["name"]; $price = $item["price"]; $summary = $item["summary"]; $description = $item["description"]; $thumbnail = $item["thumbnail"]; $image = $item["image"]; $ordre = $item["ordre"]; if(is_dir("images/") == false) mkdir("images/", 0755); $thumbnail_file = "images/item_" . $item_id . "_thumbnail.jpg"; if($thumbnail != "") { $thumbnail_file_handle = fopen("./" . $thumbnail_file, "wb"); fwrite($thumbnail_file_handle, $thumbnail, strlen($thumbnail)); chmod("./" . $thumbnail_file, 0644); } $image_file = "images/item_" . $item_id . "_image.jpg"; if($image != "") { $image_file_handle = fopen("./" . $image_file, "wb"); fwrite($image_file_handle, $image, strlen($image)); chmod("./" . $image_file, 0644); } ?> <input type="hidden" name="id_<?= $item_id ?>" /> <tr> <td valign="top"> <table> <tr> <td>item name: </td> <td><input type="text" name="name_<?= $item_id ?>" value="<?= $name ?>" onchange="save_item(<?= $item_id ?>);" /></td> </tr> <tr> <td>price: </td> <td><input type="text" name="price_<?= $item_id ?>" value="<?= $price ?>" onchange="save_item(<?= $item_id ?>);" /></td> </tr> <tr> <td>summary: </td> <td><textarea name="summary_<?= $item_id ?>" onchange="save_item(<?= $item_id ?>);"><?= $summary ?></textarea></td> </tr> <tr> <td>description: </td> <td><textarea name="description_<?= $item_id ?>" onchange="save_item(<?= $item_id ?>);"><?= $description ?></textarea></td> </tr> <tr> <td>order: </td> <td><input type="text" name="ordre_<?= $item_id ?>" value="<?= $ordre ?>" onchange="save_item(<?= $item_id ?>);" /></td> </tr> <tr> <td> <input type="button" value="add a new item" onclick="document.cart.ordre.value = <?= $ordre + 1 ?>; document.cart.submit();"/> <input type="submit" value="save" /> <input type="button" value="delete" onclick="delete_item(<?= $item_id ?>);" /> <input type="button" value="log out" onclick="logout();" /> <br /><br /> </td> </tr> </table> </td> <td align="right" valign="top" nowrap> thumbnail: <input type="file" name="thumbnail_<?= $item_id ?>" onchange="NewThumb(<?= $item_id ?>);" /> <br /> <img name="thumbnail_file_<?= $item_id ?>" src="<?= $thumbnail_file ?>" /> <br /> image: <input type="file" name="image_<?= $item_id ?>" onchange="NewImage(<?= $item_id ?>);" /> <br /> <img name="image_file_<?= $item_id ?>" src="<?= $image_file ?>" /> <br /> </td> </tr> <? } ?> <? if($isLogged == false) { ?> <tr> <td>User Name </td> <td><input type="text" name="User" /></td> </tr> <tr> <td>Password</td> <td><input type="password" name="Pass" /></td> </tr> <tr> <td colspan="2" align="right"> <input type="button" value="log in" onclick="document.cookie = 'UserName=' + document.cart.User.value; document.cookie = 'PassWord=' + document.cart.Pass.value; document.cart.submit();"> </td> </tr> <? } ?> </table> </form> </body> </html>
  9. Oh even when you have a properly assigned user name and password you're still getting the error? Have you tried substituting your variables in mysql_connect() with a user name and pword you know work? What exactly is this page doing and when are you getting the errors?
  10. Are you sure you have permission to access the server? One problem I see is here....on line 15 where you get your 1st error. $UserName = ""; $PassWord = ""; $isLogged = true; if(isset($HTTP_COOKIE_VARS["UserName"]) && isset($HTTP_COOKIE_VARS["PassWord"])) { $UserName = $HTTP_COOKIE_VARS["UserName"]; $PassWord = $HTTP_COOKIE_VARS["PassWord"]; } if(mysql_connect($db_host, $UserName, $PassWord) == false || ($UserName == "" || $PassWord == "")) What you are basically doing is allowing mysql_connect() to call even though you may not have a valid user name and password to provide it with through your "$UserName" and "$Password" variables. Those variables could very well be NULL if the issets() aren't satisfied. You need to call mysql_connect() only if you're sure you have assigned the $UserName and $Password vars... likes this: $UserName = ""; $PassWord = ""; $isLogged = true; if(isset($HTTP_COOKIE_VARS["UserName"]) && isset($HTTP_COOKIE_VARS["PassWord"])) { $UserName = $HTTP_COOKIE_VARS["UserName"]; $PassWord = $HTTP_COOKIE_VARS["PassWord"]; } else { $UserName = "BLANK"; $PassWord = "BLANK"; } //UserName and PassWord should always have an assigned, not null, string. if(mysql_connect($db_host, $UserName, $PassWord) === false || ($UserName == "" || $PassWord == ""))
  11. The title says it all.... I want to download images to my server using file_get_contents but I am not sure how I actually save these images once file_get_contents() has finished. A user inputs a URL into a form and clicks submit then the site downloads the image to my server. However I'm also not sure how I verify that they've entered a proper URL to a picture and not to a script or something like that... Thanks guys!
  12. I'll have to give it a try and go through the code to figure out what exactly is going on! Thanks!
  13. Hey guys.... I have a website that allows uses to log in and create trucks to share with the community. However I don't want to have to store hundreds of images on my home based server (for obvious reasons) so I let users link to pictures on other sites... like they're photobucket account for example. The users can also choose one of the pictures to be their thumbnail picture for that particular truck. However by referencing to the pictures on the remote sites I have a problem with displaying the images. Because the thumbnail pics are shown so much it bogs the pages down (even though I resize the pictures to 50x50 display) because the pictures on the remote site are large in size. Is there anyway I can download and resize then save all thumbnail pictures onto my machine so they're not so big and make loading quicker? Or is there a better way? Also is there anyway for me to have a script that can measure the pictures on the foriegn site? When someone is viewing a full sized picture i want to know if the picture is too tall or too wide an needs to be resized. Thanks!
×
×
  • 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.