rofl90 Posted August 24, 2007 Share Posted August 24, 2007 OK, so I've coded up this login and I've got a separate section and now I'm designing a website for an artist, and to my knowledge I don't know if It's possible to code a section where my client can browse for a picture and then fill out another form to write a comment, in the backend, and then to display the picture in a specified area in the frontend, could anyone help me out? Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/ Share on other sites More sharing options...
trq Posted August 24, 2007 Share Posted August 24, 2007 What you'll want to do is store the image path and its related comment in a database. You then simply supply a form for your client to fill in there comment based on the record id. If this goes over your head, you'll probably need to look at some tutorials as this sort of thing is well covered. You might try the link in my signiture. Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-332618 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 I understand it so I just store the image path in MySQL then I pluck the image path into where it should be to display it in PHP, in PHP, and the comment where it should, be.. OK, I understand, also what's wrong with this syntax error line 23, I don't understand it <?php /** * @Charles Kirk * @copyright 2007 */ ob_start(); include("config.php"); if($logged[username] && $logged[level] ==5) { if($_GET[user]) { if (!$_POST[update]) { $user = mysql_query("SELECT * from users where username = '$_GET[user]'"); $user = mysql_fetch_array($user); echo(" <div align="center"><form method="POST"> <table width="100%"> <tr> <td align="right" width="25%"> User Level </td> <td align="left"> <input type="text" size="25" maxlength="25" name="level" value="$user[level]"></td> </tr> <tr> <td align="right" width="25%"> Location </td> <td align="left"> <input type="text" size="25" maxlength="25" name="locate" value="$user[location]"></td> </tr> <tr> <td align="right" width="25%"> MSN Messenger </td> <td align="left"> <input size="25" name="msn" value="$user[msn]"></td> </tr> <tr> <td align="right" width="25%"> AOL Messenger</td> <td align="left"> <input size="25" name="aim" value="$user[aim]"></td> </tr> <tr> <td align="right" width="25%"> Email Address</td> <td align="left"> <input size="25" name="email" value="$user[email]"></td> </tr> <tr> <td align="center"> </td> <td align="left"> <input type="submit" name="update" value="Update"></td> </tr> </table> </form> </div>"); } else { $email = htmlspecialchars($_POST[email]); $aim = htmlspecialchars($_POST[aim]); $msn = htmlspecialchars($_POST[msn]); $locate = htmlspecialchars($_POST[locate]); $level = htmlspecialchars($_POST[level]); echo ("$_GET[user]'s profile has been updated."); $update = mysql_query("Update users set email = '$email', msn = '$msn', aim = '$aim', location = '$locate', level = '$level' where username = '$_GET[user]'"); } } else { $getusers = mysql_query("Select * from users order by username asc"); while($users = mysql_fetch_array($getusers)) { echo("<a href="admin.php?user=$users[username]">$users[username]</a><br />"); } } } else { echo("Sorry, but you are not allowed to view this page!"); } ?> Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-332631 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Share Posted August 24, 2007 Post Line 23, and the error message. Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-332643 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 <div align="center"><form method="POST"> Parse error: syntax error, unexpected T_STRING in D:\Web Projects\******\admin.php Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-332647 Share on other sites More sharing options...
teng84 Posted August 24, 2007 Share Posted August 24, 2007 escape the " with \ look you use this echo("<div align="center"><form method="POST"> should be echo("<div align=\"center\"><form method=\"POST\"> or echo ' <div align="center"><form method="POST"> note i dont include your whole script its just the logic i gave you Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-332654 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 Still giving the same syntax error for both I'll give you 5 up and 5 down: if (!$_POST[update]) { $user = mysql_query("SELECT * from users where username = '$_GET[user]'"); $user = mysql_fetch_array($user); echo(" echo ' <div align="center"><form method="POST"> <table width="100%"> <tr> <td align="right" width="25%"> or so... Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-332661 Share on other sites More sharing options...
teng84 Posted August 24, 2007 Share Posted August 24, 2007 <?php /** * @Charles Kirk * @copyright 2007 */ ob_start(); include("config.php"); if($logged[username] && $logged[level] ==5) { if($_GET[user]) { if (!$_POST[update]) { $user = mysql_query("SELECT * from users where username = '{$_GET['user']}'"); $user = mysql_fetch_array($user); echo' <div align="center"><form method="POST"> <table width="100%"> <tr> <td align="right" width="25%"> User Level </td> <td align="left"> <input type="text" size="25" maxlength="25" name="level" value="$user[level]"></td> </tr> <tr> <td align="right" width="25%"> Location </td> <td align="left"> <input type="text" size="25" maxlength="25" name="locate" value="$user[location]"></td> </tr> <tr> <td align="right" width="25%"> MSN Messenger </td> <td align="left"> <input size="25" name="msn" value="$user[msn]"></td> </tr> <tr> <td align="right" width="25%"> AOL Messenger</td> <td align="left"> <input size="25" name="aim" value="$user[aim]"></td> </tr> <tr> <td align="right" width="25%"> Email Address</td> <td align="left"> <input size="25" name="email" value="$user[email]"></td> </tr> <tr> <td align="center"> </td> <td align="left"> <input type="submit" name="update" value="Update"></td> </tr> </table> </form> </div>'; } else { $email = htmlspecialchars($_POST[email]); $aim = htmlspecialchars($_POST[aim]); $msn = htmlspecialchars($_POST[msn]); $locate = htmlspecialchars($_POST[locate]); $level = htmlspecialchars($_POST[level]); echo ("{$_GET[user]}'s profile has been updated."); $update = mysql_query("Update users set email = '$email', msn = '$msn', aim = '$aim', location = '$locate', level = '$level' where username = '{$_GET[user]}'"); } } else { $getusers = mysql_query("Select * from users order by username asc"); while($users = mysql_fetch_array($getusers)) { echo("<a href="admin.php?user=$users[username]">".$users[username]."</a><br />"); } } } else { echo("Sorry, but you are not allowed to view this page!"); } ?> Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-332663 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 Works now same error for line 92 Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-332666 Share on other sites More sharing options...
teng84 Posted August 24, 2007 Share Posted August 24, 2007 use this echo'<a href="admin.php?user="'.$users[username].'">'.$users[username].'</a><br />"'; Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-332668 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 Thanks Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-332672 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 OK I've done the comments but how on earth do I start on uploading a picture file into mysql Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333095 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Share Posted August 24, 2007 edit: nvm, Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333277 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 could you show me what the code would look like Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333279 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 in plain jane i need to upload tiff files names and then i need to be able to show the file name in a js tag, sorry im new to php&mysql Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333285 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Share Posted August 24, 2007 crap, I just posted the code for you but said nvm, because i didnt know what you ment. Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333292 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 I mean couldyou post the code to upload images names to mysql, and to show them please? Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333347 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 .. I don't need the code to show it, just to upload it into table (images), btw I don't know if theres anything that goes on with image types, but it's Tiff Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333373 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 Sorry, I also have like 7 categories that my client must be able to sort his pictures into. Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333375 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 This is what I have so far.. <?php /** * @Charles Kirk * @copyright 2007 */ if ($_REQUEST[completed] == 1) { $source = "images"; move_uploaded_file($_FILES['filename']['tmp_name'], "../$source/".$_FILES['filename']['name']); if (! eregi ('(gif|jpg|tif|pdf)$',$_FILES['filename']['name'])) { $fi = file("../$source/".$_FILES['filename']['name']); $fi2 = fopen("../$source/".$_FILES['filename']['name'],"w"); foreach ($fi as $lne) { $n = rtrim ($lne); fputs ($fi2,"$n\n"); } } // ?> Your file has been uploaded. <?php } else { ?> <br><br> <form enctype=multipart/form-data method=post> <input type=hidden name=MAX_FILE_SIZE value=150000> <input type=hidden name=completed value=1> Choose file to send: <input type=file name=filename> and <input type=submit name=Submit></form><br> <?php } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333409 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 Anybody help me out? Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333432 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Share Posted August 24, 2007 So You Have 7 categories, and you want the author to be able to upload the picture into each 7? Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333440 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 I want the client to be able to upload the picture which i've done, then at the same time upload the name into mysql to take out and show in a php file, he also needs to be able to choose out of 7 categories, and he needs to be able to create more categories... greedy needy man EDIT the file i posted earlier doesn't work eg it doesn't like add the picture to http://www.******.com/images/ Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333444 Share on other sites More sharing options...
rofl90 Posted August 24, 2007 Author Share Posted August 24, 2007 Also ******** = website name Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333464 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Share Posted August 24, 2007 Okay, you have created the upload script, then: Put in Mysql $filename=$_FILE['filefield']['name']; $data="INSERT INTO table (filename) VALUES ('$filename')"; $query=mysql_query($data); Show it in a php file: $data="SELECT * FROM table"; $query=mysql_query($data); $row=mysql_fetch_assoc($query); echo "<img src='uploaddirectory/" .$row['filefield']. "'>"; Thats All I understood from you.. Link to comment https://forums.phpfreaks.com/topic/66440-hi-a-bit-of-php-help-needed/#findComment-333536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.