Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. Adam

    mySQL help

    As the error suggests, you're not actually 'on' any database. Are you running these queries from an administrator, or within a PHP script? If within a script you need to use mysql_select_db (or appropriate method if using a DB abstraction layer), or from within an administrator, the software should actually handle switching to the correct database, generally as you select it.
  2. As the print_r() shows, the string is stored in an index. Try: $title = $d->title[0];
  3. This can be done easily by capturing the window.onscroll event, and setting the DIVs style.top property to the document.body.scrollTop, plus a little extra so that it's not right up against the edge of the window. Whipped this up as a quick example: <script type="text/javascript"> window.onscroll = function() { setTimeout("scrollDiv()", 500); } function scrollDiv() { var el = document.getElementById('scrolling_div'); el.style.top = (parseInt(document.body.scrollTop) + 10) + 'px'; } </script> <style type="text/css"> #scrolling_div { width: 150px; height: 100px; position: absolute; top: 10px; right: 10px; border: 1px solid #999; } </style> <div id="scrolling_div">foo</div> <div style="height: 1500px;">...</div> All the properties and methods used are widely support, so you shouldn't run into any cross-browser issues. Can't guarantee IE6 - since I don't have it available at the moment - but I can't see any reason why it wouldn't. If you're using jQuery however, you can animate the movement and make it look a lot better: <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> window.onscroll = function() { setTimeout("scrollDiv()", 500); } function scrollDiv() { var top = (parseInt(document.body.scrollTop) + 10) + 'px'; $('#scrolling_div').animate({top: top}, 500); } </script> You'll probably want to play around with the delay and animation speed till you get a happy medium.
  4. Shouldn't the form submit via an AJAX post when called from the modal window?
  5. Complex systems where there's an extensive amount of queries and DB-related logic for a single process benefit largely from stored procedures. Not having to communicate back and forth between the server is a huge time/resource saver, but also creates a better separation between DB and application logic (in complex systems). For example large companies where a single transaction requires a large amount of DB logic and can touch many tables, and even multiple databases, are the kind of thing they're best suited for. They can be useful in smaller applications of course, but it's probably not worth splitting the code/logic between the web server and the database server for something so small. Not to mention, some systems/applications are based purely on the database server.
  6. Just to expand on that a bit, you could accomplish what you want by using a procedure.
  7. MySQL doesn't support anonymous blocks.
  8. Ha doesn't bother me I'm a little confused though. Were you using MySQLi previously in the past, but on a different server? The only 'conversion' needed would be to just change the way you query the database through the interface, i.e. the function/method calls. If you have PDO available on the server the conversion shouldn't be too difficult, as there's just some variation in the naming and handling.. But they're relatively similar to use, and they're both object orientated. Standard MySQL doesn't support OO though, so it would be a bit more tedious to convert to.
  9. Use a group by: (...) GROUP BY name
  10. How were they not 'fucking up' up before you even had MySQLi installed?
  11. Have you tried removing the line altogether? I can't see any need for it to be there if you're not using it anyway.
  12. Use GROUP BY on a unique column in the table.. (...) GROUP BY col_name HAVING (...)
  13. How did you install it exactly? Did you restart Apache afterwards? Just to get the terminology right by the way, MySQLi is an 'extension' of PHP.
  14. From what I can tell looking at the documentation (this is it right?), the content proper just contains the HTML you want to show. Pass the form's HTML to that and you should be able to create the form? Unless I'm misunderstanding what it is you're trying to do?
  15. That must be a custom DB package, does it have error handling at all? If not you should still be able to catch the error with mysql_error(), assuming it's MySQL and not MySQLi (which you'd just use the equivalent for). Find out the error message..
  16. Just to be clear actually, that would be added to your SQL:
  17. You can use group by column_name to prevent that. Only the first row matching column_name will be returned. For example, assume you have a table containing the following data: col1 | col2 ----------- 1 | a 1 | b 1 | c 2 | d 2 | e 2 | f Using a group by on col1 would return: col1 | col2 ----------- 1 | a 2 | d
  18. Also if you add "\w" (word-characters) to the regex, you can remove a-z A-Z 0-9 and _ .. to simplify it a little.
  19. Ah. I didn't look to much at the regex before, but you need to escape special characters to use them as literals, and since you're not using the dot to match any character (instead as a literal), you also need new line / return characters in your regex, instead of the 's' modifier. Try this: #^[a-zA-Z0-9 \.,\?_/'!£\$%&*()+=\r\n-]+$#
  20. You need to add the 's' modifier after your closing delimiter: #^[a-zA-Z0-9 .,?_/'!£$%&*()+=-]+$#s
  21. At a guess, I'd say you're not getting any rows back (or more than 1), and the so the condition below is evaluating to false: if(mysqli_num_rows($data) == 1){ In which case all you're doing is assigning $error_msg a value, not actually displaying anything. Try adding a var_dump just before to double check: var_dump(mysqli_num_rows($data));
  22. Do it like in the example insert statement, pass the IP into inet_aton().
  23. Assume you have the following table: create table ip_table ( ip_col int unsigned ); When you're inserting the IP originally you'd have a query like: insert into ip_table (ip_col) values ( inet_aton('127.0.0.1') ); Then to retrieve a specific IP, in it's normal format: select inet_ntoa(ip_col) from ip_table where inet_ntoa(ip_col) = '127.0.0.1'; Obviously '127.0.0.1' would be replaced by a PHP variable.
  24. So are you referring to the channel/image? i.e.
×
×
  • 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.