Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. Your query is failing, de-bug it. <?php $sql=mysql_query("SELECT * FROM student WHERE StudentID=$passstudent_id") or trigger_error(mysql_error());
  2. 1. you never called the function repeated(). 2. you are using the depreciated function "ereg()". preg_replace('~\s{2,}~',' ',$str);
  3. The problem is NOT the DEFINE (CONSTANT), it is the Name of it. FINAL was introduced in PHP5 to keep a child classes from overriding a method. Explained here.
  4. Date Time formats accepted by strtotime() function (or most any PHP functions requiring it)
  5. In short, to stick it into a text file you would need to: <?php $arr[] = "\n"; //start the data off with a new line. foreach($_POST as $key => $value) { //cycle through the post array, and assign the keys and values. $arr[] = $key . '=' . $value; //making the keys and values into a string, assigning them to an array. } $arr[] = '-----------------------------------------------'; //line of separation at the end of current data. $file = 'testing.txt'; //file name you wish to save to. file_put_contents($file,implode("\n",$arr),FILE_APPEND); //append the data (after joining the data with new lines) to the end of the file. //Now let's show our data. echo '<pre>' . file_get_contents($file) . '</pre>'; ?>
  6. There are many ways to do this, one of them being. <?php $str = 'POGLEDAJTE KAKO JE MEZENGA DAO JEDAN OD NAJATRAKTIVNIJIH GOLOVA NA MARAKANI /VIDEO/'; //string to match $patt = '~[a-zA-Z]{3,}~'; //matching pattern; preg_match_all($patt,$str,$match); //preg match ALL, (preg match will only return one word). echo implode(' ',$match[0]); //stick the pieces back together on a space. ?>
  7. Go here, and read about "ignoring normalization" the whole article is great, but that is the part to pay particular attention to. Then make sure to watch all 9 lessions. Then familiarize yourself with MySQL's JOIN syntax. Perhaps then you may wish for a lesson in using it, or you could ask for some help here.
  8. The only db class that I know of that uses a "execute" method, returns "mysql_affected_rows()". This method is suppose to be used for "INSERT, UPDATES, DELETES" according to the documentation in the class. There is also a "query" method, that returns a resource, of which the method "fetchNextObject()" will return (ironically) a data object. DB class Although, the more powerful PDO should be used instead of this class.
  9. MySQL is a relational database. So you shouldn't be copy`in anything to another table. Just send over the unique id for the row you want to "copy". If the same data resides in multiple tables in your application, you will run into bottle necks in the future. Just a helpful note.
  10. Try this: <?php $sql = 'SELECT `car_year`, `car_name`, COUNT(*) as `total` FROM `company_inventory` WHERE owner_name = \''.$userdata['user_name'].'\' AND warehouse_id = \''.$_GET['id'].'\' GROUP BY `car_name`, `car_year` ORDER BY `car_name` ASC'; $result = mysql_query($sql) or trigger_error($sql . ' has an error<br />' . mysql_error()); if(mysql_num_rows($result) > 0) { while($row = mysql_fetch_assoc($result)) { echo $row['car_name'] . ' | ' . $row['total'] . '<br />'; } } else { echo 'There are no cars selected!'; } ?> AS has already been stated, you need some santitation, and validation on any data coming from the client (browser).
  11. $liked_results = mysql_query($liked) or trigger_error(mysql_error()); Do NOT use mysqli_error(), as you cannot mix mysql and mysqli.
  12. Paging does NOT affect ordering. Off the cuff. Example ONLY, UN-TESTED <?php //your code if (trim($_REQUEST["DBid"]) <> "" or $_REQUEST["DBid"] > 0) $SQL = $SQL . " and id > " . trim($_REQUEST["DBid"]) ; //remove this line -> $SQL = $SQL . " LIMIT 1"; //order by naslov //added code $pageResult = mysql_query(str_replace('*','COUNT(*)',$SQL)); //change query and select count of rows from database. $count = mysql_result($pageResult,0); //get the row count from the resource. $currentPage = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; //if the GET array has a page index, get it, otherwise we are on page 1. $currentPage = ($currentPage > $count) ? $count : $currentPage; //if the requested page is greater than the total pages, return it to the last page. $currentPage = ($currentPage < 1) ? 1 : $currentPage; //if the requested page is less than 1, reset it to 1. $limit = ' LIMIT ' . ($currentPage - 1) * 1 . ',' . 1; //Limit is the current page minus 1 multiplied by the number per page (1), returning the number per page rows (1). $navigation = (($currentPage > 1) ? '<a href="?page=' . ($currentPage - 1) . '">Previous</a> ' : NULL) . '|' . (($currentPage < $count) ? ' <a href="?page=' . ($currentPage + 1) . '">Next</a>' : NULL); //variable $navigation now contains your Previous and Next links, you can add them where you wish. $SQL .= $limit; //add the limit to the SQL. //back to your code $rs_data = mysql_query($SQL) or die(mysql_error()); echo "<!--" . $SQL . " : Jezik je:" . $lang . "-->";
  13. <?php //today $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE country = 'de' AND DATE('registertime') = CURDATE()"; $queryerg = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($queryerg)){ $registrationstoday = $row[0]; } //yesterday $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE country = 'de' AND DATE('registertime') = DATE_SUB(CURDATE(),INTERVAL 1 DAY)"; $queryerg = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($queryerg)){ $registrationstoday = $row[0]; } MySQL Date Functions
  14. I may be backwards, it has been re-written since I have seen it.
  15. Huff has it right. You should be running with error reporting at max and display errors on. (this can be set in php.ini) Setting it at runtime (each script) place this block at the top of the script. error_reporting(-1); ini_set('display_errors',1); This would have told you that $row did not exist. PS. welcome to the forum, let us know if an answer given doesn't work, we always check back. Otherwise, solved button is on lower right.
  16. It would be interpreted as, Select distinct words, and a count of how many times the word exist from labels, return the results by the count (highest to lowest). The returned columns would be 'words' and 'countof'
  17. to get the results you specified in the original post, you just use sort(). <?php $testArray=array("toLastName","to","message","email"); sort($testArray); echo implode('/',$testArray); ?>
  18. So order the query by the date column descending. Should give you the rows you desire.
  19. If you don't have imageMajik, I would suggest simple Image. One of the easiest free image classes out ATM.
  20. <?php $str = 'It will eventually go away.Once the carriers merge, the combined airline, will operate as Southwest. It has its logo and colors. 2.3 AirTran brand will no longer be used. '; $patt = '~(\.)([^\d\s])~'; //select a period that is NOT followed by a numerical digit or a space (capturing the space in the 1st group, and the alpha character in the second group). $str = preg_replace($patt,'$1 $2',$str); //replace the pattern with the 1st capture and the 2nd capture separated by a space. echo $str; ?>
  21. If you make code and IP both unique keys, mysql will throw an error on insert if EITHER code OR ip exist in the table.
  22. Simple image is much easier than doing it any other way, that is why it is called "Simple Image". My snippet runs hand in hand, minus the database query, with what you just did. It is fully commented.
  23. The easiest way is to get SimpleImage. Then build a script. <?php include 'simpleImage.php'; //include the class. $filePath = 'upload/images/'; //set file path. $imageName = 'myImage.jpg'; //set image name. if(!$upload_errors) { //after all error checks. $image = new SimpleImage(); //start the class. $image->load($_FILES['image']['tmp_name']); //load the temp file. $image->save($filePath . $imageName); //save the image, will be the large pic. $image->resize(200,200); //resize the image to the smaller size. $image->save($filePath . 'small_' . $imageName); //save the smaller pic, added 'small' to the name. $image->resize(50,50); //resize to thumbnail size. $image->save($filePath . 'tmb_' . $imageName); //save the thumbnail, added tmb to the name. This code should work, but is in no way good for public use. There should be lots of other checks in there. This is just to get you started.
  24. Paypal will never process a payment where the status is complete. This is because it is an old process.
  25. My post was in response to the "lawyers" stating it was ok.
×
×
  • 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.