HuggieBear
Members-
Posts
1,899 -
Joined
-
Last visited
Everything posted by HuggieBear
-
[SOLVED] Setting Upload File size limit
HuggieBear replied to darknessmdk's topic in PHP Coding Help
Quick question... Where are you defining $file_size? You are using variable that doesn't exist in an if condition... [code]<?php if ($file_size > 1000000){ echo "Your file is too large"; } ?>[/code] Regards Huggie -
OK, was it in the context of education by any chance, or some sort of learning, tutoring establishment? Regards Huggie
-
That's a great idea, I wonder why I didn't think of that Regards Huggie
-
Why not set the default value of the column in the database to be '0' and then when you insert/update the row in the database from the php, you only insert/update the required values. Checkboxes are only sent if they're checked Regards Huggie
-
It's similar yes, it's reference to the calling object. $this is a special variable that's used within classes. Here's some light reading for you http://uk.php.net/manual/en/language.oop5.basic.php Regards Huggie
-
[quote author=jesirose link=topic=124824.msg518604#msg518604 date=1170300420] Did you tell them their code doesn't work? If they can't get it to work, geez. [/quote] Their code is working fine. I've checked the URL and there's no issues with it. If you call it with a query string in the URL it responds as expected. Can you post the code that is in the flash file? I don't remember masses about Flash, but I can remember enough to get forms working I'm sure! Regards Huggie
-
It thinks $m-$d-$y is $m (minus) $d (minus) $y Try this: <?php $eventdate = $_GET['date']; echo "$eventdate"; // value is 01-18-2007 echo "$m-$d-$y"; // value is 01-18-2007 if ($eventdate == "$m-$d-$y"){ echo"test"; } ?> Regards Huggie
-
I think the only way to do this is via Javascript. It MUST be client side. So what you want is an on-click event, that when you click submit does something like a document.write and then submits the form. It is possible. I'll look tomorrow. Regards Huggie
-
Yes, it's possible. You need to let people know the column names in each table and I'm sure someone can help you out. Regards Huggie
-
The module in Perl your thinking of was probably either Win32::CaptureIE or Win32::Screenshot I believe they use ImageMagick. I don't know if it's been done in PHP but I'll have a scout about. Regards Huggie
-
Creating a PDF by combining an image and a text input
HuggieBear replied to Zeeforel's topic in PHP Coding Help
Marcel, It is possible and you need to thoroughly read this page before you go any further: PHP: PDF Functions Regards Huggie -
Try this... You don't need all the \r\n on the end of every parameter passed to mail(), only the additional headers. <?php include("fns.php"); include "config.php"; if(isset($_POST['Submit'])){ //1. Check if form fields are filled in if(!filledin($_POST)){ header( "Location:Messages.php?msg=7" ); exit(); } $name=$_POST['name']; $em=$_POST['mail']; //2. Check if entered name exist $query="Select pw from user where uname='$name'" or die(mysql_error()); $result= mysql_query($query); if(mysql_num_rows($result)>0){ for ($i=0; $i<mysql_num_rows($result); $i++) { $row = mysql_fetch_assoc($result); $pass = $row['pw']; $to = $em; $from = "From: Admin@jacquesnoah.co.uk\r\n"; $msg = "Password: $pass"; $msg .= "Username: $name"; $msg .= "Please change your password as soon as you logon"; $subject = "From Admin re: Your Login Password"; } }else{ header( "Location:Messages.php?msg=8" ); exit(); } //4. Send password to user if(mail($to,$subject,$msg,$from)){ header( "Location: Messages.php?msg=9&email=$em" ); exit(); //echo "Please click here to log"; } else{ header( "Location:Messages.php?msg=10"); exit(); } } ?> Regards Huggie
-
How do you know what my balls look like Huggie
-
If I put in a tender for freelance jobs on here, I put them in at £10 GBP per hour (approx $20 USD) but that's because it's normally only script fixes or tweaks. If I'm creating a member management system, or shopping cart, that sort of thing, then I charge based on the project as a whole. Regards Huggie
-
Try this code. I've taken it from what you posted so it should drop straight in. <?php // DB connection options $host="localhost"; // Host name $username="#"; // Mysql username $password="#"; // Mysql password $db_name="#"; // Database name $tbl_name="#"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Main query $sql="SELECT * FROM $tbl_name"; $result = mysql_query($sql) or die(mysql_error()); $count = mysql_num_rows($result); ?> <div id="nav"> <?php include("nav.php"); ?> </div> <form name="mysql" method="post" action=""> <h1>Delete multiple rows in mysql</h1> <?php while($rows = mysql_fetch_array($result)){ ?> <table width="100%" border="1"> <tr> <td valign="top"></td> <td valign="top"><strong class="title">Title</strong></td> <td valign="top"><strong class="title">Date</strong></td> <td valign="top"><strong class="title">Author</strong></td> </tr> <tr> <td valign="top"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $rows['id']; ?>"></td> <td valign="top"><?php echo $rows['title']; ?></td> <td valign="top"><?php echo $rows['date']; ?></td> <td valign="top"><?php echo $rows['user']; ?></td> </tr> </table> <?php } ?> <input name="delete" type="submit" id="delete" value="Delete"> <?php /* * This code is a bad idea as it's executing a query again and again and again. * See the code I've posted below if(isset($_POST['delete'])){ foreach($_POST['checkbox'] as $no => $del_id){ $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">"; } } */ if (isset($_POST['delete']) && isset($_POST['checkbox'])){ // don't attempt to delete just because the hit delete, make sure they checked a box first $id_string = implode("','", $_POST['checkbox']); $sql = "DELETE FROM $tbl_name WHERE id IN '$id_string'"; if(mysql_query($sql)){ echo "Success! (" . mysql_affected_rows() . " were deleted)"; // once you know it's working, then put your meta redirect in } else { echo "Failed to delete (" . mysql_error() . ")"; } } ?> </form>
-
[quote author=metrov link=topic=124824.msg518336#msg518336 date=1170278024] 2 -- If you don't see two 1's, there is a problem with your PHP setup.// Did not see the two 1's. So doesn't this indicate a problem with my PHP setup? If so, I'm confused coz you said my PHP was okay. Do you mean something else?[/quote] Jesi meant the php code itself looks fine, but the way PHP is setup on your server maybe incorrect. Regards Huggie
-
I think your 'posts per day' needs a bit of touching up though and just you wait, I'll be a recommended Freak any day soon I'm sure... hehe
-
In that case it's really simple... I can see from your existing code you're column is called due, so my sql statement is only doing to select from that column, but you can put all of your columns in... <?php // Query database and have the due column returned as a unix_timestamp $sql = "SELECT unix_timestamp(due) AS due FROM table_name WHERE column_name = 'condition'"; $result = mysql_query($sql) or die ("Unable to execute $sql: " . mysql_error()); // Get our timestamp into a php variable for comparison $due_date = mysql_result($result,0,'due'); if (date("Y-m-d") == (date("Y-m-d", $due_date)){ echo "On"; } elseif (time() > $due_date){ echo "After"; } else { echo "Before"; } ?> Edit: You're to quick for me Jesi Regards Huggie
-
[SOLVED] Please help to display rows number output from DB
HuggieBear replied to stu10576's topic in PHP Coding Help
Please edit your post and put ... tags around it. Give this a try: <?php $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); mysql_query("SET NAMES utf8"); if (!(isset($pagenum))) { $pagenum = 1; } // create query $query = "SELECT * FROM techNeed where state='Alabama' order by city"; // execute query $data = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $rows=mysql_numrows($data); $page_rows = 3; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets range that we will display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $result = mysql_query("SELECT * FROM techNeed where state='Alabama' order by city $max") or die(mysql_error()); // *** This is what I've added *** $index = ($pagenum * $page_rows) - ($page_rows - 1); while($info = mysql_fetch_array($result)) { $salonName=mysql_result($result,$i,"salonName"); $city=mysql_result($result,$i, "city"); $state=mysql_result($result,$i,"state"); $phone=mysql_result($result,$i,"phone"); echo " <table border='1' cellpadding='1' bgcolor='#D5EAEA' width='900'> <tr><td>$index</td><td>$salonName</td><td >$city </td></tr> <tr><td> </td><td>$state</td><td>$phone</td></tr> </table>"; $i++; $index++; echo " "; } if ($pagenum == 1) { } else { $previous = $pagenum-1; echo "<a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> << Trở Lại[/url] "; } $next = $pagenum+1; for($k = 1; $k <= $last; $k++){ if(($pagenum) == $k){ echo "$k "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pagenum=$k'>$k[/url] "; } } if ($next == $last+1) { echo " Hết "; } else { echo "<a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Trang Kế >>[/url] "; } ?> I just added this small calculation... $index = ($pagenum * $page_rows) - ($page_rows - 1); That should work. Regards Huggie -
ok, the easiest way to compare dates is to use unix timestamp format. So you have two ways to do this... 1) Get the date from your database, use php to convert it to a Unix timestamp and then compare it to the current timestamp. 2) Use MySQL's timestamp function and just compare it in php. The first is longer, but the column type in MySQL doesn't matter too much The second is easier and involves changing your sql query very slightly, but is dependent on the column type in MySQL being either, date, or datetime. Which way do you think you'd like to go? Regards Huggie
-
ok, well this code should work. I've included some comments and hopefully this will help by example. I've changed two main things... 1) The format of the file, not it's in YYYY-MM-DD format as that's the ISO 8601 standard, and easy to manipulate in PHP 2) We're only going to us one file. <?php /* * Open the file that contains tour dates, the format should be as below * * YYYY-MM-DD|Location of gig * 2007-06-14|London, England **/ $raw_data = file('tourdates.txt'); /* * Loop through each line, split into date and location and then place in * a new array keyed by unix timestamp **/ foreach ($raw_data as $line){ list($date, $location) = explode('|', $line); $gigs[strtotime($date)] = $location; } // Place the gigs in date order ksort($gigs); // Get todays date and work out the net gig from it $today = strtotime('today'); foreach ($gigs as $d => $l){ if ($d > $today){ $next = $d; break; } } // Echo when the next gig is, using the date() funtion to format to your liking echo "The next gig is " . date("l jS F", $next). " in " . $gigs[$next]; ?> Regards Huggie
-
Does it have to be done this way or are you open to suggestion? Regards Huggie