
blue-genie
Members-
Posts
69 -
Joined
-
Last visited
Everything posted by blue-genie
-
i have tried googling but i cant' find how to change my table type. can you advise?
-
Hi no. My type is MyISAM. if i check storage engine, have the following options available memory, blackhole, archive, federated, mrg_myisam. I always leave these as default values.
-
Hi all. I'm using xammpp version 1.6.3 with mysql 5.0.45 and php 5.2.3 i've followed this tutorial to try and set up relations etc. http://www.learnphp.org/tutorials/Setting-Up-Foreign-Keys-Using-PhpMyAdmin-63466.html although I've followed this step by step, I can't get that relation view to show up. can anyone provide some pointers. thanks. blu.
-
I have a simple login script <?php session_start(); include 'config.php'; include 'opendb.php'; //This function will find and checks if your data is correct function login(){ //Collect your info from login form $admin = $_REQUEST['username']; $password = $_REQUEST['password']; $result = mysql_query("SELECT * FROM adminusers WHERE username ='$admin'"); $row = mysql_fetch_array($result); // mysql_fetch_array return false if no record but not null if (!$row) { echo '<?xml version="1.0"?>'; echo '<dataxml>'; echo '<row type="error">'; echo "<errorMsg>Can't find user on system.</errorMsg>"; echo "</row>"; echo '</dataxml>'; die(); } else { // check password now if record found if($row['password'] == $password){ $username = $row['username']; $id = $row['adminID']; echo '<?xml version="1.0"?>'; echo '<dataxml>'; echo '<row type="success">'; echo "<firstname>".$row['username']."</firstname>"; echo "<userID>".$row['adminID']."</userID>"; echo "</row>"; echo '</dataxml>'; if(isset($_SESSION['admin'])) $_SESSION['admin'] = $id; else $_SESSION['admin'] = $id; } else { // show error if user found but password incorrect echo '<?xml version="1.0"?>'; echo '<dataxml>'; echo '<row type="error">'; echo "<errorMsg>Incorrect Password.</errorMsg>"; echo "</row>"; echo '</dataxml>'; die(); } } } login(); ?> on my local xampp folder http://127 etc works fine when i load everything up on a remote server I get the warning Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/biddcdbz/public_html/games/sun_soccer/admin/adminLogin.php on line 19 Can't find user on system. line #19 is this $row = mysql_fetch_array($result)
-
Need help to format xml from complex result returned.
blue-genie replied to blue-genie's topic in PHP Coding Help
i'm manged to get this to a semblance of what i need. i was using a for loop out of place. thanks all. -
Need help to format xml from complex result returned.
blue-genie replied to blue-genie's topic in PHP Coding Help
i all, i'm getting the data from mysql db - just pasted the details into excel so you guys can see what's happening. I'm trying to format the resultset from php in a nice and tidy xml format for the flash to handle. if i can't get the php to do it i'll need flash to loop through the result and clean it up there but that's a 2 step phase. -
Please have a look at the attached image. those are the results i'm returning with my query. $result = mysql_query("SELECT gameName, startDate, endDate, FROM (gamedetails left join gamestats on gamedetails.gameID= gamestats .gameID) left join playerdetails on gamestats.playerID = playerdetails.playerID left join gameprizes on gameprizes.gamePrizeID = gamedetails.gameID WHERE gamedetails.gameID = '".$gameID."' AND statsID is not NULL order by score desc"); basically what i'm trying to achieve is a leaderboard. so i send through a game id i need to get a) the player at position 1 b) his score c) the prize for rank 1 (if there is one) i was hoping i could get the xml into some format like this <data> <name>Game name</name> <position> <player>uni</player> <score>523></score> <prize>banana game prize 1></prize> <position> <player>test</player> <score>58></score> <prize>banana game prize 2></prize> etc ... if there is no prize for say position 3 and assuming there was a 3rd person - empty prize node etc. Can someone help me please blu. [attachment deleted by admin]
-
are there different syntaxes for PHP for different versions of PHP or MySQL - or are there just many ways to achieve one thing? reason I ask, many people come up with different code snippets with different syntax and also I get some errors stating I have an error in my sql statement for my version.
-
i got assistance from another forum. thanks.
-
i was hoping there was a way to do it within the select statement. $row['rank#'] doesn't work either, but thanks anyway.
-
hey. no that didn't work. never echos those even if field is not null.
-
have a look at what i'm trying to do. in my database, i have fields 1 - 11 for each game however not all those field will have data. Is there a way I can get my xml to only go up to where it's not null? i.e say this query returns 2 items. the first item only has 1 prize, the second one has 3. can i get the xml to look like this: <dataxml> <row gameID="65"> <gameName>banana</gameName> <prize id="1">another prize 1</prize> </row> <row gameID="666"> <gameName>carrot</gameName> <prize id="1">another prize 1</prize> <prize id="2">another prize 2</prize> </row> </dataxml> $result = mysql_query("SELECT * FROM gamedetails LEFT JOIN gamePrizes ON gameID = gamePrizeID where prizeID is NOT NULL"); echo '<?xml version="1.0"?>'; echo '<dataxml>'; if (mysql_num_rows($result)){ while ($row = mysql_fetch_array($result)) { echo '<row gameID="'.$row['gameID'].'">'; echo "<gameName>".$row['gameName']."</gameName>"; echo "<prize id='1'>".$row['rank1']."</prize>"; echo "<prize id='2'>".$row['rank2']."</prize>"; echo "<prize id='3'>".$row['rank3']."</prize>"; echo "<prize id='4'>".$row['rank4']."</prize>"; echo "<prize id='5'>".$row['rank5']."</prize>"; echo "<prize id='6'>".$row['rank6']."</prize>"; echo "<prize id='7'>".$row['rank7']."</prize>"; echo "<prize id='8'>".$row['rank8']."</prize>"; echo "<prize id='9'>".$row['rank9']."</prize>"; echo "<prize id='10'>".$row['rank10']."</prize>"; echo "<prize id='11'>".$row['rank11']."</prize>"; echo "</row>"; } } else { echo '<error>no results</error>'; } echo '</dataxml>'; mysql_free_result($result); much thanks.
-
@JustLikeIcarus thanks I did that (see my second post) and it does seem to work, but I just wanted to confirm if there was a tidier way of doing it. thanks. blu
-
i know the ID of the item i'm editing so i tried this $result = mysql_query("select count(*) as count FROM gameDetails WHERE gameID <> $editGameID AND startDate<=Date('".$newStartDate."') AND endDate>=DATE(' ".$newStartDate." ') OR startDate<=DATE(' ".$newEndDate." ') AND endDate>=DATE(' ".$newEndDate." ') " ); is this the best practice way of going about this?
-
I have the following situation. I have a bunch of instances of a game in the database. The games can not overlap date wise. with the insert I've managed to check if the date range is clear do the insert, however I now need to introduce an edit function, and I'm hitting a bit of a hurdle. assume i have an entry call var1 whose startDate is 2010-07-01 and endDate is 2010-07-30 i have another entry var2 whose startDate is 2010-06-10 and endDate is 2010-06-15 i now get the var2 back to edit it and I want to change the endDate to 2010-06-30 which in theory is fine because no other entry is within that time range, however my current query $result = mysql_query("select count(*) as count FROM gameDetails WHERE startDate<=Date('".$newStartDate."') AND endDate>=DATE(' ".$newStartDate." ') OR startDate<=DATE(' ".$newEndDate." ') AND endDate>=DATE(' ".$newEndDate." ') " ); will return 1 because it counts itself right (var2) so my question is this - I do a quick hack and check that if($row[count]>1) or is there a better way to write this script? blu
-
I'm busy researching options. Currently we have a bunch of flash (swf) files that connect directly to SOAP webservices. Now I was looking through some AMFPHP tutorials where a service was created an flash could access the function in php directly - and I thought wouldn't it be cool if I could use php to access the webservices instead of flash (just an extra level of security) - so I set about trying to incorporate something - but no luck. I'm seeing that i create a new SoapClient instance and pass the url to my websrevices. then what? does anyone have some pointers for me, links anything .... thanks bg.
-
this code works sporadically so i'm guessing its not right
blue-genie replied to blue-genie's topic in PHP Coding Help
i'm using a linux server in my final thing. testing on xampp on XP in localhost. maybe that's the problem will test it this evening and let you know. -
don't laugh but i figured i want to get the autoincrement value of what i just inserted and repeat it in another field. so i do the insert , then mysql_insert_id(); then another update. can someone clean this up for me so it works all the time (currently i get a null sometimes though the insert does happen) <?php session_start(); include 'config.php'; include 'opendb.php'; $gameID= $_REQUEST['gameID']; $gameRNG= $_REQUEST['gameRNG']; $insert = mysql_query("INSERT INTO gameinstance (gameID, gameRNGResult, gameDateTime) VALUES ('$gameID', '$gameRNG', now())"); if(!$insert){ echo '<?xml version="1.0"?>'; echo '<dataxml>'; die("There's little problem: ".mysql_error()); $MyError = "An error occured while saving data. Please try again later." + mysql_error(); echo "<sqlError>".$MyError."</sqlError>"; echo '</dataxml>'; } else { $gameInstanceNo = mysql_insert_id(); mysql_query("UPDATE gameInstance SET gameInstance_No='$gameInstanceNo' WHERE USN_Gameinstance='$gameInstanceNo'"); echo '<?xml version="1.0"?>'; echo '<dataxml>'; $success = mysql_insert_id(); echo "<success>".$success."</success>"; echo '</dataxml>'; } ?>
-
ok i've changed it to this <?php session_start(); include 'config.php'; include 'opendb.php'; $gameID=$_GET['gameID']; function getGameConfig($arg) { $sql = "SELECT * FROM gameinstance a inner join games b on a.gameID = b.'".$gameID."' order by gameDateTime LIMIT 0, 1"; $result = mysql_query($sql); echo '<?xml version="1.0"?>'; echo '<dataxml>'; if ($result){ echo "<gameID>".$result['gameID']."</gameID>"; echo "<instanceID>".$result['gameInstance_No']."</instanceID>"; echo "<gameRNG>".$result['gameRNGResult']."</gameRNG>"; echo "<numTries>".$result['numTries']."</numTries>"; echo "<gameOdds>".$result['gameOdds']."</gameOdds>"; echo "<canSMS>".$result['canSMS']."</canSMS>"; echo "<winType>".$result['winType']."</winType>"; }else{ echo '<error>no results</error>'; } echo '</dataxml>'; } getGameConfig($gameID); ?> but it's not returning any results, and there definately is something so i'm guessing it's the b. part before the variable? please advise if you can.
-
[SOLVED] random number - using variable as max value
blue-genie replied to blue-genie's topic in PHP Coding Help
ah ok i think she's got it. thanks :-) -
[SOLVED] random number - using variable as max value
blue-genie replied to blue-genie's topic in PHP Coding Help
ok wait I'm confused, you said i musn't use super globals in my function so i take $maxVal=$_GET['maxValue']; out of the function - doesn't work if i put it in the function it works. so what's the work around? -
[SOLVED] random number - using variable as max value
blue-genie replied to blue-genie's topic in PHP Coding Help
ok so in theory if I do this <?php session_start(); $maxVal= $_GET['maxValue']; function getRandom() { $random_number = rand(0, $maxVal); echo "$random_number"; } getRandom(); ?> i should then be able to test it in the brower like this http://host/testRandom.php?maxValue=200 right? I still get 0 -
[SOLVED] random number - using variable as max value
blue-genie replied to blue-genie's topic in PHP Coding Help
thanks for the response zanus. don't know if this is pertinent but I'm parsing the value through to PHP from flash, hence the _REQUEST but to test my php i use the query ?maxVal in the browser to check that my PHP works first. and in this case it's not working.