Jump to content

metalblend

Members
  • Posts

    89
  • Joined

  • Last visited

    Never

Everything posted by metalblend

  1. Actually, crashthatch\'s method would work fine unless the query returned FALSE (meaning it failed; usually a syntax error). Try using quotes around $cuser in the query.. like this: $old_location = mysql_fetch_row(mysql_query("SELECT location FROM qu_user WHERE user=\'$cuser\'")); Hope that helps.
  2. sure.. email them to me: laggor@phirebrush.com
  3. I don\'t know.. there\'s nothing wrong with what you\'ve showed me so far. If it\'s not in functions.php , it\'s in this file you\'re having trouble with. I don\'t know what else to say.. you\'ve only showed me bits of the code.
  4. that code does in fact connect to the database. try creating a new file (test.php) and use this code:[php:1:34891f45c8]<?php $location = \"localhost\"; $username = \"DarthViper3k\"; $password = \"\"; //password removed $database = \"admin\"; $conn = mysql_connect($location,$username,$password); if ($conn==FALSE) die (\"Could not connect MySQL\"); $db = mysql_select_db($database,$conn); if ($db==FALSE) die (\"Could not open database\"); $query = mysql_query(\"SELECT * FROM users\",$conn); if ($query==FALSE) { print \"<code><b>ERROR :</b> QUERY FAILED<br>\".mysql_error().\"</code>\"; } else { print \"Found \".mysql_num_rows($query).\" record(s)\"; } mysql_close($conn); ?>[/php:1:34891f45c8] if you get no errors then there\'s something stray in this page you\'re having trouble with. let us know what happens.
  5. aha! i\'m surprised i missed that. [php:1:ccb7fabe76]$updatequery = \"UPDATE \'items\' SET \'amount\'=\'$newamount\' WHERE \'id\'=\'$itemid\'\";[/php:1:ccb7fabe76]should be:[php:1:ccb7fabe76]$updatequery = \"UPDATE items SET \'amount\'=\'$newamount\' WHERE \'id\'=\'$itemid\'\";[/php:1:ccb7fabe76] no quotes around the table name. and about the errors, that\'s mysql_error() you use it to output the last error generated by mysql from your script
  6. ah sorry i misunderstood.. output some text to see if you get to that part of the loop to update. take this:[php:1:cd392f2d6e]* here we\'ll simply update the amount if it is 1 or more */ elseif ($newamount >= 1) { $updatequery = \"UPDATE \'items\' SET \'amount\'=\'$newamount\' WHERE \'id\'=\'$itemid\'\"; mysql_query($updatequery); }[/php:1:cd392f2d6e] and use this:[php:1:cd392f2d6e]* here we\'ll simply update the amount if it is 1 or more */ elseif ($newamount >= 1) { $updatequery = \"UPDATE \'items\' SET \'amount\'=\'$newamount\' WHERE \'id\'=\'$itemid\'\"; $result = mysql_query($updatequery); print \"we\'re in the UPDATE loop..<br>\"; if ($result==FALSE) { print \"<b>ERROR :</b> QUERY FAILED<br>\".mysql_error(); } }[/php:1:cd392f2d6e]
  7. ok start narrowing it down.. does this cause an error?[php:1:61e98c0148]<?php $location = \"localhost\"; $username = \"DarthViper3k\"; $password = \"\"; //password removed $database = \"admin\"; $conn = mysql_connect(\"$location\",\"$username\",\"$password\"); if ($conn==FALSE) die (\"Could not connect MySQL\"); $db = mysql_select_db($database,$conn); if ($db==FALSE) die (\"Could not open database\"); ?>[/php:1:61e98c0148]
  8. Using this, do you still get an error:[php:1:521bbbb532]<?php $location = \"localhost\"; $username = \"DarthViper3k\"; $password = \"\"; //password removed $database = \"admin\"; $conn = mysql_connect(\"$location\",\"$username\",\"$password\"); if ($conn==FALSE) die (\"Could not connect MySQL\"); $db = mysql_select_db($database,$conn); if ($db==FALSE) die (\"Could not open database\"); $info_query = mysql_query(\"SELECT * FROM users WHERE id=\'$id\'\"); $result = mysql_query($info_query); if ($result==FALSE) { # query failed.. do this print \"QUERY FAILED<br>\".mysql_error(); } else { # query was successful $info = mysql_fetch_array($info_query); } ?>[/php:1:521bbbb532] This sure is frustrating
  9. There\'s absolutely nothing wrong with that code. Going back over the error, where would \"Resource id #2\" come from? The error looks like there\'s an attempt to query the database where \"Resource id #2\" is in the query.. any idea?
  10. Check what happened.. if you got any errors. Take this:[php:1:4e2b4dbcbf]/* here is the new amount of dynobucks */ $newbucks = $dynobucks - $_POST[price]; /* now we\'re updating! */ $bucksquery = \"UPDATE users SET dynobucks=\'$newbucks\' WHERE username=\'$username\'\"; mysql_query($bucksquery); echo \"You bought <b>$itemname</b> for <b>$_POST[price]</b> DynoBucks!<br> You now have <b>$newbucks</b> DynoBucks.<p>nn\"; echo \"<a href=\'shop.php?id=$shopid\'>Return To Shop</a>nn<p>\";[/php:1:4e2b4dbcbf] And replace with this:[php:1:4e2b4dbcbf]/* here is the new amount of dynobucks */ $newbucks = $dynobucks - $_POST[price]; /* now we\'re updating! */ $bucksquery = \"UPDATE users SET dynobucks=\'$newbucks\' WHERE username=\'$username\'\"; $bucksreslt = mysql_query($bucksquery); if ($bucksreslt==FALSE) { echo \"<code><b>ERROR :</b> UPDATE FAILED<br><i>\".mysql_error().\"</i></code>\"; echo \"<a href=\'shop.php?id=$shopid\'>Return To Shop</a>nn<p>\"; } else { echo \"You bought <b>$itemname</b> for <b>$_POST[price]</b> DynoBucks!<br>You now have <b>$newbucks</b> DynoBucks.<p>nn\"; echo \"<a href=\'shop.php?id=$shopid\'>Return To Shop</a>nn<p>\"; }[/php:1:4e2b4dbcbf] If the update encounters an error you\'ll see it now.. of course when you figure out the problem you\'ll probably want to rid of the error report. Hope that helps.
  11. you\'re positive you have 0 queries executed in functions.php ? it would help to see some code.
  12. you should get no SQL syntax errors when connecting to the db can you show me how exactly you\'re connecting?
  13. your query failed. use something like this to check for that and avoid the errors:[php:1:557323ef68]if ($result==FALSE) { # query failed.. do this print \"QUERY FAILED<br>\".mysql_error(); } else { # query was successful $info = mysql_fetch_array($info_query); }[/php:1:557323ef68] basically just remember that mysql_query returns a result handler on success, FALSE on failure. you can use this method to avoid the ugly errors hope that helps.
  14. MS SQL does not have an ENUM data type.. I\'ve responded to your other thread here : http://forums.phpfreaks.com/viewtopic.php?t=3272 Hope that helps.
  15. doh .. yea, i missed that. i\'m used to my $conn connection link. Use this:[php:1:24b28da994]<?php $conn=mysql_connect (\"localhost\", \"burnttoa_tehuser\", \"tehpass\") or die (\'I cannot connect to the database because: \' . mysql_error()); mysql_select_db (\"burnttoa_tehdb\",$conn); $q1 = mysql_query(\"CREATE TABLE roleplayers ( id tinyint(4) DEFAULT \'0\' NOT NULL AUTO_INCREMENT, first varchar(20), last varchar(20), age varchar(3), race varchar(20), PRIMARY KEY (id), UNIQUE id (id))\",$conn); if ($q1==FALSE) { print \"<code><b>error:</b> query1 failed.<br></code>\"; } else { print \"<code>query1 was successful.<br></code>\"; } $q2 = mysql_query(\"INSERT INTO roleplayers VALUES (1,\'Marth\',\'Kujo\',\'23\',\'Elven\')\",$conn); if ($q2==FALSE) { print \"<code><b>error:</b> query2 failed.<br></code>\"; } else { print \"<code>query2 was successful.<br></code>\"; } $q3 = mysql_query(\"INSERT INTO roleplayers VALUES (2,\'Flick\',\'Flick\'s last name is unknown to me.\',\'No Clue!\',\'I think he\'s a little bit of everything...\')\",$conn); if ($q3==FALSE) { print \"<code><b>error:</b> query3 failed.<br></code>\"; } else { print \"<code>query3 was successful.<br></code>\"; } $q4 = mysql_query(\"INSERT INTO roleplayers VALUES (3,\'Mister\',\'Fallende\',\'Unknown... no one knows... not even himself.\',\'That\'s a secret. Bwarhar!\')\",$conn); if ($q4==FALSE) { print \"<code><b>error:</b> query4 failed.<br></code>\"; } else { print \"<code>query4 was successful.<br></code>\"; } mysql_close($conn); ?>[/php:1:24b28da994] or the longer way would be to change all $conn\'s to $dbh\'s
  16. yes in the connection, {HOST} should have been the host address.. \"localhost\" works in most cases. your queries are not PHP, you\'ll need to use PHP\'s query functions to query MySQL:[php:1:9e7885fd9b]$conn = mysql_connect(\"localhost\",$burnttoa_teh_user,$teh_pass); mysql_select_db($burnttoa_teh_db,$conn); $q1 = mysql_query(\"CREATE TABLE roleplayers ( id tinyint(4) DEFAULT \'0\' NOT NULL AUTO_INCREMENT, first varchar(20), last varchar(20), age varchar(3), race varchar(20), PRIMARY KEY (id), UNIQUE id (id))\",$conn); if ($q1==FALSE) { print \"<code><b>error:</b> query1 failed.<br></code>\"; } else { print \"<code>query1 was successful.<br></code>\"; } $q2 = mysql_query(\"INSERT INTO roleplayers VALUES (1,\'Marth\',\'Kujo\',\'23\',\'Elven\')\",$conn); if ($q2==FALSE) { print \"<code><b>error:</b> query2 failed.<br></code>\"; } else { print \"<code>query2 was successful.<br></code>\"; } $q3 = mysql_query(\"INSERT INTO roleplayers VALUES (2,\'Flick\',\'Flick\'s last name is unknown to me.\',\'No Clue!\',\'I think he\'s a little bit of everything...\')\",$conn); if ($q3==FALSE) { print \"<code><b>error:</b> query3 failed.<br></code>\"; } else { print \"<code>query3 was successful.<br></code>\"; } $q4 = mysql_query(\"INSERT INTO roleplayers VALUES (3,\'Mister\',\'Fallende\',\'Unknown... no one knows... not even himself.\',\'That\'s a secret. Bwarhar!\')\",$conn); if ($q4==FALSE) { print \"<code><b>error:</b> query4 failed.<br></code>\"; } else { print \"<code>query4 was successful.<br></code>\"; } mysql_close($conn);[/php:1:9e7885fd9b] Hope that helps.
  17. $conn = mysql_connect("{HOST}",$teh_user,$teh_pass); mysql_select_db($teh_db,$conn); You are now connected and have selected the database under $teh_db. Hope this is what you wanted to know. Some error checking would be nice.
  18. yes, that will work as long as your host has given your account permission to remotely modify the database.
  19. Do you mean you\'re trying to add another column? If so, the syntax is like this: ALTER TABLE tbl ADD colName FIELDTYPE; Hope that helps.
  20. Sorry, take out the parenthesis in both queries: $resultGET = mysql_query("SELECT id,crystal_asteroids,metal_asteroids FROM pa_users ORDER BY id ASC") or die(mysql_error()); and mysql_query("UPDATE pa_users SET crystal_asteroids=\'".$newCA."\',metal_asteroids=\'".$newMA."\' WHERE id=\'".$row[\'id\']."\'") or die(mysql_error()); Hope that helps.
  21. This should do the trick:[php:1:60596a6f97]<?php # assuming you have all these fields: # id = user id # crystal_asteroids = number of crystal asteroids # metal_asteroids = number of crystal asteroids $resultGET = mysql_query(\"SELECT (id,crystal_asteroids,metal_asteroids) FROM table ORDER BY id ASC\") or die(mysql_error()); while ($row = mysql_fetch_array($resultGET)) { $newCA = $row[\'crystal_asteroids\']+1000; $newMA = $row[\'metal_asteroids\']+1000; mysql_query(\"UPDATE table SET (crystal_asteroids=\'\".$newCA.\"\',metal_asteroids=\'\".$newMA.\"\') WHERE id=\'\".$row[\'id\'].\"\'\") or die(mysql_error()); } ?>[/php:1:60596a6f97] Hope that helps.
  22. Try using this:[php:1:ad01b63d88]mysql_query(\"SELECT * FROM agenda WHERE mes=\'\".$current_month.\"\'\") or die(mysql_error());[/php:1:ad01b63d88] Let us know what error you get.
  23. Your link is strange, but try this: print "<a href=\'".$param[\'link_on_day\'].$current_year.$current_month_2.$i_2."\'>".$i."</a>"; Hope that helps.
×
×
  • 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.