Vel
Members-
Posts
130 -
Joined
-
Last visited
Everything posted by Vel
-
The most obvious answer to me is to send them as get variables. <!-- elFinder initialization (REQUIRED) --> <script type="text/javascript" charset="utf-8"> $().ready(function() { var elf = $('#elfinder').elfinder({ lang: 'ru', // language (OPTIONAL) url : 'php/connector.php?id=<?php echo $user_id; ?>', // connector URL (REQUIRED) directory : 'files' }).elfinder('instance'); }); </script> Then in connector.php just use $_get['id'].
-
user login validation from two databse in my website
Vel replied to san_v's topic in PHP Coding Help
I thought you could search for cookies if you knew the specific domain and name? -
I was just asking to see if there was another answer other than the overhead. For most scripts I get the point, for a small script like this I find it's just easier to put it in the loop, especially for new programmers as I think my example is a lot easier to understand what is going on that yours, no offence.
-
Why shouldn't you run a query in a loop? Sure it's more overhead than running the one query but with a simple script like this does it really matter?
-
user login validation from two databse in my website
Vel replied to san_v's topic in PHP Coding Help
The only possible thing you could do is to include a cookie that is created on login on either site that is recognised by both sites. You would have to check to see if a cookie created by that site or created by the other site exists. -
Yes, because you have multiple inputs with the same name they form and array inside the $_POST array.
-
No problems . Always happy to help people learn PHP. To skip over blank cells change the code here: $player = mysql_real_escape_string($play); $query = "INSERT INTO `members` (`player`) VALUES ('$player')"; to: if(!$play) { continue; } $player = mysql_real_escape_string($play); $query = "INSERT INTO `members` (`player`) VALUES ('$player')";
-
First off, you are wide open to SQL injection attacks. You need to escape any data that you don't know the contents of, such as name, the IP ($_SERVER can be manipulated through the browser) and password. This is very easy to do, all you do is add $var = mysql_real_escape_string($var); before using it in any mysql statements. Secondly, we need more information on what is actually happening. What do your users see when the first login fails?
-
No, when dealing with multi-layer arrays you always lay it out $_POST['playerName'][$id]
-
The problem is you're not including the insert statement in your foreach loop. Try the following code: <?php foreach($_POST['player'] as $row => $play) { $player = mysql_real_escape_string($play); $query = "INSERT INTO `members` (`player`) VALUES ('$player')"; if(!mysql_query($query)) { die('Error: ' . mysql_error . '<br />Query: ' . $query); //NOTE: Never use a die statement like this outside of a development environment. It gives to much information away to potential hackers. } else { echo "$row record added<br />"; } } mysql_close($con) ?>
-
Object of class player could not be converted to string
Vel replied to Vel's topic in PHP Coding Help
I've set error reporting to E_ALL | E_STRICT in php.ini now. As you can probably guess I'm still new to all this so thank you for the help and advice. Now to recode my variable variables into an array. -
Object of class player could not be converted to string
Vel replied to Vel's topic in PHP Coding Help
Thank you! I have been through that code line by line so many times I don't know how I missed that. I turned errors on on my index page but forgot to turn them on this page. I have turned them on now. I didn't know you could put them in an array. So when creating it, instead of using <?php $var = "var" . $i; $$var = new class; Would I use? <?php $var = array(); $var[$i] = new class; Is that right? -
I'm receiving the error "Object of class player could not be converted to string" yet I cannot find why what I'm inputting is an object and not a string. As far as I can see it is a string and this error shouldn't be happening, yet it is... A form submits to a page which gets the data thus: <?php case "updplayer": if(!isset($_GET['id']) || !isset($_POST['kit']) || !isset($_POST['level']) || !isset($_POST['group']) || !isset($_POST['state'])) { header("location:admin.php?mode=settings&error=info&sid=$user->sid"); exit; } $var = "player" . $_GET['id']; $$var->kit = mysql_real_escape_string($_POST['kit']); $$var->level = mysql_real_escape_string($_POST['level']); $$var->group = mysql_real_escape_string($_POST['group']); $$var->state = mysql_real_escape_string($_POST['state']); $$var->update(); header("location:admin.php?sid=$user->sid"); exit; break; The update function is: <?php function update() { echo "Name: $this->name <br /> Kit: $this->kit <br /> Level: $this->level <br /> Group: $this->group <br /> State: $this->state <br />"; $sql = "UPDATE `players` SET `name` = '" . $this->name . "', `preferredKit` = '" . $this-kit . "', `gamingLevel` = '" . $this->level . "', `group` = '" . $this->group . "', `draftState` = " . $this->state; if(!mysql_query($sql)) { return mysql_error(); } return TRUE; } I added the echo's in for error checking. They output exactly what was expected. What is wrong with this? Error occurs on the "$sql = " line.
-
Can no one help with getting the Ajax working using JQuery? I've never used JQuery before and reading through it I have no idea how to use it to pass the information I need to my ajax.php page, then get the information back from my ajax.php page and update the original page.
-
That didn't work. Function still isn't being called. I tried onclick="alert('TEST');" and that worked. Also adding that before calling the function works. However adding it after the function doesn't work. Seems there is something wrong with the function itself, yet that function works perfectly fine for other sites. OK, let's try JQuery. I've added the JQuery script at the top, what do I need to do to pass $pOrder and down to include/ajax.php and have it update $divId?
-
yea, it adds the # to the end of the url, but nothing else happens.
-
Using JQuery has nothing to do with it (can't call JQuery if I can't use onclick). And PHP should be able to call Javascript (It's Javascript that cant call PHP). This type of format has worked for me in previous sites. This is the source code when viewed from firefox. As you can see it outputs fine. Why doesn't that work? <div class="cms-pages" id="ajax1"> <div class="cms-arrows"> <a href="#" onclick="funcUpdateCms(1, 'down', ajax1);"><img src="img/arrowdown.gif" alt="move up"></a> <img src="img/noarrowup.gif" alt="move up"> </div> <div style="float:left; width:200px"> <a href="page-edit.php?id=Home"><strong>Home</strong></a> </div> <div style="float:right; width:50px"> <a href="page-delete.php?id=Home" onclick="return confirm('Permanently delete page?');">Delete</a> </div> <div style="float:right; width:50px"> <a href="page-edit.php?id=Home">Edit</a> </div> <div style="float:right; width:50px"> <a href="../">View</a> </div> <div style="float:right; width:150px; color:#999;">0 (general)</div><br/></div> As I posted in the admins thread, I like writing my own code rather than using a framework because you learn a hell of a lot more about the code.
-
People always say why reinvent the wheel? The best answer to that, because by reinventing the wheel you understand it better. Rather than just use JQuery to get the job done by writing the whole thing yourself in javascript you're much better off understanding it.
-
I'm banging my head against a brick wall here. I can't see anything wrong with the code yet my ajax query isn't being called. I stuck an alert at the top of the ajax function, and in the onClick event itself, neither are being shown. Why wouldn't onclick be working? PHP: <?php while ($row = mysql_fetch_array($query)) { $pId = $row['pId']; $pContent = $row['pContent']; $pOrder = $row['pOrder']; $pActive = $row['pActive']; $pTemplate = $row['pTemplate']; $pMenu = $row['pMenu']; $divId = "ajax" . $pOrder; echo "<div class=\"cms-pages\" id=\"$divId\"><div class=\"cms-arrows\"> "; if ($pOrder < $num && $theorder != "alpha") { echo "<a href=\"#\" onclick=\"funcUpdateCms($pOrder, 'down', $divId);\"><img src=\"img/arrowdown.gif\" alt=\"move up\"></a> "; } if ($pOrder == $num && $theorder != "alpha") { echo "<img src=\"img/noarrowdown.gif\" alt=\"move up\"> "; } if ($pOrder > 1 && $theorder != "alpha") { echo "<a href=\"#\" onClick=\"funcUpdateCms($pOrder, 'up', $divId); funcUpdateCms($pOrder, 'upRef', $divId);\"><img src=\"img/arrowup.gif\" alt=\"move down\"></a>"; } if ($pOrder == 1 && $theorder != "alpha") { echo "<img src=\"img/noarrowup.gif\" alt=\"move up\"> "; } echo "</div><div style=\"float:left; width:200px\"><a href=\"page-edit.php?id=".$pId."\"><strong>$pId</strong></a>"; if ($pActive == 1) { echo " "; } else { echo " (not on menu) "; } echo "</div>"; echo "<div style=\"float:right; width:50px\"><a href=\"page-delete.php?id=".$pId."\" onclick=\"return confirm('Permanently delete page?');\">Delete</a></div><div style=\"float:right; width:50px\"><a href=\"page-edit.php?id=".$pId."\">Edit</a></div><div style=\"float:right; width:50px\">"; if ($pId == "Home" || $pId == "HOME" || $pId == "home") { echo "<a href=\"../\">"; } else { echo "<a href=\"../general.php?id=".$pId."\">"; } echo "View</a></div><div style=\"float:right; width:150px; color:#999;\">".$pMenu." (".$pTemplate.")</div><br/></div>"; } JS Function: <!-- // JavaScript Document function funcUpdateCms(pOrder, direction, result) { alert("Ajax Called"); if (pOrder == "") { return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { alert("Ajax response: "+xmlhttp.responseText); document.getElementById(result).innerHTML=xmlhttp.responseText; } } alert("Ajax request sent."); xmlhttp.open("GET", "include/ajax.php?pOrder="+pOrder+"&direction="+direction, true); //Call script to update drop down box xmlhttp.send(); } //-->
-
I managed to get it to work by adding a breaker between the two. Code now looks like: HTML: </mainContent> </mainWrapper> <breaker></breaker> <footerWrapper> <footerContent> <p>Copyright ©2011 Mafia Online. All rights reserved.</p> </footerContent> </footerWrapper> CSS: breaker { clear: both; width: 100%; } footerWrapper { width: 100%; height: 50px; margin-top: 20px; background: url('images/footer.jpg') repeat-x; } Why having the clear: both; seperate from footerWrapper lets the margin work I don't know? Can anyone explain why the first code posted doesn't work (with margin-top or padding-top) and the bottom does?
-
Using margin-top had no effect. There is still no gap between them.
-
Hey guys, I'm still fairly new to CSS and I don't understand why the padding isn't being applied to create a gap between mainWrapper and footerWrapper. I'd appreciate it if someone would take a look at the code below and explain to me why it isn't working and how to fix it. HTML: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="theme/default/style.css"> <title>Mafia Online :: Home</title> </head> <body> <header> <h1>Mafia Online</h1> <nav> <ul> <li>Home</li> <li>User CP</li> <li>Forum</li> <li>Games</li> <li>Wiki</li> </ul> </nav> </header> <mainWrapper> <sideBar> <module> <h1>Module 1</h1> <p>This is an example module.</p> </module> </sideBar> <mainContent> <h1>Current Games</h1> <p>Below is a list of all the current games running!</p> </mainContent> </mainWrapper> <footerWrapper> <footerContent> <p>Copyright ©2011 Mafia Online. All rights reserved.</p> </footerContent> </footerWrapper> </body> </html> CSS: @charset "utf-8"; /* CSS Document */ /*CSS Reset*/ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } /* remember to define focus styles! */ :focus { outline: 0; } /* remember to highlight inserts somehow! */ ins { text-decoration: none; } del { text-decoration: line-through; } /* tables still need 'cellspacing="0"' in the markup */ table { border-collapse: collapse; border-spacing: 0; } /*End CSS Reset*/ /* Tell the browser to render HTML 5 elements as block */ header, nav, mainWrapper, mainContent, sideBar, module, footerWrapper, footerContent, error { display: block; } body { background: #000; } header { width: 100%; height: 150px; background: url('images/header.jpg') repeat-x; line-height: 100px; } nav { margin: 0 auto; height: 50px; } nav ul { margin: 0 auto; width: 930px; padding-left: 2px; line-height: 50px; color: #fff; font-family: BickhamScriptPro; font-size: 36px; } nav ul li { float: left; display: block; width: 150px; } mainWrapper { margin: 0 auto; width: 930px; padding-top: 20px; } sideBar { float: left; width: 24%; } module { width: 100%; padding: 12px 5px; background: #FFF; border-radius: 12px; } mainContent { float: right; width: 70%; padding: 12px 5px; background: #FFF; border-radius: 12px; } module h1, mainContent h1 { font-size: 36px; } footerWrapper { clear: both; width: 100%; height: 50px; padding-top: 20px; background: url('images/footer.jpg') repeat-x; } footerContent { width: 930px; margin: 0 auto; line-height: 50px; font-size: 12px; text-align: right; } @font-face { font-family: BickhamScriptPro; src: url('BickhamScriptPro-Regular.otf'), url('BickhamScriptPro-Regular.eot') format("opentype"); /* IE */ } @font-face { font-family: BickhamScriptPro; src: url('BickhamScriptPro-Bold.otf'), url('BickhamScriptPro-Bold.eot') format("opentype"); /* IE */ font-weight: bold; } h1 { font-family: BickhamScriptPro; font-size: 60px; font-weight: bold; text-align: center; }
-
Ah, thank you again. I will change that. I find CSS a pain to learn. It seems to defy most other languages. I would have thought adding a border around the table would have automatically added it around the cells too because the cells should have inherited it from the table. Guess I was wrong...
-
Aha, so you have to define the cells border, not the tables border. Thank you.
-
Hey guys, still fairly new to HTML/CSS and having trouble getting lines to show between the cells in my table. My code for showing the table is: <?php echo "<fleets>"; echo "<table class=\"fleets\">"; echo "<tr>"; echo "<th>Fleet Commander</th>"; echo "<th>Fleet Type</th>"; echo "<th>Fleet Size</th>"; echo "<th>Number of People</th>"; echo "<th>Wanting to Merge?</th>"; echo "<th>Looking For Ships</th>"; echo "</tr>"; while($rowGetFleets = mysql_fetch_array($queryGetFleets)) { //Load each fleet into a table echo "<tr>"; echo "<td id="; if($rowGetFleets['fleetCommanderIsReg'] == 1) //If the FC of the fleet is a registered FC echo "registered"; else echo "unregistered"; echo "><a href=\"#\" onclick=\"CCPEVE.showInfo(1377, " . $rowGetFleets['fleetCommanderId'] . ");\">" . $rowGetFleets['fleetCommanderName'] . "</a></td>"; echo "<td>"; if($rowGetFleets['fleetType'] == 1) echo "Armour"; if($rowGetFleets['fleetType'] == 2) echo "Shield"; echo "</td>"; echo "<td>"; switch ($rowGetFleets['fleetSize']) { case 1: echo "Vanguard fleet"; break; case 2: echo "Assault fleet"; break; case 3: echo "HQ fleet"; break; case 4: echo "Mothership fleet"; break; default: echo "Invalid fleet size"; break; } echo "</td>"; echo "<td>" . $rowGetFleets['fleetNumberOfPeople'] . "</td>"; if($rowGetFleets['fleetMerge'] == 1) echo "<td>Yes</td>"; else echo "<td>No</td>"; //Form string for what ships the fleet is looking for $looking = FALSE; if($rowGetFleets['lookingForLogistics'] == TRUE) { $strLookingFor = "Logistics"; $looking = TRUE; } if($rowGetFleets['lookingForDps'] == TRUE) { if($looking == TRUE) $strLookingFor = $strLookingFor . ", DPS"; else { $strLookingFor = "DPS"; $looking = TRUE; } } if($rowGetFleets['lookingForSniper'] == TRUE) { if($looking == TRUE) $strLookingFor = $strLookingFor . ", Snipers"; else { $strLookingFor = "Snipers"; $looking = TRUE; } } if($rowGetFleets['lookingForOgb'] == TRUE) { if($looking == TRUE) $strLookingFor = $strLookingFor . ", an Off-Grid Booster"; else { $strLookingFor = "An Off-Grid Booster"; $looking = TRUE; } } if($looking == FALSE) $strLookingFor = "None"; echo "<td>$strLookingFor</td>"; echo "</tr>"; } //End of while echo "</table>"; echo "</fleets>"; ?> My CSS file is: @charset "utf-8"; /* CSS Document */ /*CSS Reset*/ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } /* remember to define focus styles! */ :focus { outline: 0; } /* remember to highlight inserts somehow! */ ins { text-decoration: none; } del { text-decoration: line-through; } /* tables still need 'cellspacing="0"' in the markup */ table { border-collapse: collapse; border-spacing: 0; } /*End CSS Reset*/ /* Tell the browser to render HTML 5 elements as block */ header, footer, nav, text, messages, success, error, fleets, faq, leftWrapper, rightWrapper, bottomWrapper { display: block; } body { margin: 0 auto; width: 900px; font: 13px/22px Helvetica, Arial, sans-serif; background: #202020; color: #f1f1f1; } header { background-color: #202020; margin: 0 auto; width: 900px; height: 120px; color: #EEEEEE; } footer { clear: both; margin: 0 auto; width: 900px; font: 11px Arial, Helvetica, sans-serif; padding-top: 30px; } h1 { font-size: 28px; line-height: 44px; padding: 22px 0; text-align: center; } h2 { font-size: 20px; line-height: 44px; padding: 22px 0; } p { padding-bottom: 22px; } a { color: #d50000; } a:hover { color: #f1f1f1; } a:selected { color: #f1f1f1; } a:active { color: #f1f1f1; } nav { left: 0; width: 100%; height: 50px; } nav ul { margin: 0 auto; width: 900px; padding-left: 2px; } nav ul li { float: left; display: block; width: 128px; } navAdmin ul li { float: left; display: block; margin-right: 15px; width: 160px; font-size: 14px; line-height: 44px; text-align: center; color: #000; } messages { clear: both; margin: 0 auto; width: 100%; } success { width: 100%; font: 13px/22px Helvetica, Arial, sans-serif; color: #090; } error { width: 100%; font: 13px/22px Helvetica, Arial, sans-serif; color: #C00; } fleets { width: 100%; } table { text-align: left; vertical-align: middle; } text { clear: both; } ol li { list-style-type: decimal; font-size: 14px; list-style-position: inside; } faq h3 { font-size: 15px; padding: 5px; } leftWrapper { width: 50%; float: left; } rightWrapper { width: 50%; float: right; } bottomWrapper { clear: both; } /*Classes*/ table.selected { width: 350px; } table.fleets { width: 900px; border: 1px solid #303030; } table.updateFleet { width: 500px; border: thick solid #e0e0e0; } table.updateFleet th, td { text-align: left; } table.fleets th, td { padding: 5px 15px; min-width: 110px; } .lf { width: 60px; } /*IDs*/ #home { background-image: url(../images/banner_home.jpg); } #admin { background-image: url(../images/banner_admin_cp.jpg); } #faq { background-image: url(../images/banner_faq.jpg); } #fleets { background-image: url(../images/banner_manage_fleets.jpg); } #profiles { background-image: url(../images/banner_register_as_fc.jpg); } #register { background-image: url(../images/banner_register_as_fc.jpg); } #btnAdmin { display: block; width: 128px; height: 50px; background: url(../images/button_admin_cp.gif) no-repeat 0 0; } #btnAdmin:hover { background-position: 0 -50px; } #btnAdminStatic { display: block; width: 128px; height: 50px; background: url(../images/button_admin_cp.gif) no-repeat 0 0; } #btnHome { display: block; width: 128px; height: 50px; background: url(../images/button_home.gif) no-repeat 0 0; } #btnHome:hover { background-position: 0 -50px; } #btnFaq { display: block; width: 128px; height: 50px; background: url(../images/button_faq.gif) no-repeat 0 0; } #btnFaq:hover { background-position: 0 -50px; } #btnFleets { display: block; width: 128px; height: 50px; background: url(../images/button_manage_fleets.gif) no-repeat 0 0; } #btnFleets:hover { background-position: 0 -50px; } #btnJoin { display: block; width: 128px; height: 50px; background: url(../images/button_join_btl_pub.gif) no-repeat 0 0; } #btnJoin:hover { background-position: 0 -50px; } #btnJoinStatic { display: block; width: 128px; height: 50px; background: url(../images/button_join_btl_pub.gif) no-repeat 0 0; } #btnProfiles { display: block; width: 128px; height: 50px; background: url(../images/button_profiles.gif) no-repeat 0 0; } #btnProfiles:hover { background-position: 0 -50px; } #btnRegister { display: block; width: 128px; height: 50px; background: url(../images/button_register_as_fc.gif) no-repeat 0 0; } #btnRegister:hover { background-position: 0 -50px; } #btnRegisterStatic { display: block; width: 128px; height: 50px; background: url(../images/button_register_as_fc.gif) no-repeat 0 0; } #secure { text-align: center; color: #C00; } #registered { background: #82E082; } #unregistered { background: #FF7878; } #center { text-align: center; } #middle { text-align: center; vertical-align: middle; } Only the border around the table is showing, not the lines between the cells. Can someone help me? I've tried rules=rows with no joy. I've tried cellspacing=1. I have no clue as to what it could be.