-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
No. You require openCV. PHP's graphics libraries are not enough.
-
Bit of a dilemma, need help with cookies and sessions
JonnoTheDev replied to nobodyk's topic in PHP Coding Help
I can't see the benefit of using a cookie in this situation -
Bit of a dilemma, need help with cookies and sessions
JonnoTheDev replied to nobodyk's topic in PHP Coding Help
Why not record the users IP address? $_SERVER['REMOTE_ADDR'] -
What it supposed to be happening is that the list of sites that a bookmark can be posted to are returned. For example if I have 5 sites of lets say scriptId 4, each site has 2 user accounts (10 total), and 1 bookmark to post. I want to know what users have posted this bookmark to what site and only return the sites that haven't had the bookmark posted by all user accounts. So out of 10 users, if 5 of them (1 from each site) have posted the bookmark. The query should still return all 5 sites as there is still 1 user account remaining for each site that the bookmark has not been posted to. If 1 of the 5 remaining accounts posts the bookmark then the query should return 4 sites as 1 site has used up all its user accounts. Using the following as opposed to 1 query still takes time to return the records. These queries are simple IMO. # OBTAIN ALL USERS FROM EACH SITE WHERE SCRIPT ID = X, CREATE TEMPORARY TABLE # ------------------------------- CREATE TEMPORARY TABLE siteUsers SELECT s.siteId, u.userId FROM site s INNER JOIN user u ON(s.siteId=u.siteId) WHERE s.scriptId='4'; # OBTAIN ALL USER ACCOUNTS FROM EACH SITE WHERE SCRIPT ID = X THAT HAVE SUBMITTED BOOKMARK X. DELETE THE RESULTS FROM TEMPORARY TABLE # ------------------------------- DELETE FROM siteUsers WHERE userId IN(SELECT su.userId FROM submission su WHERE su.bookmarkUrl ='http://www.xyz.com' AND su.scriptId='4'); # OBTAIN A DISTINCT LIST OF SITES FROM THE REMAINING RESULTS IN THE TEMPORARY TABLE. THE RESULTS ARE THE REMAINING SITES WHERE USER ACCOUNTS ARE # AVAILABLE TO POST BOOKMARK X # ------------------------------- SELECT siteId FROM siteUsers GROUP BY siteId;
-
As soon as the javascript function containing the request is called, usually through an event handler such as onClick() i.e the user clicks a button. When the readyState value is 4 the script has completed.
-
Windows, as you would need MS Word installed on the server. http://www.php.net/manual/en/intro.com.php
-
Get value before and/or after "x" in a string?
JonnoTheDev replied to dominod's topic in PHP Coding Help
Just to add to that, if you aren't sure about arrays. $res = explode('x', $resolution_value); $width = $res[0]; $height = $res[1]; -
Do some debugging. In your php file print the values of the GET variables i.e print $_GET['id']."<br />".$_GET['section']; This should be diplayed within <span id="locations1"></span> Use Firefoxs' error console incase there are any Javascript errors. Check the JS is running. Use a simple alert() to show that the request has been made i.e if (req.status == 200) { alert('completed'); } Check that the request URL is the correct path. I would usuall use the full url as opposed to just the file filename. var strURL="_getLocations.php?id="+hotelId+"§ion="+selectid
-
It is complete when the readyState is 4 (as you have showed in your document). There will also be a status of 200. Example: // start ajax object var req = Inint_AJAX(); // check request status req.onreadystatechange = function () { // request is complete if (req.readyState==4) { // status ok if (req.status==200) { alert('finished processing'); } } }; // make connection req.open("GET", "/phpfile.php"); // set header req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // send value req.send(null);
-
Impossible. This is correct. No, just make sure you give each file created a unique name so one user cannot overwrite anothers if running at the same time. You can create word documents using fopen(), fwrite(), etc and save the file with a .doc extension, However if you want a properly formatted document you require COM objects (windows servers only). For PDF generation I recommend the following http://www.fpdf.org/
-
I need users as I need to know the users from a particular scriptId and also the users who have submitted the bookmark already to sites from that script. Here is a modified query that uses all indexes. Still takes the same time to return results. Around 15 seconds. SELECT s.siteId FROM site s INNER JOIN user u ON(s.siteId=u.siteId AND u.scriptId='4') LEFT JOIN submission su ON(s.siteId=su.siteId AND u.userId=su.userId AND su.bookmarkUrl ='http://www.xyz.co.uk') WHERE ISNULL(su.subId) GROUP BY s.siteId So, from the 44,673 results I need all unique siteIds. That is where the GROUP BY comes in. This should result in about 77 records. Even if I use DISTINCT as opposed to GROUP BY, the query is still slow. [attachment deleted by admin]
-
I can see that. site.siteId is the PK, user.siteId has an INDEX. If I run a query to join site to user on siteId where scriptId=x, the indexed used is siteId. In the problematic query the indexed is not used, so therefore it is the rest of the query.
-
That is the Primary KEY
-
Explain results [attachment deleted by admin]
-
See, there is still an issue here. Even though removing the GROUP BY claus results in a faster query process time (reported by phpMyAdmin), the actual results take the same amount of time to be returned to the client in both queries. So the query with the GROUP BY removed that supposedly took 0.1318 sec still takes around the same time as the first query to display any results. So that is fishy! Lets try using the actual MySQL command prompt on the server. The query without the GROUP BY claus: 44317 rows in set (15.48 sec) The query with the GROUP by claus: 77 rows in set (16.34 sec) Looks like phpMyAdmin gives incorrect results in this case. So fundamentally there is little difference between the 2.
-
Using GROUP BY 77 total, Query took 16.4740 sec Without GROUP BY 44,317 total, Query took 0.1318 sec
-
Ill check tomorrow and let you know
-
No because NOW() returns the current date & time, not a unix timestamp
-
You're welcome
-
There is no way the code posted would fail! I think your database wrapper class is probably garbage. The fact that you are using or die(mysql_error()) after an object method call doesn't make sense. The object should handle query errors in an internal method. Where did you get it from? However, the results are returned in an array. Try scrapping that object and use a general mysql function. Copy this code entirely and change the database query to match your table <?php function cname($pubid) { $result = mysql_query("SELECT * FROM my_database WHERE id='".$pubid."'") or die(mysql_error()); $company = mysql_fetch_assoc($result); return $company['name']; } print cname($pubid); ?>
-
I wouldn't use osCommerce for that. I would probably build my own bespoke solution.
-
I am 100% sure that you have not copied my code correctly or changed the database query to match your tables! If you are still using your original code then here is your error: <?php while($company= $db->fetch_array($company)) { $cname = $company['name']; } ?> You are overwriting $company which contains the result set <?php while($x = $db->fetch_array($company)) { $cname = $x['name']; } ?>
-
Rather than using this from the superglobal: $_FILES["uploadedfile"]["type"] Obtain the file type from it's extension i.e doc / pdf / jpg / gif Create your list of allowed file types and check. i.e <?php /* allowed file types */ $allowed = array('pdf','doc','gif','jpg','jpeg'); /* get uploaded file extension */ $ext = substr(strtolower(strrchr($_FILES['uploadedfile']['name'], ".")),1); if(!in_array($ext, $allowed)) { print "Filetype not allowed: ".$ext; } else { /* move uploaded file */ } ?>
-
Firstly, pass variables into functions, refrain from using global variables. Secondly, if there is only 1 company name to return you do not need to loop over a result set. Example: <?php function cname($db, $companyId) { $result = $db->query("SELECT name FROM compaines WHERE id='".$companyId."'"); $company = $db->fetch_array($result); return $company['name']; } $companyId = 1; print cname($db, $companyId); ?>