
Porl123
Members-
Posts
239 -
Joined
-
Last visited
Everything posted by Porl123
-
I have a users table which has 28 fields in it but I've been told that it's bad use of MySQL to have this many fields in one table. I just thought that if I kept all the essential information in one table then it would require less queries. I have made the majority of my website and it's a big website but I was wondering how far I could take the column count before it starts affecting anything. By the time the site is finished it could easily be up to 50 fields, so I just wanted to know how cautious I should be. If it's just a case of the table looking untidy I don't really mind, I keep it organised. I've heard the average limit before mysql stops accepting new columns is a few thousand so I'm not that worried. If anyone can shine some light on this I'd be grateful. Thanks!
-
I'm not really sure of how much of a daft question this is but would it be more taxing on memory to do 1 or 2: 1. create a SELECT query to get all records that have timed out, then use a while loop to go through and delete them from the database or 2. just have a delete query which deletes all records where timer - time() < 1. there would on rarely be any rows affected by this query which would make me think that it's the more efficient option. i'm sorry if i've explained this terribly but i just needed some clarity. thanks to anyone who can help
-
Hi my MySQL version is 5.0.67 and I have a problem when I join my forum topics table with my forum replies table. The statement I'm having the problem with is on the forum topics page. What I want it to do is to go through the topics table and echo out the subjects (titles), author name and reply count, so I used LEFT JOIN so I wouldn't need a separate query per topic to check the post count. The problem is that it seems to disregard the WHERE clause where I only want it to show topics where del = 0 (not deleted) however it still posts the row anyway, just with blank fields, then 0 where the reply count should be. Does anyone know what I'm doing here to make it post the row? SELECT `forumTopics`.`id`, `forumTopics`.`subject`, `forumTopics`.`author`, COUNT(`forumReplies`.`id`) FROM `forumTopics` LEFT JOIN `forumReplies` ON `forumTopics`.`id` = `forumReplies`.`t_id` WHERE `forumTopics`.`del` = 0 I'm fairly new to MySQL so I'm sorry if I'm explaining this all wrong. :c thanks!
-
Ah yeah it's sorted now. :] thanks premiso.
-
$string = preg_replace('/\[img\](.*?)\[\/img\]/','<img src="'.validImage('\\1').'" />',$string); I'm trying to make the image tags bb code, but I need to put the link through the validImage function to check that it isn't an invalid image. I'm not really sure how to wrap it though. I think the way I've done it above just analyses the literal phrase '\\1' rather than what it represents. Anyone know what I'm doing wrong? Thanks guys!
-
Yeah, it's a pain in the arse because when you allow both to scroll, the horizontal bar accounts the vertical bar as part of the div width in IE, so I can't get rid of the horizontal bar. I'll just have to live with it. D: Thanks anyway!
-
Adding style="display:inline;" to the form tag should remove that.
-
I've got a div for my navigation bar with a fixed height, which has another div inside containing the links of my website. What it's meant to do is when the inside div gets too long the outer div is supposed to have a scrollbar, and it works fine for every browser but IE. Here's the css of the outer div: #mainNav1 {float: left; height: 496px; width: 180px; border: 1px solid #111; overflow-x: hidden; overflow-y: auto; font-size: 10px; text-align: center; padding: 0px;} Can anyone point out my mistake? Thanks
-
I tried using visibility but that made it a bit worse. D: <tr name="misc"> <td class="NavTd"><a href="/updates.php" target="mainSect">Updates</a></td> </tr> Here's an example of the table row it's supposed to toggle if it helps.
-
function showHideLinks(menu) { var menuItems = document.getElementsByName(menu); for(var i in menuItems) { if(menuItems[i].style.display != '') { menuItems[i].style.display = ''; } else { menuItems[i].style.display = 'none'; } } } I've got this toggle function which collapses sections of the navigation bar and it works in most browsers but not this older version of IE that I have. Does anyone see anything wrong with this? Thanks in advance!
-
function ajaxCon() { var xmlhttp = false; if(window.XMLHttpRequest) { xmlhttp = XMLHttpRequest; } else { xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); } if(xmlhttp != 'false') { return xmlhttp; } } var xmlContent = ajaxCon(); if(xmlContent == false) { alert('Bad browser.'); } else { xmlContent.open('GET', 'http://www.google.com', true); xmlContent.send(); xmlContent.onreadystatechange = function() { if(xmlContent.readyState == 4) { alert(xmlContent.responseText); } } } Hi, I'm quite new to javascript/ajax and I'm not really sure why this isn't working. I just copied this from a few tutorials and edited it. What I want it to do is to get the contents of the page. I've just put in google as an example. Can anyone see where I've gone wrong? Thanks!
-
Yeah, that's pretty much what I've got at the moment, except it only returns one reel per call to the function. What I was wondering is whether it could have weighted probability, so it chooses the misses and cherries than for example, the 7.
-
if(isset($_GET['r'])) { $_SESSION['r'] = $_GET['r']; } When you're asking whether a GET, POST or SESSION variable is set, use the isset() function.
-
Hey guys, I was just trying to make a simple php slot machine with realistic probability and was wondering whether anyone would have an idea of how to do that? The slot machine has 3 reels. I've started a function which produces the reels and has the option to select from '7', 'bar', 'orange', 'cherry', 'MISS (spun between 7 and cherry)' and 'MISS (spun between cherry and orange)'. If anyone can direct me on how to weight this probability to make the outcomes such as 7 and bar appear less often I'd be very appreciative. Thanks in advance!
-
<?php $items = array(1 => 'item 1', 2 => 'item 2', 3 => 'item 3', 4 => 'item 4', 5 => 'item 5'); ?> I've got an array like that and in the script it would pick an item at random, which I could use array_rand() for but I was wondering whether there'd be a way to weight the probability to a specified number? So items lower in the array would be chosen more often. If anyone gets what I mean and can help I'd really appreciate some guidance. Thanks!
-
You need to do two individual if statements, rather than an if elseif. Otherwise the subject will not be return as blank if the name is empty.
-
Most would be the results with the most amount of characters from the search criteria.
-
I've just made a search form for a page on my site that gets all images with a name similar to the one entered with `filename` LIKE '%'.$_POST['name'].'%' and I was wondering is there a way to order the results of the query by the results that match the search criteria the most? So going from most matched to least? If that's possible could you talk me through it? Thanks !
-
Ah yeah that sorted it thanks for all the help guys!
-
Yeah it's shown as 1.2E+10. so would php see what this represents or would I need to convert it?
-
No ideas? can't think of anything else
-
I just realised it wasn't in that function it was in the script. I'm not sure why but 12000000000 was converted to 1.2E+10 and when I used intval to get the value I saw intval has a limit of 2147483647 If anyone knows any other functions I'd really appreciate you helping me
-
Would ctype_digit() do the job that I want this to do btw?
-
I made a function which makes sure all numbers entered only contain the characters 0-9 but for some reason if you enter random numbers it returns false function validno($var) { if(!is_numeric($var)) { $ret = 0; } elseif($var < 0) { $ret = 0; } elseif(!preg_match('/^[0-9]+$/', $var)) { $ret = 0; } else { $ret = 1; } return $ret; } It returns false if you enter 12000000000, 14000000000, 17000000000 that I'm aware of. Probably more but I'm not sure. Any see the problem? Thanks
-
I've got an onMouseOver on a div, which when the mouse hovers over an element inside the div, it cuts out. It's probably because it just doesn't see the image as the div anymore but I was wondering if there's a way around it: <script language="JavaScript" type="text/javascript"> function play_track(track) { var box = document.getElementById('music'); var inf = document.getElementById('track-info'); if(track != 1) { box.innerHTML = '<embed src="' + track + '" style="border: 0px; height: 0px; width: 0px" hspace="0" vspace="0" hidden="true" autostart="true" loop="true" allowscriptaccess="never" type="audio/mpeg"></embed>'; inf.innerHTML = '<b>NOW PLAYING:</b> blabla<br /><br />'; } else { box.innerHTML = ''; inf.innerHTML = ''; } } </script> <div id="track-info"></div> <div id="main" style="width: 150px; height: 150px; background-image: url(none.jpeg)" onMouseOver="play_track('test.mp3')" onMouseOut="play_track(1)"><img src="button.jpeg" style="width: 50px; height: 50px" onclick="window.open('test.php', '_blank');" /></div> <div id="music"></div> If anyone knows a way around it cutting off when it goes over the image al be reet grateful. thanks!