Jump to content

uwannadonkey

Members
  • Posts

    162
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male

uwannadonkey's Achievements

Member

Member (2/5)

0

Reputation

  1. i have a table, lets name the table, "food" in table food, theres different kinds of food, and there are chances of one person having multiple amounts of food. how do i select the first instance where id = $user->ID and where item name is apple?
  2. fixed $apple1= Apple; $result=mysql_query("SELECT * FROM food WHERE owner = $user->ID AND name = 'Apple'")or die(mysql_error()); if (mysql_num_rows($result) >= 1) { $apple = mysql_num_rows($result); echo " Apples($apple)"; } apple needed a 'apple' to work
  3. Unknown column 'Apple' in 'where clause' but there is a column apple.. this is a copy of the mysql table: ID owner name effect bonus 1 1 Apple 5 energy 2 1 Apple 2 energy 3 1 Apple 5 energy
  4. 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 '>ID and name = Apple' at line 1
  5. <?php include('inc/header.php'); echo"--- Food---<br>"; $result=mysql_query('SELECT * FROM food WHERE owner = $user->ID and name = Apple'); if (mysql_num_rows($result) >= 1) { $apple = mysql_num_rows($result); echo " Apples($apple)"; } include('inc/footer.php'); ?> thats the code for counting apples, but this comes out: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/trukki4/public_html/averyel/inventory.php on line 8
  6. timestamp works! thanks so much. but now im worried about what wild said. what does he mean by that? im gonna: $message=mysql_real_escape_string($_POST[message']);
  7. FIXED the = to == still, everything is going fine, except for the message and time EDIT: problem solved for the message. how about the timestamp?
  8. for timestamp: the table is named, time, field timestamp, and default 0000-00-000, etc chris, thats not the problem, the thing is, when the message is sent, eevrything gets saved,EXCEPT for the message. ie: the owner,sender,subject get saved, except for timestamp and message and wild: could u explain what you mean
  9. <?php include('inc/header.php'); if(isset($_POST['submit'])) { if ($_POST['owner'] < 1) { echo " You are trying to send a message to an illegal ID!"; } elseif ($_POST['message'] = "") { echo " Please enter a message!"; } else { Echo " Message Sent!"; mysql_query("UPDATE `users` SET mail = mail + 1 WHERE ID = $_POST[owner]"); $query2="INSERT INTO mail(text,owner,sender,subject,time)VALUES ('$_POST[message]','$_POST[owner]', '$user->ID', '$_POST[subject]', 'now()')"; $rt=mysql_query($query2); } } echo" <form method=POST> ID: <input name=owner size=12 maxlength=10 value=$_GET[iD]><br> Subject : <input name='subject' size=12 maxlength=25><br> Message:<br><textarea name='message' cols=25 rows=10></textarea> <input type=submit name=submit id=submit value=Submit> "; include('inc/footer.php'); ?> this is my code, for writing a simple mail. the thing is, everything gets saved in mysql, except the message itself. why is that? also: my timestamp comes out like 0000-00-00-000-00 or something, is the now() the right thing to use?
  10. wow, thanks for your responses! ill test it out and get back to you all. i prefer awpti's snippet, actually.
  11. how can i check if a row EXISTS in my mysql table, through php. for example, i wanna check if ID 6 exists in table, how would i do that.
  12. whoopsies! i made an error! its not: <?php include('inc/index.php or w/e link is"); ?> its <?php include('inc/index.php or w/e link is'); ?> if that doesnt work, i ono what problem is, lol
  13. sry to ask, but first thing first. was $hk ever set?
  14. dont do random, its simple if u just do an autoincrement, with random, theres a chance 2 could be of the same number, and that would ironically be an error
×
×
  • 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.