Jump to content

J.Daniels

Members
  • Posts

    143
  • Joined

  • Last visited

    Never

Everything posted by J.Daniels

  1. You can echo out $servers[$i] to see what value is being passed.
  2. There shouldn't be a need to 'reorder' the fields of a table, as relational databases are based on sets, which have no order. If you are using mysql_fetch_row(), then rows are returned in a numbered array. I can see why you might want to change the 'order' of the fields, but why not change the code instead of the database? You can use mysql_fetch_assoc(), which will return the rows as an associative array, and you can access the fields by name.
  3. flyhoney is referring to the if/else shortcut: $value = (condition) ? true : false; I copied and pasted your code and it is working on my end.
  4. The compile process is the same between 32 and 64 bit systems. If you use precompiled binaries, then you have to use a 64-bit version.
  5. It is type casting the value of $languages_id to be of type int.
  6. The argument to system needs to be in double quotes or php will not expand the variable. Also, system returns the last line of the output, so you either need to echo it, or assign it to a variable then echo it. echo system("nc -z $servers[$i] 1494");
  7. You are missing a closing quote: echo '<table>';
  8. PHP is a server side language, which means it cannot change anything after the page has loaded without a reload. With that being said, you can choose which stylesheet is used when you output the html. For example: <html> <head> <?php $css = 'zoom'; if ($css == 'zoom') { echo '<link type="text/css" rel="stylesheet" media="screen" href="zoom.css">'; } else { echo '<link type="text/css" rel="stylesheet" media="screen" href="normal.css">'; } ?> </head> <body> If you want a button to change the stylesheet, the page would reload and you would set $css to whatever you want. To change the stylesheet after the page has been loaded, you would have to use Javascript.
  9. As stated before, mysql_insert_id() only works after an INSERT. So you should do something like this: $db->query("INSERT INTO article (title, ... ) VALUES ('Title', ... )"); $lastID = mysql_last_id(); // You can also check the CMS's SQL class to see if they have a function to grab the last id $db->query("INSERT INTO article_relation (articleId, categoryID) VALUES ($lastID, $catID)");
  10. Ken is correct because if it is of type char it would order it as: 1 10 2 3 4 5 6 7 8 9 The field should be of type int, but if it isn't you can try to cast type the field SELECT * FROM category ORDER BY CAST(cat_id as SIGNED);
  11. You can directly pass variables between Javascript and PHP. Javascript is client side and PHP is server side. There are two solutions to work around the problem. 1. Use Javascript to redirect the page and add the variable to the url (http://example.com?passed=variables) 2. Use Javascript to change the content of the td
  12. Try using GROUP BY: SELECT units.bid, units.status, buildings.*, (((acos(sin((".$latitude."*pi()/180)) * sin((buildings.`lat`*pi()/180))+cos((".$latitude."*pi()/180)) * cos((buildings.`lat`*pi()/180)) * cos(((".$longitude."-buildings.`lng`)*pi()/180))))*180/pi())*60*1.1515) as distance FROM units, buildings WHERE units.bid = buildings.bid AND status = 0 GROUP BY units.bid ORDER BY distance ASC LIMIT 0, 5
  13. The passthru() function will execute a command and return the full output to an array.
  14. $_SERVER['QUERY_STRING'] contains the portion of the url after the question mark $_SERVER['REQUEST_URI'] contains the full url
  15. URLs can be checked with a regex expression. Google 'php regex url verification' for code examples.
  16. $_SERVER['REQUEST_URI'] will show the full uri
  17. It is probably becase GoDaddy has register_long_arrays set to off. $HTTP_POST_VARS is depreciated. Change all occurrences of $HTTP_POST_VARS to $_POST
  18. I'm not sure why the order is the way it is, but relational databases are based on sets, which do not have order. When you select the data from the database, you specify the order: SELECT * FROM category ORDER BY cat_id
  19. I understand now. I haven't tested this, but you'll want to look at the HAVING clause: select distinct(u.userid), u.*, sum(e.amount) as amnt from `users` as u left join `earnings` as e on u.userid = e.referral where u.referrer = '$userid' and amnt > 0 group by u.userid HAVING amnt > 0 DESC LIMIT $from, $max_results
  20. It doesn't work in the query because the query hasn't happened yet. Well, I thought mysql_insert_id() fetched the last generated ID, in which case it would have already happened by the time I get round to inserting into the parent board field. Sorry.. I meant that it wouldn't work in this query: mysql_query("INSERT INTO `table` (`ID`, `SecondID`) VALUES (NULL, '".mysql_last_insert()."')");
  21. I did a little searching and it seems you want to use the CASE statement: SELECT *, (CASE STRCMP(title,'word') WHEN 0 THEN 0 ELSE 1 END) as result FROM table ORDER BY result
  22. It doesn't work in the query because the query hasn't happened yet.
  23. STRCMP() will always return -1, 0, or 1 and it looks like you are comparing the value of title to 'word'. STRCMP() is normally used for conditional statements. If you want to order your result set by title, just use title in the ORDER BY clause. SELECT * FROM table ORDER BY title
  24. $result_row = $result->fetchRow(DB_FETCHMODE_ASSOC); for ($i = 1; $i <= 12; $i++) { if ($result_row['tddate'.$i] != '') { echo $result_row['tddate'.$i]; echo $result_row['tdlocation'.$i]; echo $result_row['tdvenue'.$i]; } } This only checks if there is a value in the tddate column. There are better ways to store the data in the database. For example, create a tour table with id, date, location, and venue as the columns. You would link the tour with the user in a second table with the userId as one column and the tourId as the other. If you want to limit the number of tours a user can create, do the checks in your php script.
×
×
  • 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.