jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
Pretty sure this is a cross thread. He is running crontabs that never complete, and when he tries to run them again, his host disables his site for having more than 21 processes running. http://www.phpfreaks.com/forums/index.php?topic=340951.0 There are problems with the download's, I would think that he isn't limiting the connection_timeout on a cURL call. But, he didn't post that much code.
-
You are getting the header error, because of the Warnings. Which is also why you see 'characters'. I can not fix file path errors for you, all I can do is tell you to: 1. make sure that the file path is from the directory that the file is in, relative file path (not recommended, for reasons already posted). or, 2. give the script the absolute file path (recommended).
-
So you are starting work at 7, and ending work at 16 , and you want to send an email after 24 hours worked? I couldn't think of a way to explain how to do it, and there may even be a better way, but this may help you. Fully commented up. <?php $database_date = '2011-01-08 13:00:00'; //this comes from your database, $updated_time = strtotime('+' . hoursLeft($database_date) . ' hours',strtotime($database_date)); //Handle the date: $new_date = date('m-d-Y, H:i:s',$updated_time); //this is when the email should be sent. echo date('m-d-Y, H:i:s',strtotime($database_date)) . '<br />' . $new_date . '<-- you should be emailing at this time!'; //just echo's it to the screen. function hoursLeft($time) { //this function handles the count of how many hours you need to fulfill your task. ////////Editable variables ///////////////////////////// $work_starts = 7; //start time; $work_ends = 16; //end time; $time_to_email = 24; //amount of time to allow before email goes out, (work hours). ///////End Editable Variables ////////////////////////// $parts = explode(' ',$time); //split the time off of the date. list($hour, $minute, $second) = explode(':',$parts[1]); //get the hours, minutes, seconds. if($minute == 0) { //if the minutes is over 0, then return a full hour for it $hours = $work_ends - $hour; } else { //otherwise, take into account that this isn't a full hour. $hours = ($work_ends - 1) - $hour; } for($i = $work_ends,$count = $hours; $count <= $time_to_email; $i++) { //Start the increment at 16, the count at the current hours, keep the count below 25, increment on each loop. if($i > 24) { //if the increment is over 24, reset it to 1. $i = 1; } if($i >= $work_starts && $i <= $work_ends) { //if the increment is between 7 and 16, add to the count, which will break the loop at 24. $count += 1; } $hours += 1; //add to the hours, the loop breaks at a count of 24, which will give us the total hours to add to the updated_time above. } return $hours; //return hours } ?>
-
Let us see what you are doing! Need code for that.
-
When I run bbcode, I require that both opening and closing brackets are in place, otherwise the bracket will just be printed out. function bbcode($content) { $content = preg_replace("~\[b\](.+?)\[\/b\]~i", "<b>$1</b>", $content); $content = preg_replace("~\[i\](.+?)\[\/i\]~i", "<i>$1</i>", $content); $content = preg_replace("~\[u\](.+?)\[\/u\]~i", "<u>$1</u>", $content); $content = preg_replace("~\[img\](.+?)\[\/img\]~i", "<img src=\"$1\" alt=\"\" />", $content); $content = preg_replace("~\[url\](.+?)\[\/url\]~i", "<a href=\"$1\">[Link]</a>", $content); $content = preg_replace("~\[url=http://(.+?)\](.+?)\[\/url\]~i", "<a href=\"$1\">$2</a>", $content); $content = preg_replace("~\[code\](.+?)\[\/code\]~i", "<div class=\"box\">$1</div>", $content); return($content); }
-
HELP! Some sort of PHP cron task kill script needed ! ! !
jcbones replied to Vixushr's topic in PHP Coding Help
I thought he just xxxx'd out a bunch of stuff he didn't want people to see. -
When I question what something does, I follow the age old de-bugging rule. When in doubt, echo it out!
-
Sort results from mysql query into 3 different select boxes
jcbones replied to jackiejackie's topic in PHP Coding Help
while($row = mysql_fetch_assoc($result)) { $storage[$row['certain_field']][] = $row['id']; } foreach($storage as $field => $arr) { echo '<select name="' . $field . '">'; foreach($arr as $id) { echo '<option>' . $id . '</option>'; } echo '</select>'; } Something like that, you will have to play with it though. -
In your column selection add elders.id AS eldersid Then instead of getting the variable via: $row2['id'] You would get it using: $row2['eldersid'] This is happening because you have 2 columns that are named `id` in the result set, and php is overwriting the first one `elders`.`id` with the second.
-
See how this works: <?php error_reporting(E_ALL); //debugging remove after script works. ini_set('display_errors',1); //debugging remove after script works. session_start(); if(isset($_SESSION['user'])) { include_once('connect.php'); $session = $_SESSION['user']; $w = (isset($_GET['w'])) ? (int)$_GET['w'] : 0; //0 being default weapon. $find = "SELECT * FROM weapon_shop WHERE id = '$w'"; $run = mysql_fetch_array(mysql_query($find)) or trigger_error(mysql_error()); $weapon_id = $run['id']; $weapon_name = $run['Weapon_Name']; $weapon_image = $run['Weapon_Image']; $weapon_level = $run['Weapon_Level']; $weapon_cost = $run['Weapon_Cost']; $weapon_sell_value = $run['Weapon_Sell_Value']; $weapon_attack = $run['Weapon_Attack']; $weapon_defense = $run['Weapon_Defense']; $weapon_strength = $run['Weapon_Stength']; $weapon_speed = $run['Weapon_Speed']; $weapon_accuracy = $run['Weapon_Accuracy']; $weapon_range = $run['Weapon_Range']; $find_stats = "SELECT * FROM stats WHERE Username = '$session'"; $stats = mysql_fetch_array(mysql_query($find_stats)) or trigger_error(mysql_error()); $player_HBS = $stats['HBS']; $player_Credits = $stats['Current_Credits']; $player_attack = $stats['Attack']; $player_defense = $stats['Defense']; $player_strength = $stats['Strength']; $player_speed = $stats['Speed']; $player_accuracy = $stats['Accuracy']; $player_range = $stats['Range']; $find_duplicate = "SELECT Weapon_Name FROM weapons WHERE Weapon_Name = '$weapon_name'"; $dup = mysql_fetch_array(mysql_query($find_duplicate)) or trigger_error(mysql_error()); $weapon_name_check = $dup['Weapon_Name']; if($weapon_name_check == $weapon_name){ header("location:weaponshop.php"); //header expects a full URI. Location must be capitalized, and a space must be after the colon. This will insure that it works across ALL browsers. }elseif($weapon_cost > $player_Credits){ header("location:weaponshop.php"); //see above. }else{ $new_player_credits = $player_Credits-$weapon_cost; $new_attack = $weapon_attack+$player_attack; $new_defense = $weapon_defense+$player_defense; $new_strength = $weapon_strength+$player_strength; $new_speed = $weapon_speed+$player_speed; $new_accuracy = $weapon_accuracy+$player_accuracy; $new_range = $weapon_range+$player_range; $new_HBS = $new_attack+$new_defense+$new_strength+$new_speed+$new_accuracy+$new_range *.3; echo " <html> <img src='$weapon_image'/><br/> $new_player_credits<br/> $new_attack<br/> $new_defense<br/> $new_strength<br/> $new_speed<br/> $new_accuracy<br/> $new_range<br/> $new_HBS </html> "; } }else{ header("location:index.php"); //see above. } ?>
-
You will have to add your password into the phpmyadmin config file. It's windows location is "serverRootFolder/apps/phpmyadmin(versionNumber)/config.inc.php". Not sure if that helps with Mac. There is an array that holds all the data. Self explanatory. If you change it in the database via phpmyadmin, then you will still have to configure phpmyadmin to work with the new password. As it isn't the database, but rather a program that accesses the database. If you cannot access phpmyadmin, you can still use mysql via the console (mysql.exe).
-
Where to find phpmyadmin details(server, user, database, etc....)
jcbones replied to dominic600's topic in Applications
You must have missed some script during copy/paste, because I get no parse errors with the posted script. I also didn't change anything that would give you that error, as that error usually is caused by missing brackets ({). -
Where to find phpmyadmin details(server, user, database, etc....)
jcbones replied to dominic600's topic in Applications
<?php //de-bugging remove this after script works as desired> error_reporting(E_ALL); ini_set("display_errors", 1); //end de-bugging// require("styles/top.php"); ?> <div id='content'> <div id='full'> <?php $form = "<form action='register.php' method='post'> <table> <tr> <td></td> <td>Fields indicating <font color='red'>*</font> are require.</td> </tr> <tr> <td>First Name:</td> <td><input type='text' name='firstname'><font color='red'>*</font></td> </tr> <tr> <td>Last Name:</td> <td><input type='text' name='lastname'><font color='red'>*</font></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='username'><font color='red'>*</font></td> </tr> <tr> <td>E-mail:</td> <td><input type='text' name='email'><font color='red'>*</font></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password'><font color='red'>*</font></td> </tr> <tr> <td>Confirm Password:</td> <td><input type='password' name='repassword'><font color='red'>*</font></td> </tr> <tr> <td>Avatar:</td> <td><input type='file' name='avatar'></td> </tr> <tr> <td>Website:</td> <td><input type='text' name='website'></td> </tr> <tr> <td>Youtube User Name:</td> <td><input type='text' name='youtube'></td> </tr> <tr> <td>Bio:</td> <td><textarea name='bio' cols='35' rows='5'></textarea></td> </tr> <tr> <td></td> <td><input type='submit' name='submitbtn' value='Register'></td> </tr> </table> </form>"; if ($_POST['submitbtn']){ $firstname = strip_tags($_POST['firstname']); $lastname = strip_tags($_POST['lastname']); $username = strip_tags($_POST['username']); $email = strip_tags($_POST['email']); $password = strip_tags($_POST['password']); $repassword = strip_tags($_POST['repassword']); $website = strip_tags($_POST['website']); $youtube = strip_tags($_POST['youtube']); $bio = strip_tags($_POST['bio']); $name = $_FILES['avatar'] ['name']; $type = $_FILES['avatar'] ['type']; $size = $_FILES['avatar'] ['size']; $tmpname = $_FILES['avatar']['tmpname']; $ext = substr($name, strrpos($name, '.')); if ($firstname && $lastname && $username && $email && $password && $repassword){ if ($password == $repassword){ if (strstr($email, "@") && strstr($email, ".") && strlen($email) >= 6){ require("scripts/connect.php"); $sql = "SELECT * FROM users WHERE username='$username'"; $query = mysql_query($sql) or trigger_error($sql . ' has an error!<br />' . mysql_error()); //added de-bugging No need to remove. $numrows = mysql_num_rows($query); if ($numrows == 0){ $sql = "SELECT * FROM users WHERE email='$email'"; $query = mysql_query($sql) or trigger_error($sql . ' has an error!<br />' . mysql_error()); //added de-bugging No need to remove. $numrows = mysql_num_rows($query); if ($numrows == 0){ $pass = md5(md5($password)); $date = date("F d, Y"); if($name){ move_uploaded_file($tmpname, "avatars/$username.$ext"); $avatar = "$username.$ext"; } else $avatar = "default_avatar.png"; $code = substr (md5(rand(11111111111, 999999999999999)), 2, 25); $sql = "INSERT INTO users VALUES ('', '$firstname', '$lastname', '$username', '$email', 'pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')"; mysql_query($sql) or trigger_error($sql . ' has an error!<br />' . mysql_error()); //added de-bugging no need to remvoe. $webmaster = "Admin@trucksite.com"; $subject = "Activate Your Account!"; $headers = "From: Admin <$webmaster>"; $message = "Hello $firstname.\n\nWelcome to trucksite below is a link for you to activate your account!.\n http://tprofiletesting.net23.net/activate.php?code=$code"; if(mail($email, $subject, $message, $headers)) { //added de-bugging. echo "Your activation email has been sent to <b>$email</b>."; } else { echo 'Your activation email failed! Please try again!'; } } else echo "That email is currently in use."; } else echo "That username is currently in use."; } else echo "You did not enter a vaild email."; } else echo "Your passwords did not match."; } else echo"You did not fill in all the required fields."; } echo "$form"; ?> </div> <div id='footer'><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a><a href='#'>Link</a></div> <body> </body> </html> -
Where to find phpmyadmin details(server, user, database, etc....)
jcbones replied to dominic600's topic in Applications
There are no queries, nor is the 96 lines in it. -
Where to find phpmyadmin details(server, user, database, etc....)
jcbones replied to dominic600's topic in Applications
This is an error that arises from an invalid query. As invalid queries does not return a resource that can be used in mysql_num_rows(). Does your database have tables? Do the table names match your script? Post your script, and I will add some de-bugging info in it to help you. (take out your DB connection details). -
Where to find phpmyadmin details(server, user, database, etc....)
jcbones replied to dominic600's topic in Applications
They use cpanel, go to the database wizard and add a user, then bind the user to the database. -
Where to find phpmyadmin details(server, user, database, etc....)
jcbones replied to dominic600's topic in Applications
Does your host have cpanel? Who is your host? -
Where to find phpmyadmin details(server, user, database, etc....)
jcbones replied to dominic600's topic in Applications
This error is usually overcome by using 'localhost' instead of the IP. This is because the IP address of your host is set to /deny in the .htaccess file that resides in etc/ You may need to change the bind-address var from 127.0.0.1 to your desired hostname(/etc/mysql/my.cnf) -
1. I wouldn't filter out any of the input for a login. I just run it through mysql_real_escape_string(). I don't want to give anyone a hands up in hacking an account, and I expect everyone to know their login credentials. Ex. Login: Admin (would work: Ad!min, #$@#!#$#@Admin, etc.). Same for password: PS. You should want users to use symbols in their passwords (makes 'em stronger). 2. You should be storing a hash value of password, and not plain text. Bad juju! 3. No need to run a while loop on the admin login, as you are only checking for 1 row. 4. Need to see your form that submits to the first script. I see nothing that stands out for failure (other than the preg_replaces).
-
Where to find phpmyadmin details(server, user, database, etc....)
jcbones replied to dominic600's topic in Applications
The error should say more than "can't connect to 'localhost'". What is the full error (copy/paste). Most of the time database's do reside on localhost (the same web server as the site). The most common cause of this, is that you got the username, password, or database name incorrect. There are some services that have remote hosting, GoDaddy uses it I know. But, that should have been in the documentation when you set up the database. -
Haven't used it, but google pointed to it right away. http://sourceforge.net/projects/phpexcelreader/
-
http://www.dwalker.co.uk/phpmysqlautobackup/
-
The target path is the final name of the file. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); //this is what the file name is: //change it: $target_path = $target_path . 'somethingelse.txt';
-
Remove: $playlist = array( '0' => array( '0' => array( 'src' => "$url$files[0]", 'type' => "$video", ), 'config' => array( 'title' => "$title", 'poster' => "$logo") ), ); for ($i=0; $i < 3; $i++) { $playlist[$i]['src'] = "$url$files[$i]"; $playlist[$i]['type'] = "$video"; $playlist[$i]['title'] = "$title"; $playlist[$i]['poster'] = "$logo"; } And place this: $count = count($files); for($i = 0; $i < $count; $i++) { $playlist[] = array( array( 'src' => $url.$files[$i] , 'type' => $video ), 'config' => array( 'title' => $title, 'poster' => $logo) ); } Backup your files of course.
-
Try: include "database.php"; $cleaned_file = array("1","2","3","4"); $sql = "INSERT INTO test (ONE, TWO, THREE, FOUR) VALUES (?,?,?,?)"; $stmt = $db->prepare($sql) or die ("ERROR: " . implode(":", $db->errorInfo())); $stmt->bindParam (1, $cleaned_file[0]); $stmt->bindParam (2, $cleaned_file[1]); $stmt->bindParam (3, $cleaned_file[2]); $stmt->bindParam (4, $cleaned_file[3]); $stmt->execute($cleaned_file) or die ("ERROR: " . implode(":", $stmt->errorInfo())); echo "Record(s) successfully added.";