428 Posted Topics
Re: [CODE] $query_birthdate = "SELECT day(user_birthday) as Day FROM users WHERE username='kkjay'"; $birthdate = mysql_query($query_birthdate, $connections) or die(mysql_error()); $row_birthdate = mysql_fetch_assoc($birthdate) echo $row_birthdate['Day']; [/CODE] Always use the mysql functions in your queries when you can, as you have done, the database server has that functionality for a reason. No reason to … | |
Re: In my opinion the best way to do this would be to name your fields using an array index. [CODE] <input name="field[]" type="text" size="20" maxlength="40" /> <input name="field[]" type="text" size="20" maxlength="40" /> <input name="field[]" type="text" size="20" maxlength="40" /> [/CODE] Then when you process the fields with PHP it is as … | |
Re: You would need to use runas on windows to run notepad.exe as the specified user: [CODE] <?php exec('runas /user:ComputerName\UserName "notepad"'); [/CODE] However, if the user account requires a password it will prompt and can not be completed via the command line directly. You could create a vb script or something … | |
Re: I have to agree with richieking here. There are numerous open source e-commerce packages that will probably offer more than you will possibly need. Pick one, learn it, install modules/plugins/etc and/or customize it where necessary. If you are just learning php and starting out with web development, this is not … | |
Re: It doesn't look like you posted your entire table structures, hence there is no reasonable way to know where Exam_category.categoryid joins to the three other tables. I'd also like to know the conditions of your joins. e.g. Can a user take the same exam more than once. ( Fail, Fail, … | |
Re: Performance wise, you should avoid loading an entire file into memory when possible. The following code relies on the SPL (standard php library) which is mostly > php 5.1 Although this can also be done using the file functions in php. [CODE] <?php $email = 'user@domain.com'; $file = new SplFileObject('filename.txt'); … | |
Re: How about you post some code so we can see what you're talking about... ![]() | |
Re: Really two ways to do commonly do this. First, using a socket [CODE] <?php $fp = fsockopen("www.daniweb.com", 80, $errno, $errstr, 5); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "HEAD / HTTP/1.1\r\n"; $out .= "Host: www.daniweb.com\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { echo … | |
Re: You can use xdebug to profile the code: [url]http://www.xdebug.org/docs/profiler[/url] | |
Re: The php parser almost always points you right to the problem. In this case it has directed you to line 7. I took a quick glimpse and immediately realized the left parenthesis was typo'd with a left curly brace: [ICODE] $connect = mysql_connect {"localhost","root","webdesigning1") or die ("couldnt connect to mysql … | |
Re: There is absolutely no need to create your class files with a .class.php extension, or any special naming convention. However, many of the larger projects these days have moved to the PEAR standard for naming classes ([url]http://pear.php.net/manual/en/standards.naming.php[/url]). This is completely optional of course. I don't quite understand your question fully … | |
Re: Honestly, the state of php6 is so widely unknown at this point, and with adoption of php 5.3 only starting to become common, your best bet would be to lose the 6.0.0-dev build, and develop on 5.3 if you want bleeding edge and any chance of actually having something deployed. … | |
Re: My guess is the error is on line 1 somewhere... | |
Re: If your input is always going to be HTML/XML this would be ridiculously easy using SimpleXML and an xpath query: [CODE] <?php $string = <<<XML <body> <img src="page.jpg" border="0" usemap="#fghf" /> <map name="fghf" id="fghf"> <area shape="rect" coords="10,71,258,236" href="#" alt="some_alt" title="some_title" /> <area shape="rect" coords="258,72,506,237" href="#" alt="some_alt" title="some_title" /> <area shape="rect" … | |
Re: The nuke codes man! We need the launch codes. Anything that relates to your pagination would be of interest. The code where it is implemented, and also the code that actually generates the pagination. ![]() | |
Re: [CODE] function showDepartment() { require_once('lib/model/classDepartment.php'); $dept = new department(); $departmentID = $dept->showAllDepartment(); if(isset($_POST['addDepartment'])) $this->addDepartment(); if(isset($_POST['updateDepartment'])) $this->updateDepartment(); if(isset($_POST['yesDeleteDepartment'])) $this->deleteDepartment(); if(isset($_POST['noDeleteDepartment'])) echo "<script language='javascript'>window.location='department.php';</script>"; require_once('lib/view/tpl.department.php'); } [/CODE] Without knowing how the department class is setup, this is my best assumption. | |
Re: file_get_contents does exactly what the function name says. It opens a file reads all of the content from the file and stores it into a variable etc for your later use. If you want to use an additional php file within your index.php you want to use include/require ([url]http://php.net/manual/en/function.include.php[/url]) There … | |
Re: [CODE] <?php //Start with the base string plus 15 decimal places $str = '1797693134862316'; //Add 293 0's to the string e.g. (308 - 15) for( $i=0; $i<293; $i++ ){ $str = $str . '0'; } //Use bcmath to divide it by 1048576 var_dump( bcdiv( $str, '1048576', 2 ) ); [/CODE] … | |
Re: The following code uses the SplFileObject [[url]http://www.php.net/manual/en/class.splfileobject.php][/url] from the SPL library. This ensures we never read the entire file into memory, only one line at a time. For small files it is okay to read it into an array, but it is best to get in the habit of working … | |
Re: Just a general observation, feel free to ignore the following. In your table you're using a surrogate primary key, the auto-incrementing column. When you clearly have a natural and practical composite primary key in (book, chapter, verse) as they are always provided and the combination of three digits may not … | |
Re: You need to install the ImageMagick binary library for windows. You can access this via the command line which is what a lot of legacy applications do. If you want to use the imagick extension then you need the appropriate dll file. Look at your phpinfo: [CODE] <?php phpinfo(); [/CODE] … | |
Re: [url]http://www.php.net/manual/en/language.operators.comparison.php[/url] Manual page breaks down just about anything you could possibly want to know. | |
Re: What you're asking is more of a MySQL (I'm assuming) question than directly related to php. MySQL has a ton of date handling capabilities. Is the date column, which is [B]not[/B] a reserved keyword ([url]http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html[/url]), setup to be a Datetime, Date, Timestamp or Integer (unix timestamp) field? | |
Re: Your use of quotes is incorrect. In php anything wrapped in quotes is a string. If you put a number in quotes single or double it is considered a string. If you specifically want something to be a number, do not wrap it in quotes. [CODE] <?php $a = 5; … | |
Re: Using php 5.2.2+ this is a piece of cake. [CODE] <?php $date1 = new DateTime('2010-12-07'); $date2 = new DateTime('2010-12-07'); if( $date1 == $date2 ){ echo 'Dates are equal.'; } [/CODE] [url]http://www.php.net/manual/en/datetime.diff.php[/url] scroll down to example #2 for some examples. | |
Re: [CODE] <html> <form action="get.php" method="GET"> <input type="text" name="myname"><br> <input type="submit" value="click here"> </form> </html> <?php $name = $_GET["myname"]; echo "Hello, $name"; ?> [/CODE] 'myname' is not an index in the $_GET array prior to the form being submitted. [CODE] <html> <form action="get.php" method="GET"> <input type="text" name="myname"><br> <input type="submit" value="click here"> … ![]() | |
Re: What version of PHP are you running, is it VC6 or VC9 compiled and is it Thread Safe (TS) or Not Thread Safe (NTS)? You can find this information by displaying phpinfo() and looking for the lines Zend Extension Build & PHP Extension Build | |
Re: I'm not sure if I completely follow what you're asking but array_count_values will return a count of all unique values in your array. Returning an array of unique array items and their count. First, you need to change [ICODE]$stateFrequency = array_count_values($values=1);[/ICODE] to [ICODE]$stateFrequency = array_count_values($values);[/ICODE] For your example array this … | |
Re: If you're going to build this to essentially sit on top of cPanel, there is an entire API for interacting with cPanel: [url]http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/XmlApi[/url] The easiest way to do this would be to have reseller access to cPanel and create the individual user accounts using sudomain.domain.com as their domain name. Set … | |
Re: I agree with everything ardav said. If you really desire to build a social engine from scratch, define your requirements. Then you will need to spend a lot of time with domain modeling and data storage design before you even start writing code. You could hack and patch it together … | |
Re: For a long time I was a fan of doing everything with unix timestamps, but there are, in most cases, limitations to these. One of the limitations would be the available range (Jan 1, 1970 - Jan 19, 2038). Its mostly a 32bit limitation and I would hope by 2038 … | |
Re: If you're using php 5.3+ there are some new classes that make this easier to accomplish. [CODE] <?php //Define out start and end dates $start = new DateTime('2011-01-01'); $end = new DateTime('2011-02-01'); //Define our holidays //New Years Day //Martin Luther King Day $holidays = array( '2011-01-01', '2011-01-17', ); //Create a … | |
Re: I know you already solved this, but you can also achieve this without having to do the addition in php. [CODE] mysql_query("UPDATE posts SET views = views + 1 WHERE id='$start'") or die(mysql_error()); [/CODE] | |
Re: Are you trying to join data from multiple tables in one database, or are you trying to join data across multiple tables in multiple databases? | |
Re: This to me sounds like something best handled by the database using a trigger. Questions (Table): [CODE] QuestionId int Question varchar Answer varchar DateActive datetime Value tinyint default 100 [/CODE] QuestionUserAnswers (Table): [CODE] QuestionId int UserId int Answer varchar Score tinyint (min 50, max 100) [/CODE] With your trigger being … | |
Re: Actually as of php 5.3 you are able to [URL="http://en.wikipedia.org/wiki/Monkey_patch"]monkey patch[/URL] core php code. Which is essentially replacing core functions at runtime. Illustrated by this blog: [url]http://till.klampaeckel.de/blog/archives/105-Monkey-patching-in-PHP.html[/url] | |
Re: Can you please describe your use case a little more so we have a better idea of what you are trying to accomplish? You can read through a file line by line using fgets, but if you are trying to detect if a character is an end of line character, … | |
Re: I think this is going to depend more on how your array is actually structured. Post up and example of the array your iterating and a more detailed example of the result. | |
Re: In your code $get_numbers and $get_letters are variables. In the urls in the link you are building you are using the value of those variables in the url. So, [ICODE]<a href="index.php?page=21;l='.$get_letters.'"[/ICODE] would become [ICODE]<a href="index.php?page=21;l=1"[/ICODE] in your html. If the value of $get_letters was 1. This would mean the value … | |
Re: Wamp and PHP frameworks are not synonymous. Regardless whether you choose a to use a framework, you still need a web server installation, which is what Wamp is. As for frameworks, my suggestion is to make some quick applications under several of the big name frameworks and get a feel … | |
Re: BaSk, I have done just this. But, I use a command line tool called PDFTK ([url]http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/[/url]) Essentially, I take a fillable pdf that has been designed. Collect information from the user via a web interface and create xfdf from it ([url]http://partners.adobe.com/public/developer/en/xml/xfdf_2.0_draft.pdf[/url]). Once I have the generated xfdf I execute a … | |
Re: Then you probably want to look into using a 3rd party system for sending these bulk emails. There are lots of providers that supply this functionality, at a cost of course. [LIST] [*][URL="http://sendgrid.com/"]Send Grid[/URL] [*][URL="http://www.streamsend.com/"]StreamSend[/URL] [/LIST] Are two I am familiar with, StreamSend being one i've done a lot of … | |
Re: In my opinion there are several reasons to use thumbnails over full sized images. For starters the web is fast and your connection might be fast but there are still plenty of people who do not have fast connections. Second, since in a default state browsers only allow you to … | |
Re: [QUOTE][CODE]<?php <form action="ScoreCardAlpha.php" method="post"> A: <input type="text" name="$X" /> B: <input type="text" name="$Z" /> C: <input type="text" name="$W" /> // read input data on $W , $X or $Z has http// if so save after // if(!filter_has_var(INPUT_post, "$X")) { // if true **** deleate all char upto and including // … | |
Re: Assuming your table is a MyISAM and the particular column has a full-text index on it: [CODE] SELECT * FROM table WHERE MATCH (col1, col2, col3) AGAINST ('+Goa' IN BOOLEAN MODE); [/CODE] [url]http://dev.mysql.com/doc/refman/5.1/en/fulltext-boolean.html[/url] ***Apparently this does not REQUIRE a fulltext index, but will take a major performance hit | |
![]() | Re: For simple projects IDE's aren't going to make your life any easier, but when you have thousands of files, classes, and functions in a project that you need to be able to easily and quickly reference an IDE makes worlds of difference in my opinion. ![]() |
![]() | Re: it is used in context with sprintf and printf etc? [url]http://php.net/manual/en/function.sprintf.php[/url] |
Re: There are several places the character set needs to be accounted for: [LIST=1] [*][URL="http://dev.mysql.com/doc/refman/5.0/en/charset-database.html"]Database Collation & Charset[/URL] [*][URL="http://dev.mysql.com/doc/refman/5.1/en/charset-table.html"]Table Collation & Charset[/URL] [*][URL="http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html"]Charset of the database connection[/URL] [/LIST] From within php: [LIST] [*]MySQL Extension : [URL="http://www.php.net/manual/en/function.mysql-set-charset.php"]mysql_set_charset[/URL] [*]MySQLi Extension : [URL="http://www.php.net/manual/en/mysqli.set-charset.php"]mysqli->set_charset[/URL] [*][URL="http://www.galengrover.com/web-development/setting-the-connection-charset-with-php-mysql/"]PDO Extension[/URL] [/LIST] Also if you are displaying the content the … | |
Re: What is the data type of your t_stamp column? I assume it is TIMESTAMP? | |
Re: You want to use the $storage->moveMessage( id, folder) method. This site illustrates it a little more in detail: [url]http://www.devcha.com/2010/06/how-to-removemove-messages-using-zend.html[/url] The comments at the bottom of the Zend_Mail documentation also elaborate on this: [url]http://framework.zend.com/manual/en/zend.mail.read.html[/url] Automatically routing an email from a user to a particular folder would require some kind of intermediate … |
The End.