Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I recently tried to implement this script however I have had some problems with it recently.
$q=mysql_query("select * from users where id='".$row['gamertag']."'");
while($row = mysqli_fetch_array($mw2ranks))
{
echo "<tr><td> ".$i.".";
echo "</td>
<td>$q[username]
</td>
<td>More stuff will go here</td>
<td>More stuff will go here</td>
";
$i++;
}
Then I was thinking the code $q[username] would locate the username located in the data match up. This wasn't the case, can anyone tell me why?
you need to fetch the result after querying it:
$res = mysql_fetch_assoc($q);
Note the danger of SQL-injections as mentioned in the comments. also be aware that the MySQL_* methods are deprecated. use PDO instead.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am tring to learn about the imap function, and I am struggling to understand:
$result = imap_fetch_overview($mbox,"1:{$check->Nmsgs}",0);
In particular $mbox,"1:{$check->Nmsgs}",0
PHP manual says it uses the X:Y syntax.
But I just cant get my head around it.
Please can anyone assist.
This is explained in the docs, which you should definitely start reading now:
When a string is specified in double quotes or with heredoc, variables
are parsed within it.
And follow this link: http://php.net/manual/en/language.types.string.php#language.types.string.parsing
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I am new to PHP and having problems with printing values from database.
This is my code:
<?
$level = $db->Query("SELECT `level` FROM users WHERE `id` = '" . $data['id'] . "'");
$r2 = mysql_fetch_object($level);
?>
And this is what it looks like when I try to print it:
<?php
echo $r2;
?>
And when I try to echo it it doesn't print the value from level but it only loads half of the page.
I would really appreciate if someone could tell me what the problem is?
$level is a mysql result resource. Try adding the following
while ($row = $level->fetch_row()) {
var_dump($row);
}
The query is returning a result resource. You need to use that with a fetch function of some kind to retrieve the actual data. If you're using MySQLi, then you can use mysqli_fetch_row() or similar.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
In learing mongo with php,I have a tiny problem,
that is all,any help would be great appreciated!
You need to read this MongoPHPQueries Page and probably before that you need to do as #RocketHazmat said and start with this MongoPHP Tutorial.
But here is something that might help you with the data you are trying to find.
$cursor = $collection->find(array("addressse.0.state" => "NY"));
The above will give you a cursor allowing you to iterate over each record that is returned. Hope this helps.
FYI - You need more than just that line above to get that to work. So follow the links.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have this query and i am asking if i can print the result in PHP without saving the result in other table.
SELECT SUM(weekly_fees) FROM scout_cabs
You start by giving it an alias to output:
SELECT SUM(`weekly_fees`) AS `total` FROM `scout_cabs`
Then you parse it as any normal request via mysql.
<?php
$sql = "SELECT SUM(`weekly_fees`) AS `total` FROM `scout_cabs`";
$run = mysql_query($sql);
$result = mysql_fetch_assoc($run);
echo 'The sum of the query is: ' . number_format($result['total']);
It may also be worth looking into mysqli_ if you are not already using it, as mysql_ is now deprecated.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am looking to create a simple url where I can add URL querys to it and then have these saved to a database.
This would be the format that i'm looking for
example.com?name=value1&email=value2
Could anybody help ?
Get the values on the script from $_GET, then put them in your database using PDO or MySQLi. I don't know your database structure so I can't really help any further:
// In index.php
echo $_GET["name"];
echo $_GET["email"];
// Put them in your database