jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
$gettimetableObject->$setFacnameArray($FacnameArrayR); //you are assigning the method name via a variable that MOST LIKELY doesn't exist. To fix: $gettimetableObject->setFacnameArray($FacnameArrayR); //remove the $ on the method name.
-
echo __FILE__; This will show you the full path to your current script.
-
That is funny! That code was tested in the major browsers before being given to you. That being the fact, "doesn't work" doesn't mean anything around here, without specifics and a little code.
-
No one wants to wait 60 seconds for a page refresh. Most people don't even view a single web page for 60 seconds. But, if you want one, here is a javascript one. <div style="display:none;" id="strclock">Clock Here!</div> <div id="clock">To Update Click the button below!</div> <script type="text/javascript"> var hour = 0; var min = 1; var sec = 0; function checkTime() { var time = document.getElementById('strclock').innerHTML; if(time == '00:00:00') { window.location = 'http://google.com'; } } function countdown() { if(sec <= 0 && min > 0) { sec = 59; min -= 1; } else if(min <= 0 && sec <= 0) { min = 0; sec = 0; } else { sec -= 1; } if(min <= 0 && hour > 0) { min = 59; hour -= 1; } var pat = /^[0-9]{1}$/; secs = (pat.test(sec) == true) ? '0'+sec : sec; mins = (pat.test(min) == true) ? '0'+min : min; hours = (pat.test(hour) == true) ? '0'+hour : hour; document.getElementById('strclock').innerHTML = hours+":"+mins+":"+secs; if(min >= 1) { document.getElementById('clock').innerHTML = min+1+' minutes until timer runs out!'; } else { document.getElementById('clock').innerHTML = sec+' seconds until timer runs out!'; } checkTime(); setTimeout("countdown()",1000); } countdown(); </script>
-
Perhaps you meant. NOW() or CURDATE().
-
The error you are getting, is because there is no error array. This line: if(isset($errors)){ reads "if there are errors". But, then your error block is held in the else clause of this if/else block. You should change it to, if(!isset($errors)){ which reads "if there are NO errors".
-
If this outputs anything, copy/paste the output here. <?php error_reporting(-1); ini_set('display_errors',1); // Connects to your Database mysql_connect("localhost", "name", "password") or die('Error: '.mysql_error()); mysql_select_db("database") or die(mysql_error()); if(isset($_COOKIE['ID_my_site'])) { //$username of login user $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { //fname is the first name of login user Print "<b>Name:</b> ".$info['fname'] . " "; }} ?>
-
<?php if( isset($_POST['uploadbtn']) ) { $folder = "{$_SERVER['DOCUMENT_ROOT']}/images/test/"; $fileName = $_FILES['newImage']['name']; $tmpName = $_FILES['image']['tmp_name']; include('../simple-image.php'); $image = new SimpleImage(); $image->load($tmpName); $image->resizeToWidth(600); $image->save($folder.$fileName); $image->output(); //don't output unless you change your headers to an image/type if(file_exists($folder.$fileName)) { echo 'Upload was successful!'; } else { echo 'Upload failed!'; } ?> <form action="" method="post" enctype="multipart/form-data" name="uploadfrm"> <input name="image" type="file" /> <input name="uploadbtn" value="Upload" type="submit" /> </form>
-
Not much, consistent indenting will lead to cleaner code, and code that is easy to spot errors in. It doesn't take long to do, and even less if you do it while you are coding. <?php mysql_connect ("localhost", "","") or die (mysql_error()); mysql_select_db (""); $search = mysql_real_escape_string(preg_replace('/[^\w\'\"\@\-\.\,\(\) ]/i', '', $_POST['search'])); if(strlen($search) < 3) { echo "<br /><input type='image' value='Back' src='images/min.png' alt='Back' onClick='history.go(-1);return true;'></FORM>"; } //close if else { $sql = mysql_query("SELECT * FROM apartments WHERE contact LIKE '%$search%' OR phone LIKE '%$search%' OR office LIKE '%$search%' OR town LIKE '%$search%' OR cross_streets LIKE '%$search%' OR description LIKE '%$search%' OR email LIKE '%$search%' OR rent LIKE '%$search%' order by `date_created`"); if ( mysql_num_rows($sql) > 0 ) { echo "<strong style='color: #6EBEFB'>Click Headers to Sort</strong>"; echo "<br/><strong style='color: #6EBEFB'>Your Results for: </strong>"; echo htmlentities($_POST['search']); echo "<table border='0' align='center' bgcolor='#6EBEFB' cellpadding='2' bordercolor='#000000' table class='sortable' table id='results'> <tr> <th style='color: #FFF'> Title </th> <th style='color: #FFF'> Rent </th> <th style='color: #FFF'> Bed </th> <th style='color: #FFF'> Bath </th> <th style='color: #FFF'> Contact </th> <th style='color: #FFF'> Office </th> <th style='color: #FFF'> Phone </th> <th style='color: #FFF'> Image </th> </tr>"; while ($row = mysql_fetch_array($sql)) { $image = (!empty($row['imageurl1'])) ? "<img src=\"../user/{$row['imageurl1']}\" width='50'>" : 'No Images'; echo "<tr> <td bgcolor='#FFFFFF' style='color: #000' align='center'> <a href='searchapts/index.php?id=".$row['id']."'>" . $row['title'] . "</a></td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['rent'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['rooms'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['bath'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['contact'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['office'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['phone'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>{$image}</td> </tr>"; } //close while } //close if echo "</table>"; //this needs to be moved above the last bracket, otherwise you could close a table that you haven't opened. } //close else { //there is no clause for this bracket statement. Perhaps an else after the closing bracket for the if(mysql_num_rows()) clause. echo "No Results"; } ?>
-
WAMP(Windows) server, it will automatically configure everything for you. If you are using linux (doubt you are), just look up LAMP(Linux), or the cross platform XAMP (already suggested).
-
Huh? Why would you need to do that?
-
Anything can be faked on the web. You will have to talk with your city,county,state officials, as to what the criteria is that determines those factors. We deal with coding problems here, so I doubt you will get a response on this issue.
-
Darkfreaks told you exactly how and when to do it. If you use the PayPal IPN, then paypal will automatically send a response to the file you designate. After you handle the IPN response (darkfreaks post), then include your database calls where "everything went smoothly".
-
Update Table ONLY if the value has changed
jcbones replied to blackdogupya's topic in PHP Coding Help
If you are using MySQL just pass it, the database will only update if the values are different. It's smart like that. -
<?php $leaveStarts = '2012-03-08'; //starting date; $leaveEnds = '2012-03-13';//ending date; echo 'You have requested ' . hoursOfLeave($leaveStarts,$leaveEnds,7,15,array('Sunday')) . ' hours of leave.'; //function usage, printing to screen. function hoursOfLeave($timeStarts,$timeEnds,$workStarts,$workEnds,$skipDays = array()) { //NOTE: workstarts, and workEnds is 24 hour clock. $hoursPerDay = $workEnds - $workStarts; //how many hours per day does work last. $hours = 0; //start our hour count. $start = strtotime($timeStarts); //cast the start time to a unix timestamp. $end = strtotime($timeEnds); //same for the end time. for($i = $start; $i < $end; $i += 86400) { //set i to the starting timestamp, continue to loop until i is greater than or equal to the end timestamp, adding a full days seconds to i on every loop. if(!empty($skipDays) && in_array(date('l',$i),$skipDays)) { //if there are skip days, and the current timestamp(i) says we are inside of it. continue; //start a new loop cycle (bypass counting the hours of this day). } $hours += $hoursPerDay; //add the hoursPerDay to our hour count. } return $hours; //after we are completely done counting, just return the hours from the function. } ?>
-
That is not the HOURS of leave, that is the DAYS of leave. Which do you want? I have an old function in my library, that I could make work pretty quickly (I think).
-
The name of the input must be an array. INCORRECT: <input name="area" type="text" size="40" class="input" maxlength="50" value="<?php echo $data['area']; ?>"> <input name="area" type="text" size="40" class="input" maxlength="50" value="<?php echo $data['area']; ?>"> <input name="area" type="text" size="40" class="input" maxlength="50" value="<?php echo $data['area']; ?>"> CORRECT: <input name="area[]" type="text" size="40" class="input" maxlength="50" value="<?php echo $data['area'][0]; ?>"> <input name="area[]" type="text" size="40" class="input" maxlength="50" value="<?php echo $data['area'][1]; ?>"> <input name="area[]" type="text" size="40" class="input" maxlength="50" value="<?php echo $data['area'][2]; ?>">
-
Well, file permissions are an important part of servers, as they restrict who can do what with a file (as you have just found out). Being that I am inherently lazy, I'm going to ask that you look here, and if you encounter more questions or get massively confused (it happens), I'll see if I could help. My communications skills have been lacking lately, and I would probably confuse you more than those links, ATM.
-
There is an API for that.
-
When nothing is inputted to a field an error occurs
jcbones replied to frank_solo's topic in PHP Coding Help
Take a minute and look at it. It is misspelled. EMPTY. Blame it on the fat fingers. -
The bolded text tells us that the permissions on that file are not set to allow the server to write to it. You will have to change the permissions on the file to allow it to work. I would start with 644.
-
When nothing is inputted to a field an error occurs
jcbones replied to frank_solo's topic in PHP Coding Help
Your query syntax is wrong, Consider the following, I commented the changes I made. <?php if ($_SERVER['REQUEST_METHOD'] == 'POST'){ //if data was posted. $dbase = mysql_connect ( 'localhost', '', '' ); //database connection. mysql_select_db ( '', $dbase ); //database selection. if(!empty($_POST['county'])){ //if county is not empty. $county = mysql_real_escape_string($_POST['county']); //escape the string. $query[] = "county = '$county'"; //save the valid column name and value to a array index. } if(!empty($_POST['type'])) { //if type is not empty. $rooms = mysql_real_escape_string($_POST['type']); //escape the string. $query[] = "rooms = '$rooms'"; //save the valid column name and value to an array index. } if(!empty($_POST['rent_min']) && !empty($_POST['rent_max'])) { //if the rent_min AND the rent_max is not emtpy. $min = (int)$_POST['rent_min']; //rent min to an integer. $max = (int)$_POST['rent_max']; //rent max to an integer. $query[] = "(rent BETWEEN $min AND $max)"; //save to a valid column name and check for anything between these two values. } elseif(!emtpy($_POST['rent_min'])) { //if only rent min is filled out. $min = (int)$_POST['rent_min']; $query[] = "rent >= $min"; //just check for a values that are greater than or equal to this value. } elseif(!empty($_POST['rent_max'])) { $max = (int)$_POST['rent_max']; $query[] = "rent <= $max"; //same here opposite way. } } $sql = "SELECT * FROM `apartments` "; //start our query string. if(isset($query) && is_array($query)) { //$query will only be set if there is a POST to the page, $query will only be an array, if something was filled out. $sql .= 'WHERE ' . implode(' AND ',$query); //add a where clause, and populate with the $query array, joining together on ' AND '. } $sql .= "order by `date_created` DESC"; //end the sql with our order by clause. $res = mysql_query($sql, $dbase) or trigger_error($sql . ' has encountered an errror<br /> ' . mysql_error()); //NOTHIGN BELOW THIS LINE WAS CHANGED> if ( mysql_num_rows($res) > 0 ) { echo "<strong>Click Headers to Sort</strong>"; echo "<table border='0' align='center' bgcolor='#999969' cellpadding='3' bordercolor='#000000' table class='sortable' table id='results'> <tr> <th> Title </th> <th> Borough </th> <th> Town </th> <th> Phone </th> <th> Rooms </th> <th> Bath </th> <th> Fees </th> <th> Rent </th> </tr>"; while($row = mysql_fetch_assoc($res)) { echo "<tr> <td bgcolor='#FFFFFF' style='color: #000' align='center'> <a href='classified/searchapts/index.php?id=".$row['id']."'>" . $row['title'] . "</a></td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['county'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['town'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['phone'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['rooms'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['bath'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['feeornofee'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['rent'] . "</td> </tr>"; } echo "</table>"; print_r($apts); } else { echo "<p> </p><p> </p> No Results <br /><p> </p><FORM><INPUT TYPE='button' VALUE='Go Back' onClick='history.go(-1);return true;'></FORM> and Refine Your Search <p> </p><p> </p>"; } ?> -
I was trying to use $i, I see that didn't work, and yes, I missed that comma. Didn't notice it until you pointed it out.
-
What about, (keeping your same format): <?php if ($count_school_update_likes > '0') { $likers = ''; if ($count_school_update_liked == "1") { $likers[] = 'You'; } if ($count_school_update_likes > '1') { $i = 0; foreach ($get_school_update_likes->result_array() as $liker) { $likers[] = '<a id="' . $liker['user_id'] . '" href="' . $liker['user_id'] . '">' . $liker['user_name'] . '</a>, '; $i++; if ($i == 2) { $count_school_update_likes = $count_school_update_likes - 3; if ($count_school_update_likes > "0") { $likers []= ' and <a id="stream-updates-item-likes-view" href="#">' . $count_school_update_likes . ' others</a> '; } break; } } } $last_likers = (isset($i) && $i > 1) ? ' and ' . array_pop($likers) : NULL; $likerstring = implode(', ',$likers) . $last_likers . ' like this.'; echo $likerstring; }
-
The only whois utils class I can find has utils::showHTML() returning a string. I'm betting that the utils class you have does the same, or outputs an object. If you could post the method utils::showHTML(), it would clear up a lot of questions.