Jump to content

Fira

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Fira's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Awesome, I changed the table name to chara and it worked. Thanks.
  2. I've just removed the ". mysql_error()" portion of the code, and it displays the error "Error at insert character chara."
  3. Yes, either way works, but the problem is the second part of the code, where I'm trying to set chara=0 in table CHARACTER.
  4. Here is my PHP code in adding a new user to two tables, one being USER and the other being CHARACTER. [quote] $newpass = "1"; //substr(md5(time()),0,6);     $sql = "INSERT INTO user SET       userid = '$_POST[newid]',         password = '$newpass',         email = '$_POST[newemail]'";             if (!mysql_query($sql))     error('Error at insert user info.' . mysql_error()); echo "pass1";               $sql = "INSERT INTO character SET           chara = '0'"; if (!mysql_query($sql))     error('Error at insert character info.' . mysql_error()); echo "pass2"; [/quote] Both tables USER and CHARACTER have an auto-increment variable "id," both starting at 1. The code adds in the information into table USER, but not CHARACTER. When I run the code, "pass2" doesn't display, and when I check my character table, it's empty. What's wrong? Note that both tables are empty to begin with, and after the code is run, table USER has been filled out, but table CHARACTER has not.
  5. And if I was to call a value within this returned array? Would I just call it as if it was returned normally?
  6. Is it possible to return multiple values? [quote]return $lifeleft, $epgain, $apgain;[/quote] gets the error [quote]Parse error: parse error, unexpected ',' in C:\WEB_ROOT\battle.php on line 139[/quote] If not, is it possible to return an array of more multiple values?
  7. How do you change the values of variables? I know one method would be [quote] UPDATE user SET variable1 = '15', variable2 = '60' WHERE userid = '$userid'"; [/quote] But what if I wanted to add 5 to variable2? Would I need to first retrieve variable2, add 5 to it, then set the new value to variable2, or is there an easier MySQL command, like UPDATE user ADD?
  8. Yes, that's what I needed. Thanks.
  9. [quote] <?php echo "text1\n"; echo "text2\n"; ?> [/quote] This code results in [quote] text1 text2 [/quote] Is it supposed to?
  10. Simple question - how can I end a block of text with a linebreak?
  11. Problem solved. Thanks everyone.
  12. And global is only needed for usage of variables within functions? edit: Now I'm recieving the error [quote] Parse error: parse error, unexpected '=', expecting ',' or ';' in c:\WEB_ROOT\includes\include.php on line 13 [/quote] Here's line 13 of include.php: [quote] global $epts = (mysql_result($result,0,'ep')); [/quote]
  13. [quote author=AndyB link=topic=109239.msg440162#msg440162 date=1159060412] Why would you want to do that?  It's the order in which you display retrieved data that's important, isn't it? [/quote] Yes, but one of my primary indices "id" is listed as my sixth column. It'd be easier to browse and keep track if I could change the position of "id" to first position.
  14. I've been learning php for a month, and have made decent progress, but seem to have stumbled upon this: I've an include file, named inc.php. Within it stores many variables, one of which is called $var. I've another file, named function.php. It includes inc.php. Within function.php is a function named fun(). Would Fun() be able to recognize $var without any direct declarations within the function itself? And what if Fun() was called from another file that includes function.php? Help is appreciated.
  15. Is it possible to change the order of the columns in a table?
×
×
  • 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.