Jump to content

Dirty-Rockstar

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Dirty-Rockstar's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. im new at php, and im always scared im going to leave something open for someone to break my tables. By formatting i ment is it a standard practice to use a die message to display a lot of information. I guess it shouldnt hurt anything. ill try it...thanks
  2. I have a site with a sidebar with links and then whatever i want to display on the right (sidebar is an include) on index.php it looks for a session and if theres no session theres a standard die message of "login to view". but i had this really crazy idea where to make my die message an actual "page" where users that are not logged in viewing the index page would see a statistics page (multiple queries to db displaying stuff). is this proper php formatting? can it be done without any security holes? can it be done period?
  3. i have snippits of code from templates to help me on my php journey. and now im trying to learn joining tables. I found this code and i was wondering if someone could decrypt the shorthand for me and give me a better example. someone looked at it and said it was a "dirty join" lol could someone make the shorthand better for me so i can actually read it? $inv=mysql_query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_userid={$userid} ORDER BY i.itmtype ASC, i.itmname ASC",$c); the only thing i can get out of it is its trying to join 2 or 3 tables...and its ordered first by itemtype and then the name. and $c is the connection from the db but i dont even think you need that. i can understand some, but i thought some experts can help me. someone give me a better example from whatever that german code says?
  4. If i told you i worked for about an hour on that thing you would probably spit your coffee on your monitor issue resolved
  5. test1.php <?php include('sidebar.php'); print " <center><table> <tr> <td><form action=test.php method=post>Item name:</td> <td><input type=text name=itemname></td> </tr> <tr> <td>description: </td> <td><input type=text name=description></td> </tr> </table> <input type=submit value=Submit></form>"; print "</body></html>"; ?> test.php <? include('sidebar.php'); print "$_POST[itemname] <br /> $_POST[description]<br />"; $iteminsert1="INSERT INTO items (itemname, description) VALUES ( '{$_POST['itemname']}','{$_POST['description']}'"; $iteminsert2=mysql_query($iteminsert1) or die(mysql_error()); if ($iteminsert2) { print "Inserted"; }else{ Print "didnt work"; }; ?> Result: table fields: itemID (bigint20) (auto increment) itemname (text) description (text) I cant figure it out--thanks
  6. hrmm im thinking on doing it this way. 2 item tables 1 table to house the unique id of an item/name and information about the item and a second table housing the player ID and amount that the user has. im going to try that one = )
  7. im building one of those endless fun text based games Its more of a hobby to learn php. heres my situation I have a table called players which house many things including playerID i want to make another table called items, then when items are inserted i want to display items belonging to playerID. question is how do i connect the 2 of them. do i insert playerID into the item table on signup so i can use this? $id=$_SESSION['playerID']; $item1="SELECT * FROM items WHERE playerID='$id'"; $item2=mysql_query($item1) or die(mysql_error()); $item3=mysql_fetch_array($item2); print "$item3[itemnamehere]"; or is there an easier answer to query both tables. or will i have to use this method. this is my first experience in 2 tables
  8. yep that is exactly how it is, i always put my included pages at the top of each page before i code (after the start tags of course) and on include.php the first thing is the session thanks
  9. user logs in, passes thru auth.php..if that passes $_Session[usersession] is now true. on include.php i have session_start(); include.php is on all pages. do i have to have session_start(); on any other pages to keep session active? or will include.php do it for me hope i worded that right
  10. wow, you people must eat php for breakfast. I just started learning and 2 posts in here just made me scratch my head. interesting opinions on print/echo and code formatting tho.
  11. i understand, but for simple db queries and updates using print or echo to display the information does it really matter? i was taught on print, and to avoid echo all the times for what im coding anyway, which is not too complaicated. just queries, updates and inserts into 1 db then displaying that information based on certain variables and results here is an example of a snippit of code from a forum i made $ID=$_GET[iD]; $user1="SELECT * FROM {$db_prefix}question where id='$ID'"; $user2=mysql_query($user1) or die(mysql_error()); $user3=mysql_fetch_array($user2); print "Choose the Topic you want to move this thread to<br> Topic is:<br /> $user3[topic]<br />"; i ended print but in the code it continues. could i use echo to get the same result?
  12. Hi, im new. was referred by a friend. anyway My friend uses echo ' '; i use print " "; Is there a difference? or coder preference
×
×
  • 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.