Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. Assuming you were replying to my post, I was just informing him, that I would learn java first, since it is a full language. In my opinion it is better to learn that first and it will hopefully help make them more efficient and a better programmer when they start learning PHP. I love Java, it is a blast to code in cause you can do a ton of stuff with it. PHP is a blast too cause it is not a "strict"/ full blown language, where most of what you need is done for you. But as CV said, you cannot really compare the two due to the fact that Java is a stand-alone and full blown language, where as php is more of a templating language. I am glad I started out coding in Java/C++ first before I started PHP, it made working in PHP a ton easier and helped with bad habits that most of the PHP books teach you. Such as defining variables before you use them, etc. That is just my 2cents though.
  2. Please use [ code] [ /code] tags instead of the quotes (remove the initial space of course) Since your code was no where near complete I made a few changes with comments: <?php $con = mysql_connect("*******","*********","******") or die('Could not connect: ' . mysql_error()); /* No need for this if, it can be done as shown above. if (!$con) { die('Could not connect: ' . mysql_error()); } */ mysql_select_db("metropo_artrequest", $con); $result = mysql_query("SELECT * FROM artrequests WHERE invis = " . false ); // changed this so you do not need the if in the loop // added form code here, there is no need for multiple forms. echo "<form method=post action=dbeditor.php> <table border='1'> <tr> <th>Design Number</th> <th>Color</th> <th>Quantity</th> <th>Due Date</th> <th>Description</th> <th>First Name</th> <th>Email</th> <th>phone</th> <th>Greek</th> <th>School</th> <th>State</th> <th>Timestamp</th> <th>Post to Filemaker</th> </tr>"; while($row = mysql_fetch_assoc($result)) { // changed to assoc cause that is what you are pulling out // where is $invis being set at? also a single = generally returns true cause it is an assignment operator... if ($invis = "false") { // if is no longer needed, see the query above. if ($row['invis'] == false) { echo "<tr>"; echo "<td>" . $row['designnum'] . "</td>"; echo "<td>" . $row['color'] . "</td>"; echo "<td>" . $row['quant'] . "</td>"; echo "<td>" . $row['duedate'] . "</td>"; echo "<td>" . $row['desc'] . "</td>"; echo "<td>" . $row['fname'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['phone'] . "</td>"; echo "<td>" . $row['greek'] . "</td>"; echo "<td>" . $row['school'] . "</td>"; echo "<td>" . $row['state'] . "</td>"; echo "<td>" . $row['timestamp'] . "</td>"; // this will be named the same each time the loop goes through... echo "<td><input name=invis2 id=invis2 type=text size=15 value=$invis></td>"; // Let's make it a checkbox array instead echo "<td><input name=\"idval[]\" id=\"invis2\" type=\"checkbox\" value={$row['id']}></td>"; // this assumes that you do have a unique identifier column called "id" echo "</tr>"; // } if is no longer needed since the query is modified to only pull out the data where invis = false // exit; Why is this exit here? this kills the script after 1 loop and is not needed. } echo "</table> <input name=Submit type=submit value=POSTED></form>"; // the ending to the form so it can be submitted. // this is not needed, has been depreciated. mysql_close($con); ?> Read through those comments to see why I changed what I did. Example dbeditor.php <?php $con = mysql_connect("*******","*********","******") or die('Could not connect: ' . mysql_error()); mysql_select_db("metropo_artrequest", $con); // test if the form was submitted if (isset($_POST['Submit'])) { // it was, see if any checkboxes were checked if (isset($_POST['idval']) && is_array($_POST['idval'])) { // there was, let's implode the array to format it for SQL insertion using the "IN" keyword. $ids = implode(", ", $ids); mysql_query("UPDATE artrequests SET `invis` = true WHERE id IN({$ids})") or die(mysql_error()); echo mysql_rows_affected() . ' rows have been made invisible!'; } } ?> Since you did not post the dbeditor, I made an example one of how you would update those values once submit was clicked. The code I created does some assuming, such as artrequests has a primary or unique key of "id" and that invis is the column name that you are checking. EDIT: Since you are actively trying to learn, reply here if any of the above is confusing or you would like clarification. I would be happy to provide it. EDIT EDIT: Fixed the sql query, I over looked that part.
  3. Post the full html page where the form is. Hard to say without seeing that, if you want to also, post the js file too (or attach it). That will help.
  4. I will in the future, going to create a site using Wordpress MU and try and make some money off of ads. As far as hacking it, I probably will not look into that.
  5. $query = "SELECT `itemid`, `huntid`, SUM(qty) as sum_qty FROM hrhuntcart GROUP BY `item_id`, `huntid`"; Should do it.
  6. I do not know word press at all. Here is an example of how you could setup the function: function the_title($do="") { if ($do != "") { // return your custom title }else { // return the original title } } That way just calling the_title() defaults it to the original, but calling the_title(1) would show your code.
  7. Why not create a similar function that does not use "the_title" or pass a parameter into "the_title" telling it which operation to execute?
  8. PHP will only go down hill if something better comes out. It has been going strong and if you are good at it, there are some decent paying jobs for it. Java is a big industry due to it can be on multiple platforms etc. Your best bet is to learn both. Once you learned one language, learning another is not hard at all. Just learning the quirks. In my opinion java would be better to learn than PHP, since it "can" teach you better OOP habits. However, PHP will probably easier to learn. The future is hard to predict, but at least 60% (if not higher) of systems online right now run off of PHP, doubtful it will just "disappear".
  9. That sucks, hope for the best, that this time around it works and it is not a month out. That just sucks.
  10. Looks sound to me, what are you putting in that text field? Just "My Office" for testing reasons? Maybe the DB Field is not long enough...but that should have just chopped the string down to that size. Also, is register_globals turned off? Can you post the full code that is being ran, just to look and make sure that is not doing anything funky?
  11. Dude that is bull. I would tell them I want it done while I sit there and watch, or give me the refund. 1 month to repair is bunch a crap, especially when they "repaired" it with bad hardware. That is their fault. Ultimatum, repair it within 1 day, since it was their fault for not properly testing the system, or give you the refund so you can go and spend your money on something that works. Unless of course you really liked the PC and do not care for the refund, just a fixed computer.
  12. You should have a timestamp on the thread anyways, but that is not how it goes. I have never coded a forum, but I would image that they have a third table "thread_viewed" which simply has the viewedid, threadid, userid when the user views that thread the entry is created in that table. If there is an entry, do not show it as new, if not show it as being new.
  13. Well at least you tried debugging it yourself, we rarely see that here lol. I am not sure what could be happening...So the query echos out with the location being shown etc? Let me ask this, register_globals is not turned on is it? I doubt it would be, but if it is maybe that is causing some issues? Post the form code for us to look at, maybe something is going askew in there?
  14. When you post an error message, post it and also post the line that is causing the problems, then post your code under that. Without it, no one wants to go through and count your lines to find which one is the problematic one.
  15. Sounds like a weird error. So if you echo $location after defining it from the $_POST['location'] it works just fine. Is that how the code is setup in those 3 lines (there is no other processing between them?) Also, you are not really escaping input, which could cause a problem, but that would throw a mysql error, so I doubt it is that. Something to be aware of though. Have you echo'd out the $session_id also after assigning $location to the post variable to make sure that, somehow, it is not being wiped out?
  16. It is a pretty straight forward error, that method, execute, does not exist in the "MDB2_ERROR" class, are you sure that is the name of class and it should not just be "MDB2" ??? For more information read up on the Manual for it at http://pear.php.net/manual/en/package.database.mdb2.php
  17. If you use file to retrieve/display the file you can do an rsort on the array and it will reverse it so the top is displayed first. No need to rewrite the whole thing when you can simply re-organize it quick and easy. Assuming that the data is broken up by a line break ("\n"), that would work. If that is not an option, you will have to re-write the whole file each time a new entry is entered, which increases processing time quite a bit more and is more prone for collision errors due to the file having to be open for a bit longer.
  18. We need to see the code, also a better explanation would help. Are you trying to instantiate an old session? If so, the reason that would not work is cause session files are hosted on the server, hence remote and local would be different. Without code your problem will go unsolved.
  19. <?php $file = file_get_contents('test.txt'); $file = explode("-----------------------------", $file); $file = explode("\n", $file[1]); foreach ($file as $line) { echo $line . "<br />"; } ?> Should do the trick, explode file_get_contents and foreach
  20. for($i = 1; $i < $_POST['numberinparty']; ++$i){ Try that for the for statement, and see what happens.
  21. Is the issue just trying to remove the double quotes? str_replace <?php // reads a csv file and returns an two-dimensional array of lines/fields function select_csv($file,$delimiter,$field,$query) { $data_array = file($file); for ( $i = 0; $i < count($data_array); $i++ ) { $parts_array[$i] = explode($delimiter,$data_array[$i]); if(trim(strtolower($parts_array[$i][$field])) == trim(strtolower($query))) { $result_array[] = $parts_array[$i]; } } return $result_array; } // this willl display all records where the value // of the selected field matches the query $data = select_csv("datafeed/vehicles.txt",'\t','0',$_GET['vehicleID']); // 0 means first column (like ID or Key) for ( $i = 0; $i < count($data); $i++ ) { $vehicleID = $data[$i][0]; $Title = $data[$i][1]; $Odometer = $data[$i][2]; $Colour = $data[$i][3]; $Transmission = $data[$i][4]; $Registration = $data[$i][5]; $Year = $data[$i][6]; $Price_AUD = $data[$i][7]; $VIN = $data[$i][8]; $Contact_No = $data[$i][9]; $Contact_Email = $data[$i][10]; $Options = str_replace('"', "", $data[$i][11]); $Notes = $data[$i][12]; $Images = $data[$i][13]; $Extra_Images = $data[$i][14]; } ?> Title: <?php echo $Title;?><br /> Image: <?php echo $Images;?><br /> Xtra Images: <?php echo $Extra_Images;?><br /><br /> Stock: <?php echo $vehicleID;?> <br /> Odometer: <?php echo $Odometer;?> <br /> Colour: <?php echo $Colour;?> <br /> Transmission: <?php echo $Transmission;?> <br /> Registration: <?php echo $Registration;?> <br /> Year: <?php echo $Year;?> <br /> Price (AUD): <?php echo $Price_AUD;?> <br /> VIN: <?php echo $VIN;?> <br /> Contact No: <?php echo $Contact_No;?> <br /> Contact Email: <?php echo $Contact_Email;?><br /><br /> Options:<br /> <?php echo $Options;?><br /><br /> Notes:<br /> <?php echo $Notes;?><br /><br /> If that is not the issue, please state what you want a bit more clearly.
  22. You are only placing $flash in half the picture and you are not echoing it out. <param name="movie" value="<?php echo $flash;?>"> <param name=quality value=high> <embed src="<?php echo $flash;?>" quality=high Try that and see what happens.
  23. Right, it is suppose to return the filename, are you sure that the f in February on your file name is caps? If on a UNIX server, that will matter. If it is not caps on the server, use strtolower to make it all small case. Also make sure that you direct to the path where that swf is actually located. If it is located in /flashmonths/ and script is in / you need to add that portion to it as well.
  24. date is what you want to look into along with switch or simple an if/elseif/else EDIT: Just noticed that the .swf is associated with the month name. If this is the case date should be all you need. <?php $month = date('F'); $flash = $month . ".swf"; ?>
  25. So it works on your local server, which is PHP 5, but no on production which is PHP4, by chance is there a timezone difference? 1 hour has the flaw of timezones, say your server is one hour ahead and the cookie is set on your local machine, it has already expired. I am not sure if this is 100% true, I have heard issues about that. Try setting the cookie for 24 hours and see what happens.
×
×
  • 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.