Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. What you would do is create a hidden <div> tag and then show it when the user puts focus on the desired input. There are some scripts out there that will enable <datalist> functionality via JS for older browser while letting browsers that support it handle it on their own. Check this HTML5 Polyfills list for a bunch of compatibility scripts. There is a section for <datalist>, just do a search on that page.
  2. All you'd need to do is be able to pass the session ID as a cookie header. I am not familiar with those tools so I do not know whether that is possible with them or not. It sounds like how an API Key/Access Token might be implemented more so than a Session ID. A session id is typically random and different each time. An API Key would be a random value generated one-time, and then used for all the requests. Yes, that is what I mean. When you call session_start() PHP will set a cookie with the current Session ID. If one hasn't already been established one will be generated for you automatically.
  3. You need to declare your class property. Private static $class;
  4. So sitting here at an autoshop waiting for my car I see a bunch of business cards for different business in the area, bot big and small. Remembering this thread I figured I would check the emails against the above. Results: 28 cards total 20 have a email on them 8 have an address that would be rejected by the above
  5. You should try and convince him how dumb such a thing is. For some people those emails are their "real company email". I've seen numerous small-businesses that use whatever@comcast.net or whatever@gmail.com as their business email. Just a few weeks ago I was out and saw guy who runs a handyman/contracting business using hisname@comcast.net for his email. Had it painted on his truck right along side his business name, phone and fax numbers.
  6. The session varaible is just the ID, no hashing or anything like that is taking place on it. The session itself has another ID that is generated by PHP when you begin the session. This ID is what you need to ensure gets passed between the client and the server on each request. Generally this is done by setting it as a cookie (which PHP does for you typically). Using that session ID you can lookup all the data associated with it. One of the data items associated with that session would be the User ID of whoever logged in. Then you can just compare that User ID to whatever User ID is sent in the client's request to make sure they match before allowing them to do anything. As mentioned though you generally don't need to be passing around the user id at all in the service request, just pull it out of the session when it is needed. So for example if you want to have the user make updates to their profile you might send a POST request to the URI http://www.example.com/profile with the new data. In the code that handles that request you would: 1) Start the session and lookup the associated user id 2) If the user ID could not be found, deny the request with an error that they have to login first 3) If the ID does exist, run your UPDATE query using the posted data and the ID from the session. That way the end user doesn't have any means of altering the user id at all since it is managed server-side the whole time.
  7. You would use the FTP Extension to handle the browsing of and copying of files to the remote server.
  8. Just tell them what IP and domain you want them to add to the hosts file. So if your site is running on IP 1.2.3.4 and you want to use the hostname my.super.site then you'd tell them to add to their hosts file: 1.2.3.4 my.super.site
  9. If all you want to do is pass-through the file without modifying it, use the readfile function. header("Content-type:...."); header('Content-Disposition: attachment; filename="....."'); header("Content-Length: ......."); readfile($url);
  10. Godaddy only allows scripts to run for a short length of time before they forcefully kill it. You'll either need to split the job up into several short-running cron jobs, or find a different provider that allows longer jobs to be run (or use a mailer service rather than DIY'ing it).
  11. You can use a GROUP BY category clause to reduce the results down to unique category ID's. Mysql will just choose an arbitrary row to pull the article_id and name fields from so there is no guarantee that you'd get 'dog' and 'cat' instead of 'horse' and 'bird' (or any combination there of). Example That is not really the right way of using GROUP BY though. Perhaps if you explain a bit better what kind of task you're trying to accomplish we could help determine the best route to take.
  12. Specify an absolute path to the xls2csv executable. The server is likely going to have a different PATH environment variable than you do in your terminal window which means it may not be finding the program.
  13. What you would end up doing with PHP is create your server socket and then use non-blocking IO + stream_select to handle all the incoming connections. You could manage quite a few connections that way in just a single thread/process. Throwing pcntl_fork into the mix may allow even more connections to be handled. https://aoeex.com/chat/phpchatd.phps is a example I made a while back that uses the principal above. It acts as a simple server that handles all the long-poll connections for a AJAX chat room. The demo chat room that uses it is at https://aoeex.com/chat/chat.html.
  14. The file appears to be ok, no non-printable chars or anything before the tags. Reupload the file to your server, make sure you're overwriting the current one and putting it in the correct place.
  15. You need to put your conditions inside parenthesis to force precedence. Right now what you have written: orgname IS NOT NULL AND needsusername='$username' OR workerusername='$username' Is evaluated as - Is orgname not null? - AND Is needsusername equal to $username? - Then include the row in the output - OR Is workerusername equal to $username - Then include the row in the output Basically so long as the row matches workerusername='$username' it will be included. Note that your above "working" query follows this same logic pattern so it doesn't really work as you expect. orgname IS NOT NULL AND (needsusername='$username' OR workerusername='$username') The parenthesis tells mysql to evaluate those two conditions first, then after that the not null condition.
  16. Open the connect.php file in a hex editor so that you can be sure that there is nothing before the opening <?php tag. If you don't have a hex editor there are some sites online you can use, such as http://en.webhex.net/. If everything looks good, re-upload your files, and double check to make sure you are uploading them to the correct place.
  17. file_get_contents does not cache, it will request the file each time it is called. You may have something else that is caching sitting between your script and the URL you're fetching though, like a proxy server or cache server.
  18. I'm assuming you're talking about using the Publish -> Blog option in word? Sure you could setup a page for it to post to and then put the info into a database. I don't really know anything about how it works, but near as I can tell just clicking through the dialog in word you'd need a page that accepts an ATOM feed and then parses it. Wordpress is in the list of pre-supported blogs, you could grab their source and see how it is handled.
  19. That block of code could be reduced to this: $operator=$_COOKIE['ID_my_site']; //Get Users Printer Location $user_print_loc_sql="SELECT printers.* FROM operators INNER JOIN printers ON operators.default_printer_location=printers.printer_location_id WHERE operator='$operator'"; $printer_query=mysql_query($user_print_loc_sql) or die(mysql_error()); while ($printer_row=mysql_fetch_array($printer_query)){ It joins the tables and selects the printer info for the default printer in a single query rather than two.
  20. There is no need to select a list of all the dates, you can do that comparison in SQL when you join the table, and as a result only select the rows of new messages (or a count if you dont need the data). SELECT the, columns, you, need FROM users INNER JOIN messages ON users.name = messages.name AND messages.datesent >= users.logoutdate WHERE users.name = $name ORDER by ASC datesent What happens when you have two different 'Joe Smith's sign up for your site? Just going to let them view each others messages? Names are not unique, even a first+last combination. Never use it as a key for linking records.
  21. Use a JOIN to link up to which ever table you need to count the values in, then use the sql function COUNT() and the GROUP BY clause to select a list of categories and their counts. You'll have to post the structure of your tables if you need help figuring out how to do the join.
  22. Set a flag variable to false, then use a foreach loop to go over each array element and check it's ['tid'] element to see if it matches. If it does, set the flag variable to true. After the loop, check if the flag variable is true or false.
  23. The most correct way to handle something like this is to use transactions. To do this with MySQL you need to be using InnoDB tables instead of MyISAM, and you should be using mysqli or PDO as your access layer. With PDO the process would go something like this: $db = new PDO('mysql:host=localhost;dbname=yourdb', 'yourusername', 'yourpassword'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); try { $db->beginTransaction(); $stmt=$db->prepare("UPDATE domaindata SET email_sent_date = DATE_FORMAT(NOW(), '%m-%d-%Y'), email_sent_userid= :by, email_sent_id = :rndid WHERE combo = :showid"); $stmt->bindValue(':by', $_SESSION['userid']); $stmt->bindValue(':rndid', $RandID); $stmt->bindValue(':showid', $show_id); $stmt->execute(); /* ... email setup stuff */ if (!$mail->Send()){ throw new RuntimeException('Email failed'); } $db->commit(); } catch (Exception $e){ $db->rollback(); } What that does is begins a database transaction and then does the update. If the update fails an exception will be thrown which causes it to skip the email code and rollback the transaction. If the email fails it will throw an exception and also cause the transaction to be rolled back. Rolling back the transaction will revert the db to how it was when the transaction started, basically undoing the UPDATE query. If for some reason you cannot use transactions, I would probably order the code to try and send the email first, and update the DB if that succeeded. A failure sending the email seems more likely to me than a failure doing the update.
  24. With proper indenting: /* Check no duplicate usernames */ $con = mysql_connect("zambiheadshop.com.mysql", "zambiheadshop_c", "Ozzie200407") or die(mysql_error()); $query = "SELECT COUNT(*) AS count FROM members WHERE username='$username'"; @mysql_select_db('zambiheadshop_c') or die( "Unable to select database"); $results = mysql_query($query) or die ("Error reading from database"); $existingUsernames = mysql_fetch_array($results); if ($existingUsernames['count'] > 0) { header('Location: usererror.php'); } else { $con = mysql_connect("zambiheadshop.com.mysql", "zambiheadshop_c", "Ozzie200407") or die(mysql_error()); $query1 = "SELECT COUNT(*) AS count FROM members WHERE email='$email'"; @mysql_select_db('zambiheadshop_c') or die( "Unable to select database"); $results1 = mysql_query($query1) or die ("Error reading from database"); $existingEmails = mysql_fetch_array($results1); if ($existingEmails['count'] > 0) { header('Location: emailerror.php'); } else { /* Write to MySQL database */ $sql="INSERT INTO members (username, hash, firstname, surname, email, address1, address2, town, county, postcode, birthday, birthmonth, birthyear, paypalemail, terms) VALUES ('$_POST[username]','$hash','$_POST[firstname]','$_POST[surname]','$_POST[email]','$_POST[address1]','$_POST[address2]','$_POST[town]','$_POST[county]','$_POST[postcode]','$_POST[birthday]','$_POST[birthmonth]','$_POST[birthyear]','$_POST[paypalemail]','$_POST[terms]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } /* Redirect visitor to the thank you page */ header('Location: thanks.php'); exit(); } As you can see, you are missing a closing brace } at the end.
  25. The code you posted, when run through a syntax check yields No syntax errors detected in - so there is nothing wrong syntax-wise with that code block. Either there is more to the file than you are showing, or you're server is doing something to modify the file before processing it and is causing a problem. Do you get the same error if you change the code around some, such as merging the PHP blocks together and putting the html at the end?: <?php if(isset($_POST['voteup'])) { $sql = "UPDATE movies SET ratings = increment + 1 WHERE id = '".$_GET['id']."'"; mysql_query($sql); } else if(isset($_POST['votedown'])) { $sql = "UPDATE movies SET ratings = increment - 1 WHERE id = '".$_GET['id']."'"; mysql_query($sql); } ?> <a href="?voteup">VOTE UP</a> | <a href="?votedown">VOTE DOWN</a> Also, as has been pointed out, ratings = increment + 1 does not make sense. ratings = ratings + 1 is probably what you want.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.