almightyegg
Members-
Posts
791 -
Joined
-
Last visited
Everything posted by almightyegg
-
I swear I never use that syntax. Oops. Cheers, works a treat
-
it's an update
-
I have this code that just won't insert the right values, yet there is no error message.... if($defender[id] != $mem[last1] && $defender[id] != $mem[last2] && $defender[id] != $mem[last3] && $defender[id] != $mem[last4] && $defender[id] != $mem[last5]){ $new1 = $defender[id]; $new2 = $mem[last1]; $new3 = $mem[last2]; $new4 = $mem[last3]; $new5 = $mem[last4]; $up = mysql_query("UPDATE users SET last1 = '$new1' and last2 = '$new2' and last3 = '$new3' and last4 = '$new4' and last5 = '$new5' WHERE id = '{$mem['id']}'") or die(mysql_error()); if(!$up){ echo "ERRORZ"; } } The first time I run this code it updates with $mem[id] instead of $defender[id] into $new1 so values are thus: $new1 = 1; $new2 = 0; $new3 = 0; $new4 = 0; $new5 = 0; But just before the SQL I echo them out they are correct ($new1 = 2;) What's more if I run it again, all the values become 0 in the SQL when they should still be $new1 = 2; $new2 = 0; $new3 = 0; $new4 = 0; $new5 = 0; or if I changed the $defender[id] it should be $new1 = newid; $new2 = 2; $new3 = 0; $new4 = 0; $new5 = 0; but it still inserts as 0 for all 5 values! I'm so so confused.....
-
That was an epic fail by me :S cheers
-
timestamp
-
I have this code if($gauge == TRUE){ $timestamp = date("Y-m-d H:i:s"); $d2 = strtotime($timestamp); $info .= " and strtotime(`gauge`) > '$d2'"; } $info becomes this big long string and is like this: $info = "SELECT * FROM users WHERE$info"; $sel = mysql_query("$info") or die(mysql_error()); Problem is, I'm not sure how to do the strtotime() to the table variable. it's reading it a a column heading: FUNCTION lordofth_game.strtotime does not exist Any help on how to get it to work would be greatly received
-
Oh my.... we both missed it :') $info .= " SORT BY $sort $order"; should have been $info .= " ORDER BY $sort $order"; Thanks for the help
-
Most of the numbers are generated by $variables, would they require '? What do you mean run it in my GUI?
-
I had got an error with that, a really stupid one too. Thanks for noticing that but I have another one I echoed it out: SELECT * FROM users WHERE level >= '1' and level <= '20' and psyche >= '-5000' and psyche <= '-2000' and lifeforce > '-1' and clutch = '0' SORT BY level ASC I can't see problems with it? I editted the code to fix some errors if($level == TRUE && is_numeric($lvlmin) == TRUE && is_numeric($lvlmax) == TRUE){ $info .= " level >= '$lvlmin' and level <= '$lvlmax'"; }else{ $info .= " level != '0'"; } if($psyche == TRUE && is_numeric($psymin) == TRUE && is_numeric($psymax) == TRUE){ $info .= " and psyche >= '$psymin' and psyche <= '$psymax'"; }else{ $info .= " and psyche != '0'"; } if($lf == TRUE && is_numeric($lfmin) == TRUE && is_numeric($lfmax) == TRUE){ $info .= " and lifeforce >= '$lfmin' and lifeforce <= '$lfmax'"; }else{ $info .= " and lifeforce > '-1'"; } if($soc == all){ $info .= " and clutch >= '0'"; }elseif($soc == notmine){ $info .= " and clutch != '{$mem['clutch']}' and clutch > '0'"; }elseif($soc == mine){ $info .= " and clutch = '{$mem['clutch']}'"; }elseif($soc == none){ $info .= " and clutch = '0'"; } $info .= " SORT BY $sort $order"; $sel = mysql_query("SELECT * FROM users WHERE$info");
-
eh? why?? And ,clutch = '0' or clutch ,= '0' or clutch = ,'0' or what?? $info is the db details put into a string
-
I am customising a mysql_query depending on what a user has inserted on the form on the page before but I have an error in my syntax $psyche = $_POST['psyche']; $psymin = $_POST['psymin']; $psymax = $_POST['psymax']; $level = $_POST['level']; $lvlmin = $_POST['lvlmin']; $lvlmax = $_POST['lvlmax']; $lf = $_POST['lf']; $lfmin = $_POST['lfmin']; $lfmax = $_POST['lfmax']; $soc = $_POST['soc']; $sort = $_POST['sort']; $order = $_POST['order']; if($level == TRUE && is_numeric($lvlmin) == TRUE && is_numeric($lvlmax) == TRUE){ $info .= " level >= '$lvlmin' and level <= '$lvlmax'"; } if($psyche == TRUE && is_numeric($psymin) == TRUE && is_numeric($psymax) == TRUE){ $info .= " psyche >= '$psymin' and psyche <= '$psymax'"; } if($lf == TRUE && is_numeric($lfmin) == TRUE && is_numeric($lfmax) == TRUE){ $info .= " lifeforce >= '$lfmin' and lifeforce <= '$lfmax'"; } if($soc == all){ $info .= " clutch >= '0'"; }elseif($soc == notmine){ $info .= " clutch != '{$mem['clutch']}' and clutch > '0'"; }elseif($soc == mine){ $info .= " clutch = '{$mem['clutch']}'"; }elseif($soc == none){ $info .= " clutch = '0'"; } $info .= " SORT BY $sort $order"; $sel = mysql_query("SELECT * FROM users WHERE$info") or die(mysql_error()); This is the code the creates the mysql_query ($sel) but it shows: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'psyche >= '-5000' and psyche <= '-2000' clutch = '0' SORT BY level ASC' at line 1 Can anybody help me with this??
-
The <!-- is being used as something else, don't ask me what, it was a premade script... By that link you sent, this should work: <!-- [if IE]> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <![endif]--> <!-- [if !IE]> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <![endif]--> Yet IE doesn't work now, FF does
-
// above here is just general tags not to do with this (and the doctype etc..) <div id="content"> <p id="chatwindow"> </p> <!-- <textarea id="chatwindow" rows="19" cols="95" readonly></textarea><br> <input id="chatnick" type="hidden" value="<a href='/player/view.php?id=<? echo "$mem[id]'>$mem[username]</a>"; ?>"> <input id="chatmsg" type="text" size="60" maxlength="80" onkeyup="keyup(event.keyCode);"> <input type="button" value="Post" onclick="submit_msg();"></div> <br><br><br><br><br> </div> <? include 'stats.php'; ?> </body></html> <script type="text/javascript"> /* Settings you might want to define */ var waittime=0; /* Internal Variables & Stuff */ chatmsg.focus() document.getElementById("chatwindow").innerHTML = "loading..."; var xmlhttp = false; var xmlhttp2 = false; /* Request for Reading the Chat Content */ function ajax_read(url) { if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType){ xmlhttp.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp) { alert('Giving up Cannot create an XMLHTTP instance'); return false; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) { document.getElementById("chatwindow").innerHTML = xmlhttp.responseText; zeit = new Date(); ms = (zeit.getHours() * 24 * 60 * 1000) + (zeit.getMinutes() * 60 * 1000) + (zeit.getSeconds() * 1000) + zeit.getMilliseconds(); intUpdate = setTimeout("ajax_read('chat.txt?x=" + ms + "')", waittime) } } xmlhttp.open('GET',url,true); xmlhttp.send(null); } /* Request for Writing the Message */ function ajax_write(url){ if(window.XMLHttpRequest){ xmlhttp2=new XMLHttpRequest(); if(xmlhttp2.overrideMimeType){ xmlhttp2.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp2) { alert('Giving up Cannot create an XMLHTTP instance'); return false; } xmlhttp2.open('GET',url,true); xmlhttp2.send(null); } /* Submit the Message */ function submit_msg(){ nick = document.getElementById("chatnick").value; msg = document.getElementById("chatmsg").value; if (nick == "") { check = prompt("please enter username:"); if (check === null) return 0; if (check == "") check = "anonymous"; document.getElementById("chatnick").value = check; nick = check; } document.getElementById("chatmsg").value = ""; ajax_write("w.php?m=" + msg + "&n=" + nick); } /* Check if Enter is pressed */ function keyup(arg1) { if (arg1 == 13) submit_msg(); } /* Start the Requests! */ var intUpdate = setTimeout("ajax_read('chat.txt')", waittime); </script> Also, I forgot to mention, they work fine when there's no doctype but my DIVs don't work at all then :S
-
It's actually Firefox that's the problem... I have a chatroom script and it uses this code to show the latest posts: <!-- <textarea id="chatwindow" rows="19" cols="95" readonly></textarea><br> IE reads it fine in the DOCTYPE that I'v used for the rest of my side. In FF it displays: <!-- and then a big white square... Where it's meant to be black and have text in it :S
-
[SOLVED] Can I use an array to shorted this script
almightyegg replied to almightyegg's topic in PHP Coding Help
Sweet, works great - thanks loads -
I have a file that when executed it re-writes a group of files to a list of directorys like so: <? $openfile = fopen("/home/lordofth/public_html/areas/panel.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/panel.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/areas/links.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/links.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/areas/links2.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/links2.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/areas/icons.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/icons.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/areas/default.css", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/default.css")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/areas/default2.css", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/default2.css")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/areas/copyright.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/copyright.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/areas/bbcodes.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/bbcodes.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/account/panel.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/panel.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/account/links.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/links.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/account/links2.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/links2.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/account/icons.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/icons.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/account/default.css", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/default.css")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/account/default2.css", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/default2.css")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/account/copyright.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/copyright.php")); fclose($openfile); $openfile = fopen("/home/lordofth/public_html/account/bbcodes.php", "w"); fwrite($openfile, file_get_contents("/home/lordofth/public_html/layout/bbcodes.php")); fclose($openfile); Problem is, there's about 20 or so directories to fwrite() 8 files into, which from the above code, makes a large and long winded file. So I was wondering, for ease of use, if it's possible to put the directories into an array of something and then it would fwrite() to all directories in there?? If it is possible, it'd be great if you could point me in the right direction, thanks
-
I have a section of my page brought in by an AJAX function that reads a .txt file and it keeps showing this for a brief section and then reverts to the actual data I believe that it is caching old data and then realising it's not there, how do I stop this with AJAX? If you need to see my code I can but I'm hoping it's going to be a simple function or attribute
-
Thanks for you reply - only problem is in my new.php is a mysql_query("INSERT INTO blah blah blah The way I have it set up is that there is an IFRAME with mysql data in it and it reloads every 5 seconds. When posting something with my form, that new information doeasn't display until I refresh the page... So A) How do I make it insert correctly B) is there anyway of doing the mysql thing without it being reloaded and making a horrible clicking sound and also clogging up my browse history thanks in advance
-
Hi, I posted this on javascript board first but got told ajax would be better for my problem...right, I have a form with a simple text input and a submit button... I want that button, when pressed, to access a file (new.php) and take that message data with it BUT without the page reloading at all and the message input emptyig after the file is accessed... I'd be really greatful if somebody could point me in the right direction... here's my form currently: <form method="POST"> <input type="text" name="message"> <input value="Post!" type="submit"> </form>
-
Hi, right, I have a form with a simple text input and a submit button... I want that button, when pressed, to access a file (new.php) and take that message data with it BUT without the page reloading at all and the message input emptyig after the file is accessed... I'd be really greatful if somebody could point me in the right direction... here's my form currently: <form method="POST"> <input type="text" name="message"> <input value="Post!" type="submit"> </form>
-
I was originally going to use AJAX but I had no idea where to start :S tbh, I have no idea what I'm doing with this at all
-
Awesome! Thanks, that worked Erm, I have a quick question, how would I go about making it not reload if the user is currently typing in a text box?? Or is that a bit more complicated??