justAnoob
Members-
Posts
561 -
Joined
-
Last visited
Never
Everything posted by justAnoob
-
Ok,, so then if I save $newname as $imgpath.. and the path is put into mysql.. How would I go about displaying the image using the imgae path from mysql.. Sorry for all the questions.. I've looked just about everywhere I could for some answers.
-
I have images on my server in the folder "userimages". I have several sub foloders off of that (computers, students, and so on). Uploading the picture to the server is no problem. Displaying the pictures from the server is easy also... But right now I'm calling them straight from the server. What I want to do is when a picture is uploaded, the picture goes to the server(done), and then the info goes to mysql(done except for image path). The reason I want to do this is because it seems easier to call everything from mysql so it can display inside a neat table on my page. Understand what I'm saying. Here is the upload so far. <?php session_start(); $host = "0000000000"; $username = "0000"; $password = "00000000"; $db_name = "0000000000"; $tbl_name1 = "00000"; $tbl_name2 = "000000000000"; mysql_connect("$host", "$username", "$password") or die("Could not connect."); mysql_select_db("$db_name") or die("Could not find database"); $item_name = mysql_real_escape_string($_POST['item_name']); $description = mysql_real_escape_string($_POST['description']); $in_return = mysql_real_escape_string($_POST['in_return']); $imgpath = ???????? define ("MAX_SIZE","1000"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "gif") && ($extension != "png")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } $category = $_POST['listmenu']; $image_name=time().'.'.$extension; $newname="userimages/$category/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } } } } $findit = $_SESSION['id']; $result=mysql_query("SELECT id FROM members WHERE username = '$findit'"); $row=mysql_fetch_assoc($result); $user_id = $row['id']; $sql = "INSERT INTO member_trades(item_name, description, in_return, user_id)VALUES('$item_name','$description','$in_return', '$user_id')"; mysql_query($sql) or die(mysql_error()); if(isset($_POST['Submit']) && !$errors) { header ("http://www.0000000000.com/previewsave.php"); echo "<h1>Image Uploaded Successfully!</h1>"; echo '<img src="' . $newname . '" width="150" border="0"><br />'; } ?>
-
I'm still stuck on saving the image paths to mysql and then calling the images to dispaly on the page. I looked everywhere,,, google, yahoo, daniweb.... Can't find anything that will really help.
-
[SOLVED] storing image path and calling image from image path
justAnoob replied to justAnoob's topic in PHP Coding Help
think i may have found something... Will call this solved for the time being. -
[SOLVED] storing image path and calling image from image path
justAnoob replied to justAnoob's topic in PHP Coding Help
Are there any tutorials out there to help me..I can't find anything anywhere. -
I have images located on my server. Right now I'm just calling the images straight from the server to display on my page. How would I go about storing the image path in MySQL??? And then calling the image path to display the image??? I already have a field in the datagase called img_path....I can't find any detailed ways of doing this...
-
[SOLVED] how difficult to make this work???
justAnoob replied to justAnoob's topic in PHP Coding Help
the name shouldn't be that much text.... the description could be up to about 250 characters and in-return could be the same, about 250 characters... all three will be all text. -
[SOLVED] how difficult to make this work???
justAnoob replied to justAnoob's topic in PHP Coding Help
images are in several folders on the server.....i have a table in mysql with these fields that I need to display...name, description, in-return.... maybe something like that to start....but as i mentioned before...each folder(category) may have a few pages. -
[SOLVED] how difficult to make this work???
justAnoob replied to justAnoob's topic in PHP Coding Help
No need to get snippy there bud.... I can do all three you mentioned.. Just wondered if anyone knew of any tutorials that might help me out through the process.... -
[SOLVED] how difficult to make this work???
justAnoob replied to justAnoob's topic in PHP Coding Help
bump, ttt.... anyone got any input on where to start with something like this. -
i have several folders(categories) on my server which contain images. i have a database in mysql which contain info on those images. I'm looking to be able to click on a category on the website and then have the images from that category displayed in some sort of table format(10 per page, with a next and previous button in case there are more than 10, or 20 or 30, you get the point. Also I would like the info about the image to appear next to the images on the page. Is this difficult to make happen and look good??? Right now this is what I have and all it does is display the images vertically down the page with a <br/> inbetween the images. So far so good. Here is the code. <?php $imgPath = "userimages/Computers"; foreach(glob("$imgPath/{*.jpg,*.png,*.gif}", GLOB_BRACE) as $fname) { echo '<img src="' . $imgPath . '/' . baseName($fname) . '" width="150" border="1"><br/><br/>'; } ?>
-
[SOLVED] choosing from list menu to decide where to put file
justAnoob replied to justAnoob's topic in PHP Coding Help
bump, ttt... cant find anything on google about list menus and category selection -
[SOLVED] choosing from list menu to decide where to put file
justAnoob replied to justAnoob's topic in PHP Coding Help
the list is populated already with the categories... I'm using dreamweaver for this small page i'm doing. what is the next step?? -
[SOLVED] choosing from list menu to decide where to put file
justAnoob replied to justAnoob's topic in PHP Coding Help
Here is what I got,,, I'm only showing the code that is relevant to what I am trying to accomplish The "*****" are the lines that I started to change for this to work, not sure if that is correct though. <?php if(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "gif") && ($extension != "png")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } $listmenu = //****** $image_name=time().'.'.$extension; $newname="userimages/$listmenu/".$image_name; //********* $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } } } } ?> -
[SOLVED] choosing from list menu to decide where to put file
justAnoob replied to justAnoob's topic in PHP Coding Help
upload script works properly, all files just go to main userimages folder. I have sub folders created already. How would I go about the whole variable thing... something like this??>>>>> <?php $listmenu = $image_name=time().'.'.$extension; $newname="userimages/$listmenu/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); ?> the list menu options are named identical to the sub folder names just so you know -
I have a list menu of a couple categories. I have a folder on my server called userimages with the category sub folders off of that. Right now we got a upload script to upload all pictures to the main userimages folder. How would I go about intergrating a list menu so the user can pick the category he or she would like the file to go into. Here is what I got so far. <?php $image_name=time().'.'.$extension; $newname="userimages/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); ?> Any tutorials out there or step by steps or any ideas. Thanks again.
-
Got it !!! Finally,, thanks for all the help everyone.....Woooohooooo
-
is there a better way to get the username of whoever is logged in?>??
-
when the user logs in,,, this happens <?php $_COOKIE['user'] = "$username"; ?> I am storing the username as a cookie so i can use it for this,, the upload part. <?php $findit=$_COOKIE['user']; $result=mysql_query("SELECT id FROM members WHERE 'username'= '$findit'"); $row=mysql_fetch_assoc($result); $user_id = $row['id']; $sql = "INSERT INTO member_trades(item_name, description, in_return, user_id)VALUES('$item_name','$description','$in_return', '$user_id')"; mysql_query($sql) or die(mysql_error()); ?> but still nothing,,,, a number 0 still shows up in the member_trades table for my user_id
-
thanks guys,, i'll give it a shot... i never like to give up.
-
I am so lost now,,,, not sure what to do next...all i want to do is get the id for a member from one table and put it in another table when they upload a pic so i know what pictures go to each user. i know i am able to do this. what is going on? <?php $result=mysql_query("SELECT id FROM members WHERE username = 'WHAT GOES HERE. MUST BE A VARIABLE FOR WHATEVER USER IS LOGGED IN RIGHT???'"); $row=mysql_fetch_assoc($result); $user_id = $row; $sql = "INSERT INTO member_trades(item_name, description, in_return, user_id)VALUES('$item_name','$description','$in_return', '$user_id')"; mysql_query($sql) or die(mysql_error()); ?>
-
this is what i have so far, i'm not even sure if i'm getting the id from the table correctly using the $findit Does that look right?? <?php $_SESSION['id'] = "$username"; $findit=$_SESSION['id']; $result=mysql_query("SELECT id FROM members WHERE 'username'= '$findit'"); $row=mysql_fetch_assoc($result); $sql = "INSERT INTO member_trades(item_name, description, in_return, user_id)VALUES('$item_name','$description','$in_return', '$row')"; mysql_query($sql) or die(mysql_error()); ?>
-
not sure what your getting at, sorry
-
now i put this into another little project that I'm working on, and the problem is that the id of the user from the table 'members' is not getting inserted into the user id field of the table member_trades... what i'm trying to say is how do i get the id from the user that is logged in? i tried using $findit variable which is actually a sesssion variable that is created when the user logs in... i am confused,,, again. Yesideez I know your out there somewhere,, lol. <?php $_SESSION['id'] = "$username"; //this is actually set when the user logs in, just wanted to post here to show $findit=$_SESSION['id']; $result=mysql_query("SELECT id FROM members WHERE 'username'= '$findit'"); //******* $user_id=mysql_fetch_assoc($result); $sql = "INSERT INTO member_trades(item_name, description, in_return, user_id)VALUES('$item_name','$description','$in_return', '$user_id')"; mysql_query($sql) or die(mysql_error()); ?>
-
thanks for the reply bud.