Jump to content

Solar

Members
  • Posts

    145
  • Joined

  • Last visited

Everything posted by Solar

  1. After playing around with "Concatenate" - I've been able to put the code with and it words like a charm! ; $target = $target . $username. "_" . ( $_FILES['photo']['name']); Thankyou!
  2. Hello PHPFreaks! I have a question for somebody to answer <?php //This is the directory where images will be saved $target = "gallery/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $username=$_POST['username']; $photo=($_FILES['photo']['name']); $caption=$_POST['caption']; $ip=$_POST['ip']; //Writes the information to the database mysql_query("INSERT INTO `photo` (username, photo, caption, ip) VALUES ('$username', '$photo', '$caption', '$ip')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your caption has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> When pictures are uploaded; they upload the name they have named them. Is it possible to add to the script $username somewhere to the file name? For example; DSC_0077_SOLAR.JPG Thanks for your time!
  3. Sorry for the late reply and thanks to your post. Let say I have a single textbox. Everytime you leave a space in this textbox; it counts as a new word. I would like the database/table structure like; idvideoidword 01Hello 11Goodbye 23Testing Every word would have its own entry. I'm still confused and want to know if there is some sort of specific php "name" so I can search for answers. Example; mysql_fetch_row.
  4. Can I get an example for the mysql build please? Would I need a simple word in the INSERT statement? I've tried googling (php insert array) but no answers.
  5. Like Youtube; when submitting a video; You can insert words into a Textbox named Tags. Each space you leave is considered the start of a new word. How can I do this using PHP + MYSQL. Thanks!
  6. Also blank spaces in your pagerefresh.php <?php $page = $_SERVER['PHP_SELF']; $sec = "0"; header("Refresh: $sec; url=$page"); ?>
  7. Your missing a <tr> tag in your first echo. That's all I see.
  8. Solar

    Update SQL

    Thanks! I just just figured this out. My SQL Statement $sql="UPDATE blog SET name='$_POST[name]', title='$_POST[title]', entry='$_POST[entry]', na='$_POST[na]', ip='$_POST[ip]' WHERE name = '" . $_SESSION['username'] . "'";
  9. SQL PHP UPDATE: $sql="UPDATE blog (name, title, entry, na, ip) SET ('$_POST[name]','$_POST[title]','$_POST[entry]','$_POST[na]','$_POST[ip]')"; I need the SQL to read the users name to detect that the edit is there own blog post. SQL PHP PAGE: $sql = "SELECT id, name, title, entry, na, ip FROM blog WHERE name = '" . $_SESSION['username'] . "' AND `id` = '" . htmlspecialchars($_GET["id"]) . "'"; ALSO <form action="profile_blogs_edit.php" method="post"> THE ERROR I AM GETTING: Error: 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 '(title, entry, na, entry, ip) SET id='', name='Steven', 'Macromedia', ' Remem' at line 1 So is there a way to make this?: $sql="UPDATE blog (name, title, entry, na, ip) SET ('$_POST[name]','$_POST[title]','$_POST[entry]','$_POST[na]','$_POST[ip]') WHERE name = '" . $_SESSION['username'] . "'"; Thanks!
  10. 100% Works! Thanks very much! Question (Doesn't Have to Be Answered): I have; Steven changed his profile picture. Steven likes this. Steven changed his profile picture. Bob likes this. Is there a way to combine the two so that it outputs: Steven changed his profile picture. Steven, Bob likes this. Thanks ignace for your help as well. If I want to clean up my databases/tables, I will follow your tables. They make more sense that way.
  11. Thanks for your reply! As stated above (Which I have tables really similar); I am having troubles displaying this in PHP. As there is a news feed; there is a echo list (Posted above) here is an example of my output; Steven updated his profile. likes this. <- This is showing likes this. But nobody liked this post, how can I make that into an else statement using while and echo list? Steven uploaded a profile picture. John Doe likes this. Steven uploaded a profile picture. Bob likes this. <- This was allready liked above by John Doe. How can I put these two together in a while echo list? Thanks, hopefully this is clear enough to understand
  12. Since I am still new to php I am probably doing this the hardway. I'm coding a LIKE SYSTEM (Similar To Facebooks) I have a table that looks like this; Table Named; stats; idnamedescription 1Stevenupdated their status. 2Stevenuploaded a picture to their profile. Then I have a table like this; Table Named; `like`; idusernamelike 2Steven1 (Column "like" is a variable between 0 (Not Liked) and 1 (Liked) My SQL looks like this; $sql = "SELECT * FROM stats LEFT JOIN `like` ON `like`.id = stats.id ORDER BY stats.id DESC,stats.id LIMIT $offset, $rowsperpage"; Everything you see here is perfect. I will try to continue to explain the best I can. As you see above, the STATS TABLE has ID numbers auto-increcement while when someone hits the like button, that STATS ID number enters in the LIKE TABLE also inserting the sessions USERNAME and 1 Value for LIKE COLUMN. $sql="INSERT INTO `like` (id, username, `like`) VALUES ('$_POST[id]','$_POST[username]','$_POST[like]')"; Everything is once again perfect of what I have. Displaying it is my problem. echo $list[''] . "<a href=\"profile.php?user=" . $list['name'] . "\"> <b>" . $list['name'] . "</b></a> " . $list['description'] . "<br /><form action=\"profile_like_insert.php\" method=\"post\"> <input name=\"id\" type=\"hidden\" size=\"50\" value=\"" . $list['id'] . "\"/> <input name=\"username\" type=\"hidden\" size=\"50\" value=\""; ?> <?php echo $_SESSION['username']; ?> <?php echo $list[''] . "\"> <input name=\"like\" type=\"hidden\" size=\"50\" value=\"1\"/> <input type=\"submit\" value=\"Like\" /> </form>; The above is an echo list that echos perfectly. My only problem is where do I insert this into?: <a href=\"profile.php?user=" . $list['username'] . "\">" . $list['username'] . "</a> likes this.<br> When I enter this code in the ECHO LIST it duplicates posts and also has the text "Likes This" under each status update (Updated Profile). This is what I would like to have; Only show the word LIKES THIS if an USERNAME likes it. For example; Steven updated his profile. Steven uploaded a profile picture. John Doe likes this. What i've been getting is this; Steven updated his profile. likes this. Steven uploaded a profile picture. John Doe likes this. Steven uploaded a profile picture Bob likes this. (As you see it duplicates) I will keep trying very hard to figure this out, I would love someone to get me into the right path Thanks so much in advanced and your time!
  13. Thanks for the fast reply! Wow, I didn't know it was a keyword! I'll run to google and search MYSQL KEYWORDS It will save a lot of pain for next time Cheers
  14. Solar

    $_GET?

    Before: mysite.com/user.php?level=site.com/123.php?hp=1 $url = ('' . htmlspecialchars($_GET["level"]) . ''); $urlInfo = parse_url($url); $output = array(); parse_str($urlInfo['query'], $output); echo this; " . ($output['level']) . " After: site.com/123.php?hp=1 Hope this helps?
  15. Error: 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 'like (comment_id, name, like) VALUES ('102','Steven','1')' at line 1 $sql="INSERT INTO like (comment_id, name, like) VALUES ('$_POST[comment_id]','$_POST[name]','$_POST[like]')"; if (!mysql_query($sql,$con)) { die('Error:' . mysql_error()); } echo "You have succesfully liked this comment.<br /><INPUT TYPE=\"button\" VALUE=\"Back\" onClick=\"history.go(-1);\">"; mysql_close($con) Table: comment_idnamelike For some reason, I cannot spot this error. Can you find it? My $con = mysql_connect is a part I left out but it connects fine! The data form is echo'ing fine but it's not inserting into the MySQL Table. Thanks in Advanced!
  16. I don't have any code at this time as I working on other parts of my website, Once I am done that I'm going to give this ago. I have no problems, echo'ing the item database its just the BUY button would be my only problem. But variables from checking the user's amount they have and check against the cost of the item is correct. Thanks Like I posted above, I will try to give this ago, it seems to make more sense to me when you put it that way. Thanks If there are any other solutions, I will be gladly to see them as well
  17. Hello, I am needing of a start to help me make an online little virtual store on my website. Lets say I have a item.table like the following; iditemcostdescription 2Color Name500Color your name anyway you want it to make it stand out on the members list! 1Multi-Color Name1000Color your name anyway you want it to make it stand out on the members list! The only problem where I would have problems is, is the actually buy.. I understand *INSERT* php/mysql so I am fine with that, I will have a seperate list with the item's ID link with my users table.. So my question is, can someone write me a little simple code that will check a user's money in table.users and see if they have enough to purchase an item for table.items when they click buy? If they do not have enough money, then I know how to echo and elseif statement stating that you do not have enough money! Thank you for your help in advanced, I appreciate your time for reading my post.
  18. Question #1 RewriteBase /photo/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ RewriteRule .* /photo/unknown.png [L] Is it possible to remove those extensions and have just nothing? Like say if my photo was; website.com/photo/Solar If Question #1 fails; Question #2 $username = $_SESSION['username']; $target = "./photo/"; $path = pathinfo($_FILES['uploaded']['name']); //gather file data $targetnew = $target.$_SESSION['username'].$path['.']['extension']; $target = $targetnew;unset($targetnew); $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; There is something wrong in this coding that will not allow uploaded images have an "extension", What can I do to fix this?
  19. <?php if ($req_user_info['name'] !=" "){echo "<input type=\"submit\" value=\"Submit\">"; } ?> I have a code like this. If the "$req_user_info['name'] !=" Nothing here " Then it shows the button. How can I put an else if in this statement to make it.. "$req_user_info['name'] !="$session->username " Then disable or do not let the button show. Thanks in Advanced.
  20. LAWL. Imma idiot. Teehee. I have a table called Update... The $SQL was trying to update a row that did not exist, I renamed the table and now its doing what I want it to do.
  21. Yes, Nothing is updating in the "update" table.. I will keep messing around.. I thought I was coding properly, I may have a mis-spelling problem. I will keep checking my coding.
  22. $RETVAL For example; $_POST['username'], $_POST['password'], $_POST['email'], $_POST['age'], $_POST['gender'], $_POST['status'], $_POST['about']/*..etc /* Account edit successful */ if($retval){ $_SESSION['useredit'] = true; header("Location: ".$session->referrer); } After a user has edit their profile; I would like from a different table from the same database to update itself saying "Solar has updated their profile". The table for user's information is "login" and the table I want to update as well is called "update" I would love the table "update" to look like this (allready made, just need it to be inserted); idnamedescription 1Solarhas updated their profile. 2Stevenhas updated their profile. I was thinking something like this; mysql_query("INSERT INTO update (name, description) VALUES ('$session->username', 'has updated their profile')"); But I am having problems putting this puzzle together. I would be happy if someone can get me started P.s. Would I have to close off the first mysql connection before making another one? Or would that work. If there is a mysql code that could also do this trick automatically, that would be amazing! Thanks in advanced!
  23. Solar

    2 $Rows?

    <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="login"; // Database name $tbl_name="forum_titles"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name WHERE cat='general' ORDER BY fid"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); $link = mysql_connect("localhost", "root", ""); mysql_select_db("login", $link); $result2 = mysql_query("SELECT fid FROM forum_question WHERE fid='$fid'", $link); $num_rows = mysql_num_rows($result2); ?> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="53%" align="center" bgcolor="#E6E6E6"><strong>General</strong></td> </tr> <?php while($rows = mysql_fetch_array($result, $result2) ){ // Start looping table row ?> <tr> <td bgcolor="#FFFFFF"> <a href="forums.php?forum=<? echo $rows['fid']; ?>"> <? echo $rows['forum']; ?></a><BR><span class="style1"> <? echo $rows['desc']; ?> - <?php echo "$num_rows"; ?> </span> </td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> What I would like to do is have database-forum_question (Forum Topics) Show how many topics are in that specific database-forum_title (Forum Name). So That being said. My databases look like this; Database Forum_Title fidforumdesccat 1GeneralBlah Blah...1 2SupportBlah Blah...2 Database Forum_Question idfidquestiondetailcat 11General TestBlah Blah...1 22Support TestBlah Blah...2 What I want; For example; General - 4 Topics Support - 2 Topics Anything - 0 Topics I think I am on the right track.. But I know for sure that this following doesn't help. while($rows = mysql_fetch_array($result, $result2) ){ // Start looping table row How would I be able to fix this up? *There is no error, it just results as Zero as the two databases aren't connecting properly*
  24. Haha thanks! Works like a charm, of course when I tried I missed out the '
  25. Oops, I understand that. Doh, silly me. I know how to echo the specific column, what I meant was... Echo the table I provided (Which I have coded) but only show the forum with the specific category for example; fidforumdesccat 1GeneralTalk About Anythinggeneral 2HobbiesTalk About Hobbiesgeneral 3HTML HelpGet help on HTMLhelp Will result into php coding; fidforumdesccat 1GeneralTalk About Anythinggeneral 2HobbiesTalk About Hobbiesgeneral <td bgcolor="#FFFFFF"><? echo $rows['forum']; ?><BR><span class="style1"><? echo $rows['desc']; ?></span></td> But using; $sql="SELECT * FROM $tbl_name ORDER BY fid"; Do I use a whereas in this statement?
×
×
  • 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.