Jump to content

homchz

Members
  • Posts

    93
  • Joined

  • Last visited

    Never

Everything posted by homchz

  1. This one is wierd. My script is running and updating my db, but I am getting an error afterward, and an unusual <br/> tag??? The funtion inside of the class jobs [code] function pay_cron()     {         $sql = mysql_query("SELECT uid, gold, salary FROM p_users WHERE occupation != '0'")or die(mysql_error());         while($results = mysql_fetch_object($sql))         {             $uid[]    = $results->uid;             $gold[]   = $results->gold;             $salary[] = $results->salary;                          $num      = count($uid);                                      for($i=0; $i<$num; $i++)             {                 $pay = ($gold[$i]+$salary[$i]);                                  $sql = mysql_query("UPDATE p_users SET gold = '$pay' WHERE uid = '$uid[$i]'")or die(mysql_error());                 $update = mysql_query($sql);             }         }     } [/code] How I am calling the funtion for testing: [code] <?php include('classes/class_jobs.php'); $daily_pay = new jobs; $daily_pay->pay_cron(); ?> [/code] Then I am getting this warning "after" the script excutes. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/flightfe/public_html/new/projects/pirate/source/classes/class_jobs.php on line 127 [/quote] Line 126 & 127: [code] 126: $sql = mysql_query("SELECT uid, gold, salary FROM p_users WHERE occupation != '0'")or die(mysql_error()); 127: while($results = mysql_fetch_object($sql)) [/code] any thoughts?? Edit: never mind This always happens, as soon as I see the reveiw the code when i post it. I see my issue. Thanks anyway Josh
  2. I have both but use DW as a default becasue it is what I am used too. And Zend Studio is not really a Design tool, so if you design as well as program it can make for more work. The program you use (IMO) does not help the individual that much. Actually, you would probably learn more if you just used a text editor as it would not guide you and you would learn more though the research. Josh
  3. [!--quoteo(post=382307:date=Jun 10 2006, 03:26 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 10 2006, 03:26 PM) [snapback]382307[/snapback][/div][div class=\'quotemain\'][!--quotec--] [b]homchz[/b] you don't need that switch statement. instead of this: [code] if((isset($_GET['page'])) && in_array($_GET['page'],$allowable_page)) {     $page = $_GET['page'];     switch($page)     {         case "register":         include 'pages/register.php';         break;         case "login":         include 'pages/login.php';         break;         case "welcome":         include 'pages/welcome.php';         break;         case "validate":         include 'pages/validate.php';         break;         case "profile":         include 'pages/profile.php';         break;     } } [/code] do this: [code] if((isset($_GET['page'])) && in_array($_GET['page'],$allowable_page)) {     $page = $_GET['page'];      include ("pages/".$page.".php"); } [/code] [/quote] Thanks for that
  4. Here is where I get a little foggy. I want to run a query every day at a certain time. Is ths a Cron Job? I could take the times a user logs in compare it to his last log in time, and do the math from there, but it would be easier to just have a script run a a certian time every day in case a user is logged on at that specific time. Thanks for any info, Josh
  5. Thanks for this thread. It opened my eyes to a few things. I use switches to obtain pages, and always wondered if there were vunerabilities, I have never had issue, so never looked to hard. However I have modified my switch to this [code] <?php $allowable_page = array("register", "login", "welcome", "validate", "profile"); if((isset($_GET['page'])) && in_array($_GET['page'],$allowable_page)) {     $page = $_GET['page'];     switch($page)     {         case "register":         include 'pages/register.php';         break;         case "login":         include 'pages/login.php';         break;         case "welcome":         include 'pages/welcome.php';         break;         case "validate":         include 'pages/validate.php';         break;         case "profile":         include 'pages/profile.php';         break;     } } else if (!isset($_GET['page'])) {     include 'pages/p_index.php'; } else {     print "It appears you are trying to do something you should not be doing. Shame on you!"; } ?> [/code] I had an issue with the default load page, untill I added the elseif !isset condition. Thanks again Josh
  6. I would start buy reading through this. [a href=\"http://www.phpfreaks.com/tutorials/83/0.php\" target=\"_blank\"]http://www.phpfreaks.com/tutorials/83/0.php[/a]
  7. Please do not keep the moving text, it is not friendly on the eyes
  8. [!--quoteo(post=380466:date=Jun 5 2006, 11:02 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 5 2006, 11:02 PM) [snapback]380466[/snapback][/div][div class=\'quotemain\'][!--quotec--] I'll advise you that it's probably not going to work as expected. The variable in the array will be extended but it will have an empty value. [/quote] Yes I tried both methods before posting here and actually recieved errors. I got around this by passing a session variable and not URL variable. Thanks for the advice though, Josh
  9. Using a session variable or passing variable though the URL??
  10. Tried that too but if I use double quotes in the array I get an" Unexpected '"' error on that line.
  11. nope the format is correct. I just thought it would pick up the variable.
  12. [code] class navigation {     var $u_links = array(                     'Home'    => 'http://www.domain.com',                     'Profile' => '?page=profile&uid=$u_id',                     'Search'  => '?page=search');     function navigation()     {               }          function get_nav($u_id)     {                 foreach($this->u_links as $title => $url)         {             print "<a href=\"$url\">$title</a><br/>";         }     } } [/code] The profile links does not recognize $u_id it only prints the literal $u_id. Is this not possible??
  13. [!--quoteo(post=380034:date=Jun 4 2006, 05:31 PM:name=joecooper)--][div class=\'quotetop\']QUOTE(joecooper @ Jun 4 2006, 05:31 PM) [snapback]380034[/snapback][/div][div class=\'quotemain\'][!--quotec--] how can i do it WITH output to the browser before that statement? [/quote] You can always call it on a php script away from the visual page. This way there will be no output sent and it will redirect where ever you have to go.
  14. what is it not doing, how large is the file, If it works on your local machine but not on your live server, you may need to talk to your host. Most shared hosts to not allow larger than 2MB uploads on there systems to prevent lag. So it might not be a code issue. Just a thought
  15. What exactly do you want to the Complete to do? Make ti so it can not be edited anymore??
  16. Nevermind: Bad advice at second glance.
  17. Do you have any of the code behind what's allready there?
  18. is anything being inserted? or just not the $linkcode variable??
  19. I am a big fan of Navicat for mySQL managmant [a href=\"http://www.navicat.com\" target=\"_blank\"]http://www.navicat.com[/a]
  20. i use session to pass error messages back to the login or register page so basically I do this [code] if($_SESSION['send'] == "no") {     print $_SESSION['error'];     require_once('templates/login_form.php');     unset($_SESSION['send']); } else {     require_once('templates/login_form.php'); } ?> [/code] That way if there is no $_SESSION['send'] to say what to do with the form I load my form, however if my script sees an error I give a variable $send = "no"; then an error message variable $msg .= "There has been an error"; Once all the messages are gathered I set my session variables $_SESSION['send'] = $send; $_SESSION['error'] = $msg; This then gets passed back to the form page explains the error and gives them a new chance. The unset($_SESSION['send']) is so after it displays the error, my script knows to look for a new variable on the next load.
  21. [!--quoteo(post=378534:date=May 30 2006, 06:57 PM:name=Gerbilkit)--][div class=\'quotetop\']QUOTE(Gerbilkit @ May 30 2006, 06:57 PM) [snapback]378534[/snapback][/div][div class=\'quotemain\'][!--quotec--] But I though letting users use HTML was dangerous. [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] [/quote] It can be but you should be able to limit what they can and cannot use.
  22. Totally misread that question :lol: I use both and determine where i need them. If it is a known item. I use words. If it is unknown and could be many I use numbers. My example [code]http://localhost/JoshuaJones/blog/index.php?page=comment&action=add&tid=288[/code] page=comment: I know there are only certian named pages. action=add: You can either add or read on the comment page tid=28: The user chose the topic, and I can never know which they want to I use numbers here to make the rest of my realtions easier.
  23. If you create a db table with a text or blob, then use the nl2br() function it will insert line breaks for every return, and if you use regular html codes like <b> </b> they will work instead of needing bbcode.
  24. I am building my own blog at this point too, and it is a long process. Sure you can build one fast, with just a few queries and forms, but the key is to find all the options you want then code them in. My suggestion would be to use a Wordpress or other blog to find out what you want then, create your plan. I am three weeks into mine and only about 10% done. Granted I only get to code on the evenings. This is a big undertaking for someone with limited knowledge, but I will give you some info. Database tables I have so far are Topics Posts Comments Categories Users When i want a full post I grab the Topic (Header) from the Topic Table joined to the Post table where I get the body of the post. Then it searches for any comments, and displays them appropriatley. I am archiving by category and date to start with, but will allow multiple topics for one Post so it need to beable to relate the Topic to many categories. I would not allow anyone to upload anything other than text, giving the public too much power when they do not need it is not a good idea, and if you have limited skills to code PHP, you will not be successful in fending off problems. I hope this helped some, good luck, Josh
×
×
  • 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.