Jump to content

Vikas Jayna

Members
  • Posts

    121
  • Joined

  • Last visited

Everything posted by Vikas Jayna

  1. replace the line [code]if ($step="sub")[/code] with [code]if ($step=="sub")[/code] Basically, for comparison the operator is == and not =
  2. replace the line [code]$writedata = '$word';[/code] with [code]$writedata = '$word\n';[/code]
  3. Probably there is some configuration difference in the server and the local machine. Is the GD library installed on the server?
  4. One way is to put a check in each of your scripts or probably the home page by putting some checks on the current system time and whether the thing has been logged. This approach is used by the software available at http://www.dwalker.co.uk/phpjobscheduler/ But the time at which the data will be logged will be different every day as it will depend on when a page is requested on the website and hence this method will not work for sites which have only a few hits a day
  5. decode the image with [b]base64_decode()[/b] and then write it to a temporary file on the disk (say image.jpg). In case you do not wish to write the file on the disk, then the code would look something like this: [code]$fp=popen("/usr/bin/convert -resize 30x30 - -"); fwrite($fp,$imagecontent); pclose($fp);[/code] Here the command uses an additional [b]hyphen[/b] which means that the input image will come from standard input stream i.e. the content writen by [b]fwrite[/b] function
  6. You already have the [b]foreach[/b] loop, only the [b]if condition[/b] is to be added with the [b]foreach[/b] nested within. Good luck!
  7. Well there are lots of issues with this code:- Firstly, the following query is a waste since the recordset obtained $result is not being used anywhere: [code]$grab_post = "SELECT * FROM `posts` WHERE `id`=\"$id\" LIMIT 1"; $result = @mysql_query($grab_post, $conn) or die(mysql_error());[/code] Secondly, there are no values in [b]$row['title'][/b] , [b]$row['body'][/b] Thirdly, the variable [b]$news[/b] is used as a string at some places and as an object of [b]ShowNews[/b] class later. If you were to put the following two lines [code]$news = new ShowNews; $news->show_news(2);[/code] In the second last line of show_news.php before [b]echo $news[/b] then the separate comments will be lost. Was that the case why separate comments were not getting displayed?
  8. [code]select query_id from query_trace where owner='xyz' and completed != "0000-00-00 00:00:00" order by created desc limit 1[/code]
  9. use the array_merge() function.
  10. Will have to monitor the mysql processlist using [b]show processlist[/b] to see what mysql is doing during those five minutes - is the connection established immediately? is the query executing or does the connection show the status as [b]sleep[/b]. Also, it would be worth seeing the performance of apache on the new machine - simply execute a script that does not use mysql and see how fast it executes.
  11. Cron jobs are a feature of linux and not php. It allows you to schedule any command in linux.
  12. You can check whether [b]$delete_array[/b] is an array using [b]is_array()[/b] function and only then process the foreach loop. Like this:- [code]if(is_array($delete_array)) {           foreach($delete_array as $val)           {                 //delete them!                 $query = "DELETE FROM software WHERE id = '$val'";                 $result = mysql_query($query) or die(mysql_error());           } }[/code]
  13. See the output of the phpinfo() function. When php is to be compiled with mysql support, we need to specify the path where mysql is installed by using the --with-mysql option in the configure command. Check whether this is there in the output received from phpinfo(). Also, if it is installed then there should a a separate section for mysql.
  14. Do you have the [b]ImageMagick[/b] library installed on the server. In case you do, then the [b]convert command[/b] can be called from within php using [b]passthru function[/b] like this: [code]passthru("/usr/bin/convert -resize 30x30 image.jpg -");[/code] this will output the thumbnail of size 30x30 to the browser. image.jpg should be an image file on the disk.
  15. In [b]mysql[/b], you can enclose the column names within [b]backquotes[/b] like this: [code]$sql2 = "select  distinct `grp no` from tbl_studiag_num where `stu no`=\"$stu_id\" ";[/code] and it'll work. cheers :)
  16. The character length can be limited using [b]maxlength=1[/b] in the input tag i.e. [code]<input type="text" maxlength="1" name="xyz">[/code] Also, the focus can be shifted to the second textbox by using the [b]OnChange()[/b] property on the first textbox
  17. intval is different from round in the following way:- intval(2.8) gives 2 round(2.8) gives 3
  18. The queries should be executed conditionally i.e. they should be executed only if the corresponding value of email is not blank.
  19. There are no closing braces for the [b]if statements[/b] used.
  20. Will have to see the contents of the configuration file httpd.conf or .htaccess(if enabled) to figure this one.
  21. rounding the value may not work. Suppose there are 23 items in the array, then [i][b]round(23/10)[/b][/i] becomes [b]2[/b] and you add [b]1[/b] to this and get the number of pages i.e. [b]3[/b]. btherl's solution could give erronious result for a few values for e.g. if the No. of items is 29, then it will give 4 pages instead of 3. Here is the correct code that should work: [code]$n = count($array); $last_page = intval($n / 10) + 1;[/code]
  22. The mysql_query() function expects a single query and not multiple queries. Ideally this script should be giving a parsing error p[i][b]arse error, unexpected '\"'[/b][/i] as there is no concatenation operator between the five strings. Probably you can have five calls to mysql_query() function with one query each or a single insert statement to insert all the five records at once - See the Insert query syntax in the mysql manual for the same.
  23. You Can highlight the portion of the page after the html has been loaded in the <div> and then use "view selection source". This is a good way of checking source with Ajax.
  24. Ok! I'll try to explain with an example. Supose a user XYZ chooses the following values:- For Occupation - values A,B and C For Religion - values D,E and F For Language - values G,H and I For Residence - values J,K and L Now there are various ways of creating the database structure:- 1) [b]Having multiple tables[/b] ( one each for Occupation, Religion, Language and Residence) - all the four tables will have two columns, one containing the user id and the other the value. In this case, there will be three rows in each table for user XYZ as three values have been selected for each. [b]This is the database structure I have at present[/b] but to search this database for those users that have chosen say - A in Occupation and E in Religion and I in language and L in residence, will require a join between the four tables. 2) Another way is to use a [b]single table[/b] and have the values A,B and C stored [b]comma delimited[/b] in a column Occupation. This will require the usage of 'like clause' for searching the user with the criteria given above and 'like clause' will not use indexes which will make the search slower 3) Another way is to use a [b]single table[/b] that is [b]de-normalised[/b] such that if the user chooses 3 values for each of the four columns, then the total No. of rows in the table will be 3*3*3*3 = 81 rows for the user and then a simple where condition like 'occupation=A and religion=E and language=I and residence=L' will give the result but the table will become huge and hence even this solution is impractical. Regards, Vikas Jayna
  25. Then how do I store multiple values in a column against one id and still be able to search on the column?
×
×
  • 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.