Jump to content

cryp7

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cryp7's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ah excellent, much simpler than i expected thanks. Now one more thing that would be a great help to know is... the code above only shows results if there is an exact match is there an way of printing the results that a close matches and then ordering them in order of closest... I have search the net for this and couldn't find anything. Thanks in advanced Andy
  2. Hello, I have searched all over the internet for a solution and have not found what i was looking for so i thought I'd see if you lovely people would be able to help... I'm looking for a script that filters, multiple times, from my MySQl database and the selects exact match results or results closest to the input data. The only way i could think of doing it is like: $query = mysql_query("SELECT * FROM data WHERE height = '$height' AND WHERE weight LIKE '$weight' AND WHERE shoe LIKE '$shoe' AND WHERE useage LIKE '$useage' AND WHERE skill LIKE '$skill'") or die(mysql_error()); This doesn't work and gives this error I'm really not sure what to try so any help would be appreciated, thanks a lot Andy
  3. Hi, The code I have so far is: [code] <?php mysql_connect("localhost", "HIDDEN", "HIDDEN") or die(mysql_error()); mysql_select_db("HIDDEN") or die(mysql_error()); $category = games; $totalrows = mysql_query("SELECT * FROM games"); or die(mysql_error()); $totalrowsresult = mysql_num_rows($totalrows); or die(mysql_error()); srand ((double) microtime( )*1000000); $randnum = rand(1,'$totalrowsresult'); or die(mysql_error()); $result = mysql_query("SELECT * FROM games WHERE no='randnum'"); while($row = mysql_fetch_array($result)) or die(mysql_error()); echo "$row['no'], $row['id'], $row['data']"; or die(mysql_error()); ?> [/code] What i want it to do is to count the number of rows in the table "games" then select a random number between 1 and how ever many rows there are in the table, then to select the data from the row, where the random number is equal to the value "no" in a row of the "games" table. Then finally to display this infomation. Ive written the above and am unsure whats wrong... The error i get is [quote]Parse error: syntax error, unexpected T_LOGICAL_OR in HIDDEN/select.php on line 9[/quote] Any help I could get would greatly be appreciated. Thanks in advanced Andy
  4. thanks for the wuick reply, is there any secure way to prevent this hacking and any other attempt, or is it utterly hopeless? thanks again andy
  5. If i allowed other people to upload their own PHP (or any other type of file) onto my web sever, what could the consucences be? would they be albe to hack my serve and change the details..or what? i would appreciate the help and look forward to your reply thanks again andy
  6. cheers that worked thanks alot but u needed to add a '; thingy somewhere i know it wasnt intentaly thxs alot again [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] echo 'You do not have enough points'; [/quote]
  7. Ok i have a work buy.php script for a sort of RPG online game, but it still allows users to buy stuff even if they dont have enough "points" [code] <?php require ("db_connect.php"); if ($logged_in == 1) { $username = $_SESSION['username']; $query = "SELECT * FROM users WHERE username='$username'"; $results = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($results) == 0) { die("Not logged in, or your session username doesn't exist"); } while ($row = mysql_fetch_array($results)) { $points = $row['points']; } echo "<font face=\"Arial\"><center>Thank You For Purchasing From The Store<p> The Item Has Been Added And The Cost Deducted<p> Please Dont Forget To Come Again<p><a href=\"inventory.php\">Inventory</a></center></font>"; } else { echo "<font face=\"Arial\"><center>Not Logged In <a href=\"login.php\">Login</a></center></font>"; } mysql_connect("localhost", "xxxy", "xxx") or die(mysql_error()); mysql_select_db("xxx") or die(mysql_error()); $user = $_SESSION['username']; $buyid = $_GET['name']; $item = mysql_query("SELECT item_id, name, description, buy_price, sell_price, img_path FROM items WHERE item_id='$buyid'"); $row2=mysql_fetch_array($item); $buyprice = $row2['buy_price']; $subval = $points-$buyprice; mysql_query("INSERT INTO inventory (id, username, item_id) VALUES('', '$user', '$buyid')"); mysql_query("UPDATE users SET points = '$subval' WHERE username = '$user'"); mysql_free_result($item); mysql_close(); ?> [/code] I was wondering what i could do to fix this and i dont actually have a clue what to do so thxs in advance
  8. EDIT: Ok i worked out forms :D now waht i need to know is how to get values from a database so that i can put them into a drop down box on a form ie. i want to find what items the user has that are "type" = "S" now to do this i need to search the "inventory" table for "item_id"s by "username", then seach "item" table by "item_id" to add a "name" etc to the "item_id" but i wanna sort these items by "type" "S" e.g. user admin has item_id 1,2 and 3 these are: 1 - Blue Ball Skin - type "S" 2 - Green Ball Skin - type "S" 3 - Crazied Blob Skin - type "I" so i need values 1 and 2, selected and then a way to add them to a drop down list in a form... heres what i got so far: [code] <?php mysql_connect("localhost", "xxx", "xxx") or die("Could not connect: " . mysql_error()); mysql_select_db("xxx"); $allitems_id = mysql_query("SELECT id,item_id FROM inventory WHERE username='$username'"); $row10 = mysql_fetch_array($allitems_id); $item_id = $row10['item_id']; $type = "S"; $sitems_id = mysql_query("SELECT name,description,buy_price,sell_price,img_path FROM items WHERE item_id='$item_id' AND type='$type'"); $row11 = mysql_fetch_array($sitems_id); printf ("Name: %s", $row11['name']); mysql_free_result($sitems_id); ?> [/code] although this dosnts print the values, i think its on the right track...? any help welcome thxs
  9. Ok i did a quick search like normal and cudnt find ne thing So what im looking for is the script to search the "user" table for the row "characters" by the "username", and if the value found for the spefic user is "1" then it needs to say sorry cant do it etc. and if its "0" then it should let the rest happen [code] <?php mysql_connect("localhost", "xxx", "xxx") or die("Could not connect: " . mysql_error()); mysql_select_db("xxx"); $create = mysql_query("SELECT characters FROM users WHERE username='$username'"); $results2 = mysql_query($create) or die(mysql_error()); if (mysql_num_rows($results2) == 1) { die("You Already Have A Character, And Cant Make Another - Try Editing Your Character Instead <a href=\"character_edit.php\">Edit Here</a>"); } if ($create == 0) { echo "So Therefore You Can Make One Here:"; } ?> [/code] Thats what i got so far - and i get... [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] 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 'Resource id #19' at line 1 [/quote] so help would be very much appreciated.
  10. thxs for the reply - your right it didn't work but i told me something new... [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] 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 'character WHERE username='admin'' at line 1 [/quote] this doesn't actually mean anything to me :S soz thxs again
  11. Ive Done A Search and cant find ne thing that helps me i got... [code] <?php mysql_connect("localhost", "xxx", "xxx") or die("Could not connect: " . mysql_error()); mysql_select_db("xxx"); $img_skin = "SELECT img_skin FROM character WHERE username='admin'"; $img_skin_res = mysql_query($img_skin); $name = "SELECT name FROM character WHERE username='admin'"; $name_res = mysql_query($name); $row_img=mysql_fetch_array($img_skin_res); $img_skin_string = $row_img['img_skin']; $row_name=mysql_fetch_array($name_res); $name_string = $row_name['name']; echo "IMG: $img_skin_string, Name: $name_string"; mysql_free_result($img_skin_string); mysql_free_result($name_string); ?> [/code] What i want is the results "img_skin" and "name" for admin, which are stored in the "character" table, to be printed...ive tried searching and doing everything that i can think of now im stuck :S And This is what i get [code] Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/andy/public_html/character.php on line 103 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/andy/public_html/character.php on line 106 IMG: , Name: Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/andy/public_html/character.php on line 111 Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/andy/public_html/character.php on line 112 [/code] so help would be loved - thxs
×
×
  • 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.