-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
Executing SQL queries in a loop is a fairly common cause of slow pages. For example doing something like: $res=mysql_query('SELECT blah FROM bleh'); while ($row=mysql_fetch_assoc($res)){ $res2=mysql_query('SELECT foo FROM boo WHERE blah='.$row['blah']); } The only way to find out what is going on really though is to profile the script to see what exactly is taking up the time. If your PHP script seems to be running about as quick as possible but it still takes a long time for the page to render, you'll need to use browser dev tools like firebug or chrome's console to analyze where the time is being spent (loading resources such as scripts, parsing the dom, applying css, etc).
-
Your Arduino code does not account for the \r\n characters you are sending. When your PHP code sends "L\r\n" you're sending three separate characters that the arduino will then read. On the first loop it will read 'L' and set the light because in == 'L'. On the second loop it will read the \r and hit the else part, turning the light off again. The third loop will read a \n and hit the else again then the rest of the loops will just keep hitting the else branch because in=='\n'. You'll need to either change the arduino code to allow for the new lines or change the PHP to not send them. I haven't looked through the PHP serial class to know if they are necessary to flush the data or not.
- 16 replies
-
- script
- serial port
-
(and 2 more)
Tagged with:
-
Assuming you're talking about the shaded regions, my best guess would be that they are using the Polygon feature of the maps api to define the regions on the map.
-
You can put a PHP file as the source for an image, there is nothing wrong with that. You just have to make sure the PHP file outputs a valid image file. No, you don't just echo raw image data into the src attribute. At the very least you would have to construct a data: uri from the data, but using a separate PHP file as the OP is currently doing would be the easiest/most flexable method. Load your Communication_socket.php file directly in the browser so you can see if there is any extra output such as PHP warnings or HTML code. If there is any output other than the image data you receive it will cause the image to be invalid.
-
What is the code you're using on the arduino? You said the light turn on, but then turns off again right away so it sounds like PHP is sending the data properly. The Arduino is just not interpreting it properly or the PHP code is not sending the correct data. Without both pieces of the puzzle it's hard to say which.
- 16 replies
-
- script
- serial port
-
(and 2 more)
Tagged with:
-
You can't do what you're trying to do. The closest you could get to using a variable with multiple items in the IN clause is to use a table value varaible, such as: DECLARE @test TABLE ( s VARCHAR(100) ) INSERT INTO @test VALUES ('test1'),('test2'); SELECT * FROM testtable WHERE col1 IN (SELECT s FROM @test)
-
Yes, it will only return a matching row once regardless of how many times it's value appears in the IN clause. No, afaik there is no way to change that. If you need it multiple times, you'll have to do that after the fact in your PHP code. Select each row's data then duplicate it when you read the results if necessary. It may be helpful to describe what exactly you're trying to do, perhaps someone can provide a better approach.
-
How Do I Configure Error Messages To Format Like This?
kicken replied to idkwhy's topic in PHP Coding Help
You set your custom error handler by calling the function set_error_handler and passing it the name of your function. Any time there is an error (of certain types) PHP will call your function to handle the error. You can have that function format the error output however you want by just echoing out the proper html for it. -
Have your include file accept a variable that defines the ID/Name of the select boxes, then use that to identify which ones to validate. eg: Date of Birth: <?php $fieldName='birth'; include("includeDOB.php"); ?> <select name="<?php echo $fieldName;?>_Day" id="<?php echo $fieldName;?>_Day"> <option selected>Select</option> <?php $day=1; while($day<32) { ...
-
Near as I can tell from the documentation the way you would use the offset feature is like so: SELECT col1, col2, col3 FROM table ORDER BY col1 OFFSET 0 ROWS FETCH 10 ROWS ONLY Would be equivalent to the mysql query SELECT col1, col2, col3 FROM table ORDER BY col1 LIMIT 0,10 I only have sql server 2008, so I can't actually try anything. For 2008 one would use: SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY col1) as rowNumber, col1, col2, col3 FROM table ORDER BY col1 ) page WHERE rowNumber BETWEEN 1 AND 10
- 2 replies
-
- mssql2012pagination
- offset
-
(and 1 more)
Tagged with:
-
$content= '$sql = mysql_query("SELECT * FROM instructors WHERE name=\'$uid\' AND passwd=\'$pwd\' ");'; See also the manual page on strings for all the details and alternative ways.
-
I use it for my template system. Code a bit like: function DoTemplate($__file, $__vars){ extract($__vars); include($__file); } DoTemplate('somefile.tpl', array( 'title' => 'blah' , 'desc' => 'Some description' )); Then in the template file I can just use the key names directly as variables: <html><head><title><?php echo $title; ?></title></head> <body> <h1><?php echo $title; ?></h1> <p><?php echo $desc; ?></p> </body> </html>
-
You'll have to use a UNION and two separate select queries, rather than joining things together like you're currently doing.
-
Fputcsv() Is Writing To My File But Erasing The Previous Data
kicken replied to s4surbhi2218's topic in PHP Coding Help
It's not the fputcsv that is wiping out your file, it's the fact that you're using mode 'w' when you open it. If you want to append the data to the file, use mode 'a': -
Paginate A Table In Multiple Databases (Php/mysql)
kicken replied to FishSword's topic in PHP Coding Help
You can do a UNION across different database (in my version of mysql at least, 5.5.25). SELECT * FROM t1.users UNION ALL SELECT * FROM t2.users UNION ALL SELECT * FROM t3.users; returns +----+------+ | ID | name | +----+------+ | 1 | t1a | | 2 | t1b | | 1 | t2a | | 2 | t2b | | 3 | t3a | | 4 | t3b | +----+------+ You can apply your limits for pagination and an order by to the result of the union query. -
Use a couple of foreach() loops and unset(). If you want a better answer provide more details such as how that data is structured in your code and/or where it comes from (db tables/structure).
-
When Connected To A Certain Network, Stylesheet Doesn't Load.
kicken replied to DVigneault's topic in CSS Help
If it's not loading due to the library's network filtering it out, you'd have to find out why it is filtering and see if you can change it so it doesn't match that filter condition anymore. Without someone here being able to actually see the problem (which from the description would mean going into that library and trying to load the site) it's unlikely you'll be able to get much help. Providing the URL to your live website may improve your chances at getting some help. -
Just as an FYI, the "what I want" code you have is invalid HTML. Your child <ul> needs to be inside one of the parent's <li> tags, eg: <ul class="catalognav"> <li> <a class="selected" href="#">Tops /</a> </li> <li> <a href="#">Denim /</a> </li> <li> <a href="#">Outerwear /</a> <ul class="childnav"> <li><a href="#">Shirts /</a></li> <li><a href="#">Sweaters /</a></li> <li><a href="#">Tees /</a></li> <li><a href="#">Hoodies and Sweatshirts /</a></li> </ul> </li> </ul>
-
That is going to block until you read either 128 bytes of data, or a new-line character. Since your server is not sending data which meets either of those conditions, your PHP script is going end up stuck there waiting indefinitely. The easiest fix is to just make sure your server meets one of those conditions, such as adding \r\n to the end of the data you send: connect.send("AUTHENTICATION DETAILS REQUIRED\r\n")
-
You would just replace the second parameter of $.get with a variable. eg: var myobj = { param1: 'blah', param2: 'blah' }; $.get('someurl', myobj, function(data){ console.log(data); }); Then you just have to define what myobj is, which you can do conditionally if necessary.
-
Wasn't Sure Where To Post This - Possible Vulnerability?
kicken replied to Beeeeney's topic in Website Critique
Providing a directory listing isn't necessarily a bad thing unless there's some files in there you don't want the world to know about. If you want to prevent the listing then either configure your server to not provide it (Options -Indexes in .htaccess I believe) or put a simple index.html file in each folder. -
You use it regardless of the magic quotes setting. However if magic quotes=on then you need to run your request data through stripslashes before hand.
-
Not all operating systems are equipped with the same set of fonts. A user could always remove fonts or install extra fonts as well, though someone removing a font is probably not typical. Even if the OS has a specific font though, a particular programs may not be able to use every font that is installed on the system. You can't know with certainty that any given font is available. CSS does however support the concept of generic font families so you can at least specify the type of font that should be used. Ie, you can specify that your text should be font-family: monospace to get a fixed-width font, rather than trying to use a specific font like font-family: fixedsys Which font the system uses for a particular family is up to the user/program to decide but it will meet some basic conditions (ie fixed-width characters). For newer browsers, you can set it up so that the browser may actually download the font you want in order to render the page using that font, but you should still choose a good generic family to fall back on in case the browser either does not support this, fails to download the file, or cannot render that type of font.