Jump to content

Problem With Change


ChidoriSoul
 Share

Recommended Posts

I am having a problem with my Promo page, where I want it to show if the user has already received the promo, and do not run the script, and if they have not, run the script. The page is located here. My code is this:

 <?phpsession_start();?><html><!--[if IE]>  <link rel="stylesheet" type="text/css" href="allie.css" /><![endif]--><center><head><?php include('head.php'); ?></head><body><?phprequire_once('db.php');$promosession = $_SESSION["user_id"];$querypromo = mysql_query("SELECT * FROM `users` WHERE `id` = '".$promosession."'");$promo = mysql_fetch_array($querypromo);$query = mysql_query("SELECT `got_promo` FROM `users` WHERE `id` = '".$promosession."'");if($query == 0) {$name = Darkrai;$owner = $_SESSION['user_name'];$position = 1;$query =  mysql_query("INSERT INTO pokemon (pokemon_id, name, owner, picture, icon, position) VALUES ('', '$name','$owner','<img src=\'images/sprites/darkrai.png\' alt=\'darkrai\' />','<img src=\'http://www.pokemonelite2000.com/sprites/dpiconani/dpiconani491.gif\' alt=\'darkraicon\' />','$position')");echo "<div id='container'>	<div id='banner'></div>	<div id='frame'>		<div id='leftmenu'><div style='padding: 3px;'>			<?php include('menuin.php'); ?>		</div></div>		<div id='content'><div style='padding: 3px;'>			<center><u>Promo!</u><br/><table border='1' width='100%'><tr><th>Current Promo</th></tr><tr><td width='100%' style='text-align: center'>The current Promotional Pokemon is <b>Darkrai</b>!</td></tr><tr><td width='100%' style='text-align: center'><img src='images/sprites/darkrai.png' alt='darkrai' /></td></tr><tr><td width='100%' style='text-align: center'><font color='red'>You have just obtained the Current Promotional Pokemon: <b>Darkrai</b>!</td></tr></table>		<br/><br/><script type='text/javascript'><!--google_ad_client = 'pub-4468899317544238';/* Pokemon Planet Ads */google_ad_slot = '7415068260';google_ad_width = 468;google_ad_height = 60;//--></script><script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script></div></div>			<?php include('rightmenuin.php'); ?>		</div></div></div>	<div id='footer'><center><font color='#000000'>Pokemon Planet is © 2009 by Shadow. This site is created and coded by Shadow. Pokemon Planet is in no way affiliated with Nintendo, Pokémon Company, Game Freak, Creatures, or any related organizations. Most Pokémon images (sprites, icons, map tiles, etc.) are © Nintendo and their publishers. Images are slightly modified in order to meet certain needs upon this website.</font></center></div></div>";}else {echo "<div id='container'>	<div id='banner'></div>	<div id='frame'>		<div id='leftmenu'><div style='padding: 3px;'>			<?php include('menuin.php'); ?>		</div></div>		<div id='content'><div style='padding: 3px;'>			<center><u>Promo!</u><br/><table border='1' width='100%'><tr><th>Current Promo</th></tr><tr><td width='100%' style='text-align: center'>The current Promotional Pokemon is <b>Darkrai</b>!</td></tr><tr><td width='100%' style='text-align: center'><img src='images/sprites/darkrai.png' alt='darkrai' /></td></tr><tr><td width='100%' style='text-align: center'><font color='red'>You have already obtained a <b>Darkrai!</b></td></tr></table>		<br/><br/><script type='text/javascript'><!--google_ad_client = 'pub-4468899317544238';/* Pokemon Planet Ads */google_ad_slot = '7415068260';google_ad_width = 468;google_ad_height = 60;//--></script><script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script></div></div>		<div id='rightmenu'><div style='padding: 3px;'>			<?php include('rightmenuin.php'); ?>		</div></div></div>	<div id='footer'><center><font color='#000000'>Pokemon Planet is © 2009 by Shadow. This site is created and coded by Shadow. Pokemon Planet is in no way affiliated with Nintendo, Pokémon Company, Game Freak, Creatures, or any related organizations. Most Pokémon images (sprites, icons, map tiles, etc.) are © Nintendo and their publishers. Images are slightly modified in order to meet certain needs upon this website.</font></center></div></div>";$query =  mysql_query("UPDATE `users` SET got_promo='1' WHERE `id` = '".$_SESSION['user_id']."'");}?></body></html>

Link to comment
Share on other sites

$query = mysql_query("SELECT `got_promo` FROM `users` WHERE `id` = '".$promosession."'");if($query == 0) {

It isn't cut and paste code. You will need to adjust it to suit your application. Notice the last line of my code is checking to see how many rows is being returned?

Link to comment
Share on other sites

Ok, I removed my code, edited your in to match mine, but it still Updates my profile but does not give me a Darkrai, whats up?My Code:

<?phpsession_start();?><html><!--[if IE]>  <link rel="stylesheet" type="text/css" href="allie.css" /><![endif]--><center><head><?php include('head.php'); ?></head><body><?phprequire_once('db.php');$promosession = $_SESSION["user_id"];$querypromo = mysql_query("SELECT * FROM `users` WHERE `id` = '".$promosession."'");$promo = mysql_fetch_array($querypromo);$query = "SELECT `id` FROM `users` WHERE `id`='".$promosession."'";$result = mysql_query($query);if (mysql_num_rows($result) == 0) {$name = Darkrai;$owner = $_SESSION['user_name'];$position = 1;$query =  mysql_query("INSERT INTO pokemon (pokemon_id, name, owner, picture, icon, position) VALUES ('', '$name','$owner','<img src=\'images/sprites/darkrai.png\' alt=\'darkrai\' />','<img src=\'http://www.pokemonelite2000.com/sprites/dpiconani/dpiconani491.gif\' alt=\'darkraicon\' />','$position')");echo "<div id='container'>	<div id='banner'></div>	<div id='frame'>		<div id='leftmenu'><div style='padding: 3px;'>			<?php include('menuin.php'); ?>		</div></div>		<div id='content'><div style='padding: 3px;'>			<center><u>Promo!</u><br/><table border='1' width='100%'><tr><th>Current Promo</th></tr><tr><td width='100%' style='text-align: center'>The current Promotional Pokemon is <b>Darkrai</b>!</td></tr><tr><td width='100%' style='text-align: center'><img src='images/sprites/darkrai.png' alt='darkrai' /></td></tr><tr><td width='100%' style='text-align: center'><font color='red'>You have just obtained the Current Promotional Pokemon: <b>Darkrai</b>!</td></tr></table>		<br/><br/><script type='text/javascript'><!--google_ad_client = 'pub-4468899317544238';/* Pokemon Planet Ads */google_ad_slot = '7415068260';google_ad_width = 468;google_ad_height = 60;//--></script><script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script></div></div>			<?php include('rightmenuin.php'); ?>		</div></div></div>	<div id='footer'><center><font color='#000000'>Pokemon Planet is © 2009 by Shadow. This site is created and coded by Shadow. Pokemon Planet is in no way affiliated with Nintendo, Pokémon Company, Game Freak, Creatures, or any related organizations. Most Pokémon images (sprites, icons, map tiles, etc.) are © Nintendo and their publishers. Images are slightly modified in order to meet certain needs upon this website.</font></center></div></div>";}else {echo "<div id='container'>	<div id='banner'></div>	<div id='frame'>		<div id='leftmenu'><div style='padding: 3px;'>			<?php include('menuin.php'); ?>		</div></div>		<div id='content'><div style='padding: 3px;'>			<center><u>Promo!</u><br/><table border='1' width='100%'><tr><th>Current Promo</th></tr><tr><td width='100%' style='text-align: center'>The current Promotional Pokemon is <b>Darkrai</b>!</td></tr><tr><td width='100%' style='text-align: center'><img src='images/sprites/darkrai.png' alt='darkrai' /></td></tr><tr><td width='100%' style='text-align: center'><font color='red'>You have already obtained a <b>Darkrai!</b></td></tr></table>		<br/><br/><script type='text/javascript'><!--google_ad_client = 'pub-4468899317544238';/* Pokemon Planet Ads */google_ad_slot = '7415068260';google_ad_width = 468;google_ad_height = 60;//--></script><script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script></div></div>		<div id='rightmenu'><div style='padding: 3px;'>			<?php include('rightmenuin.php'); ?>		</div></div></div>	<div id='footer'><center><font color='#000000'>Pokemon Planet is © 2009 by Shadow. This site is created and coded by Shadow. Pokemon Planet is in no way affiliated with Nintendo, Pokémon Company, Game Freak, Creatures, or any related organizations. Most Pokémon images (sprites, icons, map tiles, etc.) are © Nintendo and their publishers. Images are slightly modified in order to meet certain needs upon this website.</font></center></div></div>";$query =  mysql_query("UPDATE `users` SET got_promo='1' WHERE `id` = '".$_SESSION['user_id']."'");}?></body></html>

Link to comment
Share on other sites

Thank you very much JSG. Now, even though my row shows that it is at 2 in the field (2 = get, else = not), it still takes me to the I already have it page.

<?phpsession_start();?><html><!--[if IE]>  <link rel="stylesheet" type="text/css" href="allie.css" /><![endif]--><center><head><?php include('head.php'); ?></head><body><?phprequire_once('db.php');$promosession = $_SESSION["user_id"];$querypromo = mysql_query("SELECT * FROM `users` WHERE `id` = '".$promosession."'");$promo = mysql_fetch_array($querypromo);$query = mysql_query("SELECT `got_promo` FROM `users` WHERE `id`='".$promosession."'");if (mysql_num_rows($query) == 2) {$name = Darkrai;$owner = $_SESSION['user_name'];$position = 1;$query =  mysql_query("INSERT INTO pokemon (pokemon_id, name, owner, picture, icon, position) VALUES ('', '$name','$owner','<img src=\'images/sprites/darkrai.png\' alt=\'darkrai\' />','<img src=\'http://www.pokemonelite2000.com/sprites/dpiconani/dpiconani491.gif\' alt=\'darkraicon\' />','$position')");echo "<div id='container'>	<div id='banner'></div>	<div id='frame'>		<div id='leftmenu'><div style='padding: 3px;'>			<?php include('menuin.php'); ?>		</div></div>		<div id='content'><div style='padding: 3px;'>			<center><u>Promo!</u><br/><table border='1' width='100%'><tr><th>Current Promo</th></tr><tr><td width='100%' style='text-align: center'>The current Promotional Pokemon is <b>Darkrai</b>!</td></tr><tr><td width='100%' style='text-align: center'><img src='images/sprites/darkrai.png' alt='darkrai' /></td></tr><tr><td width='100%' style='text-align: center'><font color='red'>You have just obtained the Current Promotional Pokemon: <b>Darkrai</b>!</td></tr></table>		<br/><br/><script type='text/javascript'><!--google_ad_client = 'pub-4468899317544238';/* Pokemon Planet Ads */google_ad_slot = '7415068260';google_ad_width = 468;google_ad_height = 60;//--></script><script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script></div></div>			<?php include('rightmenuin.php'); ?>		</div></div></div>	<div id='footer'><font color='#000000'>Pokemon Planet is © 2009 by Shadow. This site is created and coded by Shadow. Pokemon Planet is in no way affiliated with Nintendo, Pokémon Company, Game Freak, Creatures, or any related organizations. Most Pokémon images (sprites, icons, map tiles, etc.) are © Nintendo and their publishers. Images are slightly modified in order to meet certain needs upon this website.</font></div></div>";$query =  mysql_query("UPDATE `users` SET got_promo='2' WHERE `id` = '".$_SESSION['user_id']."'");}else {echo "<div id='container'>	<div id='banner'></div>	<div id='frame'>		<div id='leftmenu'><div style='padding: 3px;'>			<?php include('menuin.php'); ?>		</div></div>		<div id='content'><div style='padding: 3px;'>			<center><u>Promo!</u><br/><table border='1' width='100%'><tr><th>Current Promo</th></tr><tr><td width='100%' style='text-align: center'>The current Promotional Pokemon is <b>Darkrai</b>!</td></tr><tr><td width='100%' style='text-align: center'><img src='images/sprites/darkrai.png' alt='darkrai' /></td></tr><tr><td width='100%' style='text-align: center'><font color='red'>You have already obtained a <b>Darkrai!</b></td></tr></table>		<br/><br/><script type='text/javascript'><!--google_ad_client = 'pub-4468899317544238';/* Pokemon Planet Ads */google_ad_slot = '7415068260';google_ad_width = 468;google_ad_height = 60;//--></script><script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script></div></div>		<div id='rightmenu'><div style='padding: 3px;'>			<?php include('rightmenuin.php'); ?>		</div></div></div>	<div id='footer'><center><font color='#000000'>Pokemon Planet is © 2009 by Shadow. This site is created and coded by Shadow. Pokemon Planet is in no way affiliated with Nintendo, Pokémon Company, Game Freak, Creatures, or any related organizations. Most Pokémon images (sprites, icons, map tiles, etc.) are © Nintendo and their publishers. Images are slightly modified in order to meet certain needs upon this website.</font></center></div></div>";$query =  mysql_query("UPDATE `users` SET got_promo='2' WHERE `id` = '".$_SESSION['user_id']."'");}?></body></html>

Link to comment
Share on other sites

This code:

$query = mysql_query("SELECT `got_promo` FROM `users` WHERE `id`='".$promosession."'");if (mysql_num_rows($query) == 2) {

Checks how many rows were returned. mysql_num_rows will return 2 if that query matched 2 users in the database. If you want to check the value of a specific field, use mysql_fetch_assoc to get the row that it returned, and then check the field in the row.http://www.php.net/manual/en/function.mysql-fetch-assoc.php

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...