Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. Possibly, if you are using multiple connections, I would highly suggest using $connection in the mysql_query as the second parameter. <?php function fetch($query) { global $connection; return mysql_fetch_array(mysql_query($query, $connection)); }?> Also I just noticed that you had the fetch_array in the wrong spot, and also note that without the while loop this will only ever return the first array value. function fetch($query) { global $connection; $result = mysql_query($query, $connection); while ($row = mysql_fetch_array($result)) { $return[] = $row; } return $return; } That will return the multi-dimm array with the results.
  2. Look at the file you are including and see if you are resetting the mysql_connection in it, or if it is being reset. That is what seems to be happening imo.
  3. Hes not doing a file upload. He is just trying to query from his database....
  4. Does the query work outside of the "fetch" function you created? Before you use the "fetch" are you getting a good connection to the database. Honestly if the query works outside than you should try passing the dblink or making it global to the function and using that. But if the mysql_query does not work outside of the function the issue lies within your database username/password privileges.
  5. Read the error. You need to make sure you have permissions setup for the user kabooc not using a password on your mysql database. It is not the function at all.
  6. money_format is the key if you are on a linux box. Of not view the comments for a user-created money_format function.
  7. Should not matter browser wise. Not sure why it is, but the PHP does not know or care about the browser. As far as why your code does not work. foreach ($_POST as $field => $value) { echo "$field -> $value<br>"; } $query= "select * from title where isbn like '$value'"; Should always display the last $value, since the $query is not in the loop. That just makes no sense. This would be better. $isbn = isset($_POST['isbn'])?$_POST['isbn']:''; $query= "select * from title where isbn like '$isbn'"; Should get correct results each time.
  8. You want to use modulus. $i=0; while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { $class = ($i%2==0)?'row1':'row2'; print'<tr class=' . $class . '>'; print'<td valign=top>Admin 1 (site admin)</td>'; print'<td valign=top>Forum Name </td>'; print'<td valign=top><ul class=characters><li>Character Name</li>'; print'</ul></td>'; print'</tr>'; print'<tr class=' . $class . '>'; print'<td valign=top>User 1</td>'; print'<td valign=top>Forum Name </td>'; print'<td valign=top><ul class=characters><li>Character Name</li>'; print'</ul></td>'; print'</tr>'; print'</table><br />'; print'<h2 class=backstage><form method=POST><input type=hidden name=action value=mainmenu><input type=submit value="Return to Main Menu" class=button200></form></h2>'; $i++; } I am unsure why you displaying a table each loop but that is the idea behind it.
  9. It depends on how you want to "customize it" In a production enviroment it is not good to display real errors to users. In a case like that I would create my own function called "errorReport" or something similiar. This would email the admin the error and then display a friendly message like this: function errorReport($msg, $mysql=false) { if ($mysql) { $msg .= " MySQL Error: " . mysql_error(); } mail(ADMIN_EMAIL, "Error", $msg, HEADERS); // note ADMIN_EMAIL and HEADERS are constants that need to be defined. die("An error has occurred, the admin has been emailed. We apologize for this issue."); } That way you know about the error and the user is displayed a nice message letting them know about the error. That is how I handle it (well in a similiar fashion just more robust).
  10. Well yea it will not work. You are mixing JS and PHP. They are two different languages JS has to be done on the client side. So in order for this to work you will have to setup a page that loads before anything else is loaded and set the locale probably as a cookie using javascript. Then take it to the original page and access the locale from the cookie.
  11. That is a CGI question...probably best posted at a CGI Forum, cause CGI can be written in a couple different languages (if I remember right). I know it can be written in Perl and I think C++ (not sure on the C++). But yea, it depends on what language it was written in etc. You can google just as well as I can, honestly. Search "Redirect with CGI and Request Variables"
  12. "and is not working" Very vague. How is it not working? for($i=0; $i< count($hotelFK); $i++){ $query = "SELECT * FROM hotels WHERE hotel_ID = $hotelFK[$i]"; } This makes no sense. You overwrite the query each time so it will only pull the last query. Try replacing it with: $hotelIds = implode(", ", $hotelFK); $query = "SELECT * FROM hotels WHERE hotel_ID IN(" . $hotelIds . ")"; Should yield the proper results.
  13. Add this to the top line: ini_set("display_errors", 1); And see if there are any errors displaying. Usually the white screen means errors but they are not displayed.
  14. It is an assignment operator. It is not used with all arrays in a sense. An array as such: <?php $array = array("test", "test2", "test3"); print_r($array); Will default that 0 => "test", 1 => "test2" and 2 => "test3" It is used with all arrays, just sometimes you do not see it. The reason you would specify it in an array would be to assign a known key to a value so you can reference it later. So that is the answer, it is used when a specific key is needed, a prime example is a database, they key would be the column and the value is the insert value IE: <?php $array = array("col1" => "value1", "col2" => value2"); foreach ($array as $colName => $value) { $cols[] = $colName; $vals[] = $values; } $cols = implode("`, `", $cols); $vals = implode("', '", $vals); $query = "INSERT INTO table_name (" . $cols . ") VALUES (". $vals. ")"; ?> etc.
  15. Eh no worries. Better to have 5 different choices than just one. If you are looking for SEO Friendly I would recommend my idea and even replace the & with and. If not MadTechie way works great and is probably easier to implement!
  16. replace the spaces with _'s and use str_replace to go back and forth. Simple as that.
  17. <?php function stars($num, $rating) { for ($i=0; $i<$num;$i++) { $ratingstar.="<img src='http://www.8baller.co.uk/star.png'>"; } $ratingstar .= "<font size='1'>($rating)</font>"; if ($num == 0) { $ratingstar="<font size='1'>No Rating Yet <a href='#' title='Teams need at least 3 members to gain a rating'><img src='http://8baller.co.uk/forum/images/toplinks/help.gif' border='0'></a></font>"; } return $ratingstar; } ?> Should do what you want.
  18. Create a new mysql table called "approval" or something similiar. Anytime a new function is requested you put this into the approval table. From here you display on a page the approval table which shows the new functions that need approved. Here you do have that column of approved with a 1 or 0. If you choose to approve the item then you copy that function right then and there to the "functions" table or the current table. Anything in that table is allowed to be used. Then you set the approved = 1 and go on. If you choose to deny the action, set the approved to -1. This is so you can choose to pull it up at a later date if you want to. Or just delete if you do not approve. Hope that helps.
  19. You are on the track. Do it mysql with my sql by adding a column like active or approved. If this is false then do not display/use the program. If it is approved allow the program to be used. Not really complicated if you ask me, you just need to add a new form for the approval process.
  20. I think his title is mis leading. I think he wants to be able to put in multiple rows/values and dynamically create an update statement. Really it is not a multi-query as much as just a normal update statement created by values passed to a function.
  21. implodeexplode <?php $col = "category,category_name"; $val = "10,mycatname"; $cols = explode($col, ","); $vals = explode($val, ","); $cnt = count($cols); for ($i=0;$i<$cnt;$i++) { $updateSQL .= " " . $cols[$i] . " = " . $cols[$i] . ", "; } $updateSQL = substr($updateSQL, 0, -2); // not sure on this // etc etc ?> But if you ask me, due to that your values may include a comma I would pass each one as an array IE: updatedb("mytable", array("catageory", "category_name"), array("10", "MyCatName"), ....etc That would make it easier and allow you to pass just about anything into it and parse it without a problem.
  22. Where is $id, $groupname, $userid being populated at? I do not see that. The code you have is assuming that register_globals is on. You should access it by $_POST['id'], $_POST['groupname'] etc..
  23. It will just finish the updating when the next person hits the page/script. This is the downside of not using CRON.
  24. file Will put it into an array then just $file = file('http://thesite.com'); echo $file[276]; Should echo that line as long as it is always on line 277.
  25. http://www.google.com/search?hl=en&q=php+programming+dreamweaver&btnG=Google+Search&aq=f&oq=php+programming+dreamweave PHP programming is the same no matter what medium you use to code it in. I would start by just learning how to program in PHP. Googling that will get you some good tutorials.
×
×
  • 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.