-
Posts
471 -
Joined
-
Last visited
-
Days Won
8
Everything posted by dalecosp
-
Your English is pardoned ... but I'm (unforunately) not quite clear on what you want. It sounds like you want to update the form page with data from the server without submitting the form. This requires AJAX (Asynchronous Javascript And XML) and is something of an advanced topic (and not much about PHP).
-
Won't you get in trouble if I do your homework for ya? ;) <?php echo "Enter any number\n";$number=trim(fgets(STDIN));$low=floor($number);$decimal=$number - $low;$real=decbin($low); $counter = 0; while(0<$decimal<1) { //fixed this; either way works in PHP, but Javascript needs //the bracket on the right --- so it's a good habit to start $mantissa[]=$decimal*2; $counter++; if ($counter == 10) { break; }} echo "\n";?> HTH,
-
Well, yes, triggered by something, typically an event. Javascript is the internal language of the browser, and the browser is displaying what's given to it by the server. In the context of the loaded "page", it will then execute. So you use Javascript most often to manipulate the document (page) when it's already loaded in the browser window, which means you're manipulating the browser's view of the code (the DOM) after it's already been parsed and rendered, more or less.
-
The API is the browser, and the quote is from Douglas Crockford, a renowned speaker on Javascript. Start here: and you'll learn quite a bit about Javascript. There are 3 parts to this original teaching, and he's gone on from there to "world famous" on the subject.
-
You'd do well to get a book or some web tutorials on Java*script*. Remember this is NOT JAVA. An array in Javascript is just as simple as PHP, or perhaps moreso, and can be initialized like this: myArray = ['dog','cat']; Putting it "in the browser", though, is a whole 'nother can of worms known as "manipulating the DOM" (Document Object Model). One of Javascript's biggest proponents calls it (the DOM) nothing less than the "worst API ever invented." Here's one way it could be done, but I would never recommend it for general use: myArray = ['dog','cat']; body = document.getElementsByTagName("body"); body[0].innerHTML = myArray[0];
-
This usually indicates that the POST array doesn't have the structure that you expect it to. What does print_r($_POST); at the top of the script give you?
-
Need help stopping a form from posting if no file attached?
dalecosp replied to A JM's topic in PHP Coding Help
Yes, probably, for UI convenience; of course, this doesn't take into account users with JS disabled/unsupported, or people with questionable intentions. So you should also check with PHP on the server-side near the top of the handler script. I'd probably check "$_FILES['userfile']['size']" for that. -
is this query faster or i have to do something to make it fast ?
dalecosp replied to Pawan_Agarwal's topic in MySQL Help
They have docs http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html -
Set a counter variable, increment it in the while loop, and either check it with logical AND in the conditional or use a break() statement inside an "if" in the while loop?
-
Yup it's wrong. Since I'm not sure what you want, dunno if I can fix it. Does this work? $banner_location = "http://".$_SERVER['SERVER_NAME']."/images/".$page_language.".png"; echo "<a href=http://".$_SERVER['SERVER_NAME']."/tilfredshedsgaranti-".$page_language.">"; echo "Link text goes here"; echo "</a>";
-
PHPexcel to export SQL data to workbook and multiple sheets
dalecosp replied to kms's topic in PHP Coding Help
As I tried to imply, I wondered at the time if it was a translation problem between PHP and the MS-interface; I might try playing with trim() or strtoupper(), etc. and see if that helps. Sorry that I'm basically clueless here. -
PHPexcel to export SQL data to workbook and multiple sheets
dalecosp replied to kms's topic in PHP Coding Help
I'm not sure; in my interaction with PHPExcel I keep my nose buried in the docs most of the time. I did check on one script that *reads* from multiple sheets, and it works using a numeric array and setActiveSheetIndex($sheetnum); ... so I can't say for sure whether setActiveSheetIndexByName() works for me or not. You're sure that $row['TeamName'] is a valid sheet name at this point? It seems like I used the numeric approach because I couldn't figure out the sheet name translation ... -
PHPexcel to export SQL data to workbook and multiple sheets
dalecosp replied to kms's topic in PHP Coding Help
You only do this: $objPHPExcel->setActiveSheetIndex(0); the one time --- is this: $objWorksheet = new PHPExcel_Worksheet($objPHPExcel); $objPHPExcel->addSheet($objWorksheet); $objWorksheet->setTitle(''. $row['TeamName']); $objPHPExcel->setActiveSheetIndexByName($row['TeamName']); Supposed to be adding the sheets? I don't see that you done any checking to see if these calls are failing ... might be a place to start... -
I'd go to BBC's site and see if they have an RSS feed, XML/Soap Service, JSON feed, etc. That way you'd not be likely to violate any T.O.S. that they might already have in place....
-
Mysql Query taking too much time. Almost 10 minutes
dalecosp replied to boomarang's topic in MySQL Help
Well, Pawan, you're "hijacking" by attaching your question to another thread, but I'll try and shed some light anyway. select * from people_record where user_id=AAAA_00001A couple of observations about the code first: 1] Do you really need to "select *"? It's better to select only the data you need unless you truly need it all. 2] You must use quotes around the user_id comparator unless it's completely numeric: "where user_id='AAAA_00001'" ... That said, MySQL should quickly retrieve the correct row ... IF the row is indexed it will help. Is "user_id" a primary key (it usually is). Here's an example of a table where the ID field is the primary key: mysql> describe companies; +---------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(256) | YES | | NULL | | | url | varchar(50) | YES | | NULL | | | business_type | int(11) | YES | | NULL | | +---------------+--------------+------+-----+---------+----------------+ MySQL is indexing the "id" field, so queries using this field as a selector will be faster than queries using the "name" field as the selector. HTH, -
Let's take a look at these lines: if (mysql_query($query) === TRUE) { $_SESSION['seqno'] = mysql_insert_id(); $_SESSION['user'] = $_POST['firstname']; $_SESSION['emailid'] = $_REQUEST['emailid']; }else{ header('Location: form.php?errormsg=Insert Error.'.mysql_error()); #die("Error! Insert failed.Please try again"); } You actually had, at some point, the ability to print planned ... but you're redirecting first. Try something like this for debug purposes *only*: if (mysql_query($query) === TRUE) { $_SESSION['seqno'] = mysql_insert_id(); $_SESSION['user'] = $_POST['firstname']; $_SESSION['emailid'] = $_REQUEST['emailid']; }else{ //header('Location: form.php?errormsg=Insert Error.'.mysql_error()); die("Error! Insert failed. The SQL was $query <br><br> MySQL said: ".mysql_error()); }
-
The business case typically all comes down to maintenance, something you've hinted at. Our company's flagship site is based on (a long time ago) a package that was heavily adapted prior to deployment. As time has gone on, continued customization has put us in a position where we cannot upgrade the package without destroying the site's functionality. That being said, a lot of businesses at least strongly consider what you're talking about --- after all, we did it with a package originally to save time/money on the initial development cost. I don't know what the "fallover" point of customization vs. configuration is, unfortunately; we find we're committed to customization at this point. The original software doesn't scale well enough to support our growing business, so over the last year or so I've found myself replacing large chunks of our functionality with something totally custom that runs a couple of orders of magnitude faster. Doug Henschen wrote a good article on this in Information Week last fall; it might be worth discussing with your staff. Hope this helps,
-
Thanks ... you're welcome.
-
Your console error is: Uncaught TypeError: Cannot read property 'left' of undefined No JS guru here either, but I'm guessing we'd need to figure out why "position" is undefined at this point.
-
You want "SELECT COUNT(something)", then, not that humongous query with a "SELECT *" ... too expensive otherwise.
- 8 replies
-
- php
- pagination
-
(and 2 more)
Tagged with:
-
<?php$signatureslist = mysql_query("SELECT * FROM $table, $usernamestable Where $table.subscriber_id= $usernamestable.id and $table.list_id='$listid' ORDER BY subdate desc limit 20 ", $link); if (!$signatureslist) { //put an error handler here: maybe 'die("no result from Query!");' ?} //I'm gonna change your bracket style; you should do it as the above in JS, so let's do it in PHP too... while ($row = mysql_fetch_assoc($signatureslist)) { echo '<li style="padding:5px 0 5px 0;"><strong class="largertext" style="color:#e6b532">'; echo $row[name]; echo ' </strong><br /><div style="margin-top:-6px">from '; //Generally it's not a good idea to put a query inside a loop. If your outer loop will occur many times, that is... can this be combined with the query above?//also, why do "select *" when you're only using "column1" ? $registeredcountry = mysql_query("SELECT column1 FROM z1gv4_community_fields_values where user_id =" . $row[user_id] . " and field_id = " . $field_id . "", $link); //this looks like an error ... no block brackets after it? I'll add them: while ($row2 = mysql_fetch_assoc($registeredcountry)) { //added this one if(empty($row['column1'])) { echo $row2[value]; } else { echo $row[column1]; }}//and this one
-
echo doesn't output-- help, please.
dalecosp replied to SpartanTacoDuckie's topic in PHP Coding Help
In a development environment, if a query fails, print the query, and then print the error message. This often helps you find the issue more quickly. -
Is this right? Because to write a query like that and then only use it for a calculation (and incidentally, are you quite certain it's a numeric value and not a DB resource handle you're using as the dividend there?) seems a tad strange...
- 8 replies
-
- php
- pagination
-
(and 2 more)
Tagged with:
-
Mysql Query taking too much time. Almost 10 minutes
dalecosp replied to boomarang's topic in MySQL Help
Barand knocked it, and gets my vote. The title of the thread should probably be "10 minutes to run 18 million queries ... I've got a great server!" ;) And I know we may be a tad over-zealous and have killed PHPBuilder by saying this, but, for goodness' sake, it's 2013. mysql_query, mysql_fetch_assoc, mysql_connect, and all the mysql extension functions have been deprecated. Time to use mysqli instead, or PDO ....