Hello. -
iGetty - 06.06.2012
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!
Re: Hello. -
DaRealShazz - 06.06.2012
I am new to PHP, but wouldn't you wanna put your variable outside of the quotation marks?
Re: Hello. -
Stereotype - 06.06.2012
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>
Re: Hello. -
Cell_ - 06.06.2012
Hello.
Re: Hello. - kikito - 06.06.2012
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?
Re: Hello. -
iGetty - 06.06.2012
It's fine, I got it all working. Also Kikito, yes I did
.
Re: Hello. -
iLinx - 06.06.2012
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.
Re: Hello. -
Mauzen - 06.06.2012
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
Re: Hello. -
iGetty - 06.06.2012
Thanks guys, I've edited the first post.
Re: Hello. -
donB - 07.06.2012
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($masql, MYSQL_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?