Hello.
#1

Edit:

I have a new problem.

Well; two.

1) How do I get multiple results from a sql database and then store them into a string?

I have this:

PHP код:
$masql mysql_query("SELECT * FROM Accounts WHERE MasterAccount='$user'");
$marow mysql_fetch_row($masql); 
And

PHP код:
<div align="center"><h5>Current Characters</h5>
                <p><b><?php echo $marow[1]; ?></b></p></div>
IT should show up to 4 characters, not just one.

Also;

PHP код:
$sql mysql_query("INSERT INTO Accounts (Username,Password,IP,MasterAccount) VALUES('$charname','$password', '$ip', '$user')") or die (mysql_error()); 
That doesn't store the result of $user into the MasterAccount section on the Table. It just leaves it blank.

Thanks!
Reply
#2

I am new to PHP, but wouldn't you wanna put your variable outside of the quotation marks?
Reply
#3

if u make something in php for email it should be like this .. $email

i mean

PHP код:
<?php echo "\$" $row['$email']; ?>
That what u maked means like you searching all from the base

See here : http://www.learnphp-tutorial.com/Sessions.cfm

or try like this

PHP код:
echo "<div align='center'>$email</div> 
Reply
#4

Hello.
Reply
#5

PHP код:
$newsql mysql_query("SELECT * FROM Member WHERE id = '$userid'");
$row mysql_fetch_array($newsql);  
echo 
'<p><center><b>E-mail Address: </b></center><div align="center"><b>'$row['email'].'</b></div></p>'
Just to know, did you escaped the $userid?
Reply
#6

It's fine, I got it all working. Also Kikito, yes I did .
Reply
#7

Just saying if you wanted to put a variable inside a double-quote string (this is possible), this is the correct format:

PHP код:
echo "<div align='center'>{$email}</div> ... 
Not including the braces can confuse the compiler in some cases.
Reply
#8

The query is the problem I guess. Variables in strings arent parsed afaik, use . to concatenate strings:

PHP код:
$newsql mysql_query("SELECT `email` FROM Member WHERE id='".$userid."'");
$row mysql_fetch_assoc($newsql); 
NVM just read you already solved it
Reply
#9

Thanks guys, I've edited the first post.
Reply
#10

Quote:
Originally Posted by iGetty
Посмотреть сообщение
Edit:

I have a new problem.

Well; two.

1) How do I get multiple results from a sql database and then store them into a string?

I have this:

PHP код:
$masql mysql_query("SELECT * FROM Accounts WHERE MasterAccount='$user'");
$marow mysql_fetch_row($masql); 
And

PHP код:
<div align="center"><h5>Current Characters</h5>
                <p><b><?php echo $marow[1]; ?></b></p></div>
IT should show up to 4 characters, not just one.
I understand that you're trying to retrieve all the field values for the 'MasterAccount' $user, and displaying them in php.
If that's the case, try this:
PHP код:
$masql mysql_query("SELECT * FROM Accounts WHERE MasterAccount='$user'");
if(
$masql)
{
while(
$marow mysql_fetch_array($masqlMYSQL_NUM))
{
$field1 $marow[0];
$field2 $marow[1];
// and so on.. to whatever values you need in the table 'Accounts'
}} 
Now, displaying them in php,
PHP код:
<div align="center"><h5>Current Characters</h5>
                <p><b><?php echo "$field1 <br /> $field2 </br> And so on.."?></b></p></div>
Quote:
Originally Posted by iGetty
Посмотреть сообщение
Also;

PHP код:
$sql mysql_query("INSERT INTO Accounts (Username,Password,IP,MasterAccount) VALUES('$charname','$password', '$ip', '$user')") or die (mysql_error()); 
That doesn't store the result of $user into the MasterAccount section on the Table. It just leaves it blank.

Thanks!
Do the remaining values store the result as expected?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)