Jump to content

Muddy_Funster

Members
  • Posts

    3,372
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Muddy_Funster

  1. something along the lines of : SELECT id,user,profilelink,name,email,dateOfBirth FROM `friend_req` WHERE (SELECT (DATEDIFF(CURDATE(), dateOfBirth) / 365.25) FROM friend_req) = ((21*365.25)-30) Limit 5; Havn't tested it, but I used something simmilar about a year ago to calculate employee ages for a pension program, so should work with a little tweeking.
  2. Yeah, that is pretty much the code you will need to get the info our the database to populate the form with. Just an FYI for future refference - try and keep your php variable names different from your table fields and table names. It's much less confusing in the long run, and more secure (for people who worry about these things). Foreign keys can be set in the admin - most commonly they will be set using this at the point of creating the table its self. But anything that you can do in the admin can also be done with an SQL statement. You never actualy "NEED" a foreign key, but by the same token you never actualy "NEED" a primary key either. Obviously you try and use a primary key wherever practical (and yes, there are some occasions where it's just not - though they are few and far between), so you sould also be trying to use foreign keys under the same philosophy. The problem is foreign keys are less well known in the general public (yet another thing I am going to blame that bloody M$ Access for). Most people, will pick up on primary keys, either by using some "user friendly" database system or from skimming the first few chapters of a DBA book... anyway I digress, I was trying to get across:- don't think of it in terms of whether you "need" it or not, trying to get away with the bare minimum is not a mindset that will behove this kind of practice, think rather "will it make my database better if I use it" and you will get along much better in the long run.
  3. ohh, well in that case you just have your join statement back to front (I had to build a duplicate of your sample data into my test area to notice it though ), try this : SELECT table1.id, table1.name, table1.value, table1.anotherID, table2.otherValue, table2.otherValue2 FROM table1 LEFT JOIN table2 ON (table1.id = table2.id) You can use whatever WHERE your working with, I didn't need one obviously as the dataset was nice and small.
  4. Not nearly as much as it will slow things down trying to query against every table. MySQL is (more or less) designed to be big. There is little actual performance drop running a query against a table with 100000 records compared to running one against a table with 100 (ASSUMING the table is built and indexed properly). Merge your stores into a single table with a store_id number field. then create a refference table to link store_id to store_name. this will let you query all your goods, and at the same time let you query single stores with a user frieldy selection of name rather than number.
  5. Off the top of my head I would suggest an intermediate page, that checks the md5 from the user page, generates another hash and passes that onto your file play page using $_POST and include_once(); that way what people see in the bar isn't actualy how they access the file.
  6. so, just to clear this up : Have you got NULL in as a string value (i.e. is NULL actualy written into the field) or is it a NULL value (i.e. you have set the default value to be NULL which in turn meens that there is no value to address at all)
  7. Could you post the full page? If there is nothing in there other than the ticket counter you should be able to get away with changing your if (count($venues) == 100) { echo "<div class='error'>Due to Internet traffic, ticket counter has been disabled</div>"; to echo "<div class='error'>Due to Internet traffic, ticket counter has been disabled</div>"; die however if there are, as I suspect, other things going on, then it will need some minor surgery.
  8. For a viewer Dreamwaever is pretty nice. It will let you load the full site into it and can then trace through all the links and css. Don't know if it's any use at all for php though, I've always just used psPad for that.
  9. what do you meen you "want the price range to read the description"? you want the form on the page to display a price range dependant on what the description is? or you want to have the price range tied to the description during the query so that the result set is only descriptions within the given price range?
  10. hmm....same person or just the same class? http://www.phpfreaks.com/forums/php-coding-help/php-script-help!-325034/ lol
  11. you hav't assigned anything to $result $result = mysql_query($query,$which) or die ('Error performing database lookup -- '.mysql_error()); Now that gets you a value attached to $result, However, this isn't your actual data from your database. Next you need to call the data into an array, and as you next to never have a single row of data in a table, you will need to run through each row by using a while loop. Once you have the information into the array, you can then pull it out into a flat variable such as $kk. Look up some examples online on how to use mysql_fetch_assoc(), or better still get a book on php and mysql from amazon or somewhere, it will make a much more convenient refference.
  12. what's it not doing / doing that it shouldnt?
  13. Select boxes are html. To display / hide a text field from the OnChange function of the select box your gonna want javascript, not PHP.
  14. OR Name LIKE \' {^[[:alpha:]]+$}'.$_POST['search'].' {^[[:alpha:]]+$}\''; What is this supposed to do exactly? You would be much better off using a preg_replace on your $_POST input to strip out anything that you want there (as PaulRyan has shown), and then enter it into the query. SQL isn't neerly as good at that type of data manipulation as PHP is.
  15. My suggestion would be to create -at the least- a different table for each device every month. I am, however, a little concerned that you may be out your deapth with this if your imediate thinking was to store everything in a single table (that, and you put the comma in the wrong place for 432,000 ).
  16. What is it with people using SELECT * and single letter aliases for tables that are only 4 letters long anyway? Just to be lazy? That asside, sounds like your looking to use GROUP BY more than SELECT DISTINCT, but we're going to need some more information to be of any real help.
  17. .....jeezus! ok, before we go anywhere with this, add the error report to the update like you did the connection string and let us know what the actual error your getting for now is. mysql_query($query) or die('Error, insert query failed -- '.mysql_error());
  18. There is no "correct" way to make a login form per-say. There have been several example login forms posted on phpfreaks, each diffent and each correct for what it does. You are better off trying to find what is causing the problems in your form and then work through fixing it. It will make maintaining the finnished product much easier. If you are looking for an out the box login form, check in the code repository section of the forum. I'm sure there are quite a few in there. If you want help fixing yours post up what you get back from that echo.
  19. Every time I have come accross that message (and other simmilar ones) it has been an SQL issue (wrong table selected, case sensitive errors, etc.), not a PHP one. That your case may be different is indeed possable, I was just playing the numbers on that one. Hopefully someone else will be able to help.
  20. Your issue is that you are getting 0 rows returned from the query. This in turn points to the problem of your $username variable being either not something in the database, or wrongly populated. Either way, it's not what you expect it should be, so echo the contents of $username and $password after it tells you that there is no such user and see what you get.
  21. change this line $result=mysql_query($sql); to read $result=mysql_query($sql) or die ('ERROR in posting to database -- '.mysql_error()); and see what happens.
  22. that error has nothing to do with the mysql_num_rows function being unrecognised. That error is thrown because your SQL syntax is malformed in the following: $result = query("SELECT * FROM users WHERE username = '$username' AND '$password'"); The fact that you are using SELECT * asside, you are not checking $password against a field name in the database. Try: $result = query("SELECT username FROM users WHERE username = '$username' AND password= '$password'");
  23. You got it. Using tableName.fieldName to identify the field in the statement only tells the SQL where to find the fieldName that you are looking for. When the SQL returns the values it only uses the fieldName to identify it. As gristoi said, the use of aliases helps when trying to identify between two fields that have the same fieldName from different tables. This is perticularly usefull when echoing back results in PHP using the mysql_fetch_assoc() command. Oh, and if your new to MySQL, it's not too late to save you - STOP using SELECT *
  24. Is this, perhaps, in the wrong section? or do you actualy have an issue here?
  25. Surely the issue here is that you are instantly overwriting the selected database to db2 at the start of each page? mysql_select_db('db1',$conn_local); mysql_select_db('db2',$conn_local2); It's not something I have tried in PHP, but the logical flow seems to be showing that to be the case.
×
×
  • 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.