hello i have this code:
$thread_qry5= "SELECT * FROM xenProve_prove ORDER BY view_count DESC LIMIT 5";
$row5 = XenForo_Application::get('db')->fetchAll($thread_qry5);
foreach ( $row5 AS $rows5 ) {
$viewid = $rows5['thread_id'];
$viewtitle = $rows5['title'];
$viewuser = $rows5['username'];
$MostView .= 'div style="height:30px; width:640px; border-bottom:1px solid #999;padding:5px;">
<div style="height:40px; width:500px;float:left">
<div style="height:20px; width:650px; font-size:16px;color:#6d3f03;">'.$viewtitle.'</div>
<div style="height:20px; width:650px; font-size:12px;color:#6d3f03;">'.$viewuser.'</div>
</div>
</div>';
how can replace this symbol .= ?
Xenforo system don't read this symbol (.=)
I tried :
$MostView = 'div style="height:30px; width:640px; border-bottom:1px solid #999;padding:5px;">
<div style="height:40px; width:500px;float:left">
<div style="height:20px; width:650px; font-size:16px;color:#6d3f03;">'.$viewtitle.'</div>
<div style="height:20px; width:650px; font-size:12px;color:#6d3f03;">'.$viewuser.'</div>
</div>
</div>' . $MostView;
but don't work.
And i tried the For cycle anche the While cycle but don't work.
Thanks you
You are trying to add a string to another string (by a concatenating assignment operator) that doesn't exist (yet). You have to define the string first:
$MostView = '';
and then:
foreach ( $row5 AS $rows5 ) {
$viewid = $rows5['thread_id'];
$viewtitle = $rows5['title'];
$viewuser = $rows5['username'];
$MostView .= 'div style="height:30px; width:640px; border-bottom:1px solid #999;padding:5px;">
<div style="height:40px; width:500px;float:left">
<div style="height:20px; width:650px; font-size:16px;color:#6d3f03;">'.$viewtitle.'</div>
<div style="height:20px; width:650px; font-size:12px;color:#6d3f03;">'.$viewuser.'</div>
</div>
</div>';
I don't think this problem is related to XenForo. If you turn on error reporting (just check Google or Stack Overflow) you will get more usefull information about this error.
Related
I want to conditionally display a div so when there are no values, the div is not displayed.
Without the php if part, all is working fine, the css styles are applying to the divs.
But when i add the if condition, the CSS doesn't apply anymore.
Here is the div part:
<?php
$getCar_1 = getCar_1();
$getCar_2 = getCar_2();
if(!empty($getCar_1) || !empty($getCar_2)){
?>
<div class="block">
<div class="up">
<div class="title"><h4>Cars</h4></div>
</div>
<div class="down">
<div class="column_1"><b><?php getCar_1(); ?></b></div>
<div class="column_2"><b><?php getCar_2(); ?></b></div>
</div>
</div>
<?php
}
?>
and here is the CSS part:
.block{
width:900px;
margin:0 auto;
overflow:hidden;
float:left;
}
.up{
width:100%;
text-align:center;
border:1px solid;
margin-top:10px;
margin-bottom:10px;
background-color:skyblue;
}
.down{
width:100%;
clear:both;
}
.column_1{
float:left;
width:47%;
padding:10px;
}
.column_2{
float:right;
width:47%;
text-align:right;
padding:10px;
}
I know this code is very simple but i can't understand why it is not working properly.
To be more specific.
If i use only this code:
<div class="block">
<div class="up">
<div class="title"><h4>Cars</h4></div>
</div>
<div class="down">
<div class="column_1"><b><?php getCar_1(); ?></b></div>
<div class="column_2"><b><?php getCar_2(); ?></b></div>
</div>
</div>
it display normal:
using only div
And when adding the php if part it display this:
ading php if
So when i add the php if, the css has no effect anymore. I also tried the inline styling variant like <div class="block" style="......"> but it won't work this way either.
EDIT: I'm back because i think the issue comes from the functions get getCar_1(); and getCar_2(); which are in functions.php page and look like this:
<?php
function getCar_2(){
global $connect;
$get_car_2 = "SELECT * FROM cars WHERE category_id=5";
$get_car_result_2 = mysqli_query($connect, $get_car_2) or die(mysqli_query());
while($row_car_2 = mysqli_fetch_array($get_car_result_2)){
$car_model_2 = $row_car_2['car_name'];
$car_image_2 = $row_car_2['car_image'];
if(isset($car_model_2) && isset($car_image_2)){
echo "
<div id='' style='white-space:nowrap;'>
<p id='model' style='display:inline-block; margin-right:10px; margin-left:10px; padding-top:10px; position:relative; bottom:35px;'>$car_model_2</p></a>
<img src='administrator/images/$car_image_2' width='120' height='80' style='display: inline-block; box-shadow: 0 0 11px #000;'/><br>
</div>";
}
}
}
?>
Instead of:
if(!empty($getCar_1) || !empty($getCar_2)){
?>
Try this:
if((!empty($getCar_1) || (!empty($getCar_2)): ?>
and instead of:
<?php
}
?>
Try this:
<?php endif; ?>
You are not returning anything from getCar_2() function. What value you expect to be in $getCar_2 by line : $getCar_2 = getCar_2(); same question about getCar_1() function if its same like getCar_2() with no return statement in it.
Problem is that your if block will never execute because your condition:
if((!empty($getCar_1) || (!empty($getCar_2)):
will never be true as $getCar_1 and $getCar_2 variables will always be empty since getCar_1() and getCar_2() are not returning anything.
So only echo you are providing from the function getCar_2() and getCar_1() is being printed as output to HTML and your if block is not executing at all.
You should put return statement in getCar_2() and getCar_1() functions if you want if block to work.Like this:
Instead of:
<?php
function getCar_2(){
global $connect;
$get_car_2 = "SELECT * FROM cars WHERE category_id=5";
$get_car_result_2 = mysqli_query($connect, $get_car_2) or die(mysqli_query());
while($row_car_2 = mysqli_fetch_array($get_car_result_2)){
$car_model_2 = $row_car_2['car_name'];
$car_image_2 = $row_car_2['car_image'];
if(isset($car_model_2) && isset($car_image_2)){
echo "
<div id='' style='white-space:nowrap;'>
<p id='model' style='display:inline-block; margin-right:10px; margin-left:10px; padding-top:10px; position:relative; bottom:35px;'>$car_model_2</p></a>
<img src='administrator/images/$car_image_2' width='120' height='80' style='display: inline-block; box-shadow: 0 0 11px #000;'/><br>
</div>";
}
}
}
?>
Use this:
<?php
function getCar_2(){
global $connect;
$response = NULL;
$get_car_2 = "SELECT * FROM cars WHERE category_id=5";
$get_car_result_2 = mysqli_query($connect, $get_car_2) or die(mysqli_query());
while($row_car_2 = mysqli_fetch_array($get_car_result_2)){
$car_model_2 = $row_car_2['car_name'];
$car_image_2 = $row_car_2['car_image'];
if(isset($car_model_2) && isset($car_image_2)){
$response = 'success';
echo "
<div id='' style='white-space:nowrap;'>
<p id='model' style='display:inline-block; margin-right:10px; margin-left:10px; padding-top:10px; position:relative; bottom:35px;'>$car_model_2</p></a>
<img src='administrator/images/$car_image_2' width='120' height='80' style='display: inline-block; box-shadow: 0 0 11px #000;'/><br>
</div>";
}
}
return $response;
}
?>
I hope it helps
To me seems to be something wrong where you are printing the data, it should be:
<?php
$getCar_1 = getCar_1();
$getCar_2 = getCar_2();
if(!empty($getCar_1) || !empty($getCar_2)){
?>
<div class="block">
<div class="up">
<div class="title"><h4>Cars</h4></div>
</div>
<div class="down">
<div class="column_1"><b><?php echo $getCar_1; ?></b></div>
<div class="column_2"><b><?php echo $getCar_2; ?></b></div>
</div>
</div>
<?php
}
?>
EDIT: The issue was solved with the help of an admin from another forum. As Banzay said it would have been good if i would post the get getCar_1(); and getCar_2(); functions earlier.
The issue was with the functions. Anyway if other beginners like me will have this issue here is the solution.
I modified this:
<?php
function getCar_2(){
global $connect;
$get_car_2 = "SELECT * FROM cars WHERE category_id=5";
$get_car_result_2 = mysqli_query($connect, $get_car_2) or die(mysqli_query());
while($row_car_2 = mysqli_fetch_array($get_car_result_2)){
$car_model_2 = $row_car_2['car_name'];
$car_image_2 = $row_car_2['car_image'];
if(isset($car_model_2) && isset($car_image_2)){
echo "
<div id='' style='white-space:nowrap;'>
<p id='model' style='display:inline-block; margin-right:10px; margin-left:10px; padding-top:10px; position:relative; bottom:35px;'>$car_model_2</p></a>
<img src='administrator/images/$car_image_2' width='120' height='80' style='display: inline-block; box-shadow: 0 0 11px #000;'/><br>
</div>";
}
}
}
?>
into this:
<?php
function getCar_2(){
global $connect;
$text = "";
$get_car_2 = "SELECT * FROM cars WHERE category_id=5";
$get_car_result_2 = mysqli_query($connect, $get_car_2) or die(mysqli_query());
while($row_car_2 = mysqli_fetch_array($get_car_result_2)){
$car_model_2 = $row_car_2['car_name'];
$car_image_2 = $row_car_2['car_image'];
if(isset($car_model_2) && isset($car_image_2)){
$text = "
<div id='' style='white-space:nowrap;'>
<p id='model' style='display:inline-block; margin-right:10px; margin-left:10px; padding-top:10px; position:relative; bottom:35px;'>$car_model_2</p></a>
<img src='administrator/images/$car_image_2' width='120' height='80' style='display: inline-block; box-shadow: 0 0 11px #000;'/><br>
</div>";
}
}
return $text;
}
?>
I replaced echo "..." with $text = "..." and returned the variable after the while closing bracket, like this: return $text;
In order to work the $text variable must be initiated before the query like this: $text = "";
I am currently having a trouble using the radio button, I'm getting confuse because of the output of my codes. In the left picture that's what my output like, in the right picture I want my output like that. When I choose from the candidates both radio button can choose instead of only one should be can be chosen.
Here's my code:
<?php
$YearNow=Date('Y');
$dsds=$rowasa['posid'];
$results = $db->prepare("SELECT * FROM candidates,student,school_year,partylist where student.idno = candidates.idno AND school_year.syearid = candidates.syearid AND posid =:a AND candidates.partyid = partylist.partyid AND school_year.from_year like $YearNow ");
$results->bindParam(':a', $dsds);
$results->execute();
for($i=0; $rows = $results->fetch(); $i++){
?>
//here's the part that i was confuse
<input type ="radio"><input style="padding: 35px 50px 35px 80px; background:url('admin/candidates/images/<?php echo $rows['image']; ?>') no-repeat scroll 5px 7px / 70px auto rgba(0, 0, 0, 0);"
value="<?php echo $rows['candid'] . "-" ." ". $rows['lastname'] .",". " ". $rows['firstname'] ?>"><?php echo $rows['lastname'] ?>,
<?php echo $rows['firstname'] ?>
- <?php
echo $rows['party_name']?>
<?php
}
?>
It looks like you SQL query is giving you the right results however I would really look into using JOINs. Regardless, im assuming your SQL results are something like this:
$candidates = array(
array(
"id" => "1",
"firstname" => "John",
"image" => "some/image/path",
"party_name" => "Party1",
),
array(
"id" => "2",
"firstname" => "Jane",
"image" => "some/image/path",
"party_name" => "Party2",
)
);
To iterate through this and build your HTML, it will be a lot easier to use foreach like so:
<form method="post" action="submit.php">
<?php
foreach ($candidates as $candidate) {
?>
<div class="box">
<div class="image">
<img src="admin/candidates/images/<?php echo $candidate['image']; ?>" alt="">
</div>
<div class="input">
<input type="radio" name="candidate_selected" value="<?= $candidate['id'] ?>">
</div>
<div class="text">
<?php echo $candidate['firstname'] . " - " . $candidate['party_name'] ?>
</div>
</div>
<?php
}
?>
<input type="submit">
</form>
Notice how the input has the same name and the id of your candidate results. Once this is submitted, you should only see the id of the selected candidate in your submit.php handler.
Now add some CSS:
.box {
display: inline-block;
text-align: center;
}
.box .image {
padding: 15px;
}
.box .image img {
width: 150px;
height: 150px;
display: block;
}
Hope this helps.
Try echo the radio button like this.
<?php
$YearNow=Date('Y');
$dsds=$rowasa['posid'];
$results = $db->prepare("SELECT * FROM candidates,student,school_year,partylist where student.idno = candidates.idno AND school_year.syearid = candidates.syearid AND posid =:a AND candidates.partyid = partylist.partyid AND school_year.from_year like $YearNow ");
$results->bindParam(':a', $dsds);
$results->execute();
for($i=0; $rows = $results->fetch(); $i++){
//here's the part that i was confuse
echo "<input type ='radio'><input style='padding: 35px 50px 35px 80px; background:url('admin/candidates/images/". $rows['image'] . "') no-repeat scroll 5px 7px / 70px auto rgba(0, 0, 0, 0);
value='" . $rows['candid'] . " - "$rows['lastname'] ", ". $rows['firstname'] . "'>" . $rows['lastname'] . "," . $rows['firstname'];
echo $rows['firstname'] ." - ". $rows['party_name'];
}
?>
I want to check the equality of the "$v" and "$formats2". But it gives and error message
Warning: strcmp() expects parameter 2 to be string, array given in C:\xampp\htdocs\playit2\product.php on line 312
Here is my HTML code.
$jsqla = mysql_query("select * from products where id='$product_id'") or die(mysql_error());
$jfeta = mysql_fetch_assoc($jsqla);
$formats = explode(";", $jfeta['formats']);
$jsqla2 = mysql_query("select formats from request_list where id='$product_id'") or die(mysql_error());
$jfeta2 = mysql_fetch_assoc($jsqla2);
$formats2 = explode(";", $jfeta2['formats']);
<div class="">
<?php if($formats2 != "") { ?>
<?php foreach($formats as $v){ ?>
<label style="line-height: 1.25em;display: block;width: 100px;margin-right: 10px;float: left;">
<div id="format-id_<?php echo $v?>" <?php if (strcmp($v, $formats2) === 0) { ?> style="border: 1px solid;border-radius: 9px;text-align: center;padding-top: 10px;padding-bottom:10px;padding-left: 3px;padding-right: 3px;border-color: #cccccc;font-family: 'SSemibold'; font-size: 13px; color: #44b7da; background-color: #cccccc;" <?php } else { ?> style="border: 1px solid;border-radius: 9px;text-align: center;padding-top: 10px;padding-bottom:10px;padding-left: 3px;padding-right: 3px;border-color: #cccccc;font-family: 'SSemibold'; font-size: 13px; color: #44b7da;" <?php } ?>>
<input class="format_cheks" type="radio" value="<?php echo $v; ?>" name="abc" style="visibility:hidden;" id="<?php echo $v ?>" onClick="changeColour(this)"/>
<span style="margin:-17px auto auto 0px;display:block;"><?php echo $v; ?></span>
</div>
</label>
<?php } ?>
<?php } else { ?>
<?php foreach($formats as $v){ ?>
<label style="line-height: 1.25em;display: block;width: 100px;margin-right: 10px;float: left;">
<div id="format-id_<?php echo $v?>" style="border: 1px solid;border-radius: 9px;text-align: center;padding-top: 10px;padding-bottom:10px;padding-left: 3px;padding-right: 3px;border-color: #cccccc;font-family: 'SSemibold'; font-size: 13px; color: #44b7da;">
<input class="format_cheks" type="radio" value="<?php echo $v; ?>" name="abc" style="visibility:hidden;" id="<?php echo $v ?>" onClick="changeColour(this)"/>
<span style="margin:-17px auto auto 0px;display:block;"><?php echo $v; ?></span>
</div>
</label>
<?php } ?>
<?php } ?>
</div>
You mistyped implode as explode. The latter takes a string and produces an array. You likely want the opposite. UPD: Oh, you already have a string. Then simply use it as is:
- $formats2 = explode(";", $jfeta2['formats']);
+ $formats2 = $jfeta2['formats'];
Hope it helps.
You also use
if( $val1 === $val2){
//true part . this === strictly check
}
You should pass the key as after explode it will contain an array.
strcmp($v, $formats2[key])
explode()
So I have this code, and I've been fretting over it for several hours now and my friend and I can't find the solution. It display reviews based on a descending ID pulled from a database. This is an endless scroll type of script to eliminate pagination. For some reason when I hit the bottom of the page and run the script, the while loop is iterating through the data twice. So if its supposed to display reviews ID 5 - 10, it display 10, 9, 8, 7, 6, 5, 10, 9, 8, 7, 6, 5; instead of 10, 9, 8, 7, 6, 5. This is going to be a very large bit of code, But I hope you can help me with my problem.
Thanks in advance!!
<?php
include("../mysql_server/connect_to_mysql.php");
if($_GET['lastPost']) {
$mysqlQuery = mysql_query('SELECT * FROM `reviews` WHERE `review_id` < "' . $_GET['lastPost'] . '" ORDER BY `review_id` DESC LIMIT 0, 10');
while ($review_row = mysql_fetch_assoc($mysqlQuery)) {
$review_title = $review_row['review_title'];
$user_id = $review_row['user_id'];
$user_firstname = $review_row['user_firstname'];
$user_lastname = $review_row['user_lastname'];
$review_id = $review_row['review_id'];
$review_body = $review_row['review_body'];
$review_referral = $review_row['review_referral'];
// Code to append text for title
// strip tags to avoid breaking any html
$review_title = strip_tags($review_title);
if (strlen($review_title) > 30) {
// truncate string
$stringCut = substr($review_title, 0, 30);
// make sure it ends in a word so assassinate doesn't become ass...
$review_title = substr($stringCut, 0, strrpos($stringCut, ' ')).'...';
}
// Code to append text and add Read More
// strip tags to avoid breaking any html
$review_body = strip_tags($review_body);
if (strlen($review_body) > 230) {
// truncate string
$stringCut = substr($review_body, 0, 230);
// make sure it ends in a word so assassinate doesn't become ass...
$review_body = substr($stringCut, 0, strrpos($stringCut, ' ')).'... <a class="reviewContentLink" href="../../pages/home_page/post_content.php?id='. $review_id .'">See Full Post</a>';
} else {
$review_body .= '<a class="reviewContentLink" href="../../pages/home_page/post_content.php?id='. $review_id .'">See Full Post</a>';
}
$review_date = $review_row['review_date'];
$review_date = date_create($review_date);
$review_date = date_format($review_date, 'g:ia \o\n F jS\, Y');
$user_firstname = $review_row['user_firstname'];
$review_rating = $review_row['rating'];
/////// Mechanism to Display Pic. See if they have uploaded a pic or not //////////////////////////
$check_pic = "../members/$user_id/thumb_image01.jpg";
$default_pic = "../members/0/image01.jpg";
if (file_exists($check_pic)) {
$review_pic = "<img src=\"../$check_pic\" width=\"80px\" />";
} else {
$review_pic = "<img src=\"../$default_pic\" width=\"80px\" />";
}
include_once('../include/star_display.php');
//Pull the Review Category from the row
$review_category = "";
$review_category = $review_row['review_category'];
include_once('../include/review_category.php');
//Pull the Referral Category from the row
$referral_category = $review_row['referral_category'];
include_once('../include/referral_category.php');
//Code for URL for Each Review
$review_url = $review_row['review_url'];
if (!function_exists('remove_http')) {
function remove_http($url = '') {
return(str_replace(array('http://','https://'), '', $url));
}
}
//CODE TO DISTINGUISH REFERRALS FROM REVIEWS
//Final Output List
if($review_referral == 0) {
//Code for Displaying URL Link
$review_url = remove_http($review_url);
$review_url = "<a target='_BLANK' href='http://". $review_url ."'>Buy It Here!</a> ";
echo ''. $review_id .' '. $review_referral .'
<div class="display_newsfeed" id="'.$review_id.'">
<table id="'.$review_id.'" style="width:98.5%; border:#00B347 1px solid; margin:10px 0px 20px 10px;">
<td style="float:left; width:15%; border-right:1px solid #DDDDDD; margin:5px 0px 5px 0px;">
<div class="review_user_name">'. $user_firstname.' '. $user_lastname .'</div>
<div class="review_prof_pic">'. $review_pic .'</div>
<div class="bought_it_newsfeed">Bought It!</div>
</td>
<td style="float:right; width:82%;">
<div class="review_title_p">
<p><span class="review_title">'. $review_title .'</span><span class="review_date_p">'. $review_date .'</span><span class="review_stars">'. $review_stars .'</span></p>
</div>
<div class="review_read_more">
<p class="review_body_p">'. $review_body .'</p><br />
<div>
<div style="float:left;" class="review_black_font_link">Website:'.$review_url.'</div>
<div style="float:right; margin-right:20px;" class="review_black_font_link">Category: '.$review_category_post .'</div>
</div>
</div>
</td>
</table>
<hr style="margin:0px 20px 0px 20px;" />
</div>
';
} else if($review_referral == 1) {
//Code for Displaying URL Link
$review_url = remove_http($review_url);
$review_url = "<a target='_BLANK' href='http://". $review_url ."'>Click Here</a> ";
echo '
<div class="display_newsfeed" id="'.$review_id.'">
<table id="'.$review_id.'" style="width:98.5%; border:#0099FF 1px solid; margin:10px 0px 20px 10px;">
<td style="float:left; width:15%; border-right:1px solid #DDDDDD; margin:5px 0px 5px 0px;">
<div class="review_user_name">'. $user_firstname.' '. $user_lastname .'</div>
<div class="review_prof_pic">'. $review_pic .'</div>
<div class="referral_newsfeed">Referral</div>
</td>
<td style="float:right; width:82%;">
<div class="review_title_p">
<p>'. $review_title .'<span class="review_date_p">'. $review_date .'</span><span class="review_stars">'. $review_stars .'</span></p>
</div>
<div class="review_read_more">
<p class="review_body_p">'. $review_body .'</p><br />
<div>
<div style="float:left;" class="review_black_font_link">Business Website:'. $review_url .'</div>
<div style="float:right; margin-right:20px;" class="review_black_font_link">Category: '. $referral_category_post .'</div>
</div>
</div>
</td>
</table>
<hr style="margin:0px 20px 0px 20px;" />
</div>
';
}
}
} else {
echo "didn't work";
}
?>
Are you also sure there is no corruption in your database? you can try just
while ($review_row = mysql_fetch_assoc($mysqlQuery)) {
echo $review_row['review_title'] . "<br />";
}
Can you post the code that calls/posts to this script? As the others stated, it is quite possible this code is being called twice.
Also, if you run this query directly in the database, what is returned?
SELECT *
FROM `reviews`
WHERE `review_id` < (insert the id here)
ORDER BY `review_id` DESC
LIMIT 0, 10
I'm creating an online game and I have a problem with updating some fields in database.
Here's the form and the php code.
<form method='post'>
<div style="float: left; width: 630px; color: white;">
<div style="float: left; width: 400px; background: #555; height: 20px;">
<?php
if ($row['Protected'] == 1)
{
?>
<img src="images/pass.png"></img>
<input type="password" name="pass" placeholder="Password" style="height: 18px;" />
<?php
}
echo("<input type='submit' name='enter' style='background: #555; text-decoration: underline;' value='$row[Name]' />");
?>
</div>
<div style="float: right; width: 229px; background: #555; margin-left: 1px; height: 20px;">
<?php
echo($row['NrPlayers']);
echo("/");
echo($row['MaxPlayers']);
echo(" Players");
?>
</div>
<div style="clear: both;">
<?php
echo($row['Descr']);
?>
</div>
<div style="background: #ccc; font-size: 13px; margin-bottom: 2px; color: black;">
<?php
echo($row['FName']);
echo(" ");
echo($row['LName']);
?>
</div>
<input type="hidden" name="id" value="<?php$row['Id_Room']?>" />
<input type="hidden" name="protect" value="<?php$row['Protected']?>" />
<input type="hidden" name="password" value="<?php$row['Pass']?>" />
<input type="hidden" name="nr" value="<?php$row['NrPlayers']?>" />
</div>
</form>
<?php
if (isset($_POST['enter']))
{
if ($_POST['protect'] == 1)
{
if ($_POST['pass'] == $_POST['password'])
{
$nr = $_POST['nr'] + 1;
mysql_query("upadte users set Id_Room = '$_POST[id]' where Id_User = '$_SESSION[id]'");
mysql_query("update rooms set NrPlayers = '$nr' where Id_Room = '$_POST[id]'");
header("Location: game.php");
}
else
{
?>
<span style="color: red; text-align: center;">The password you entered is incorrect.</span>
<?php
}
}
else
if (($_POST['protect'] == 0))
{*/
$nr = $_POST['nr'] + 1;
mysql_query("upadte users set Id_Room = '$_POST[id]' where Id_User = '$_SESSION[id]'");
mysql_query("update rooms set NrPlayers = '$nr' where Id_Room = '$_POST[id]'");
header("Location: game.php");
}
}
?>
There are two updates and one redirect. So, updates don't work but redirect does.
Step 1:
Submit the form to a template, then dump out all your values from the form scope to ensure your getting what you need through from the form.
Step 2:
Using some test values write your queries in a query editor like mysql work bench or php myAdmin so that you have working queries.
Step 3:
Write the code that generates your queries in php, but instead of executing it dump it out to screen. Do this until the outpu looks like the query you designed in the step 2.
Step 4:
Finish the page and execute the query, look out for typos, syntax errors and security holes. then dump out results from the query.
Things you need to check in your current code:
mysql_query("upadte users set Id_Room = '$_POST[id]' where Id_User = '$_SESSION[id]'");
Typos - 'upadte' , inline substition - Id_Room = '{$_POST['id']}'.
Always walk through thorough debugging steps before posting large amounts of code and asking for help.