jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
Purchased files that are obfuscated means the developer doesn't want anyone monkey'in with their work. You could go back to the purchased place and ask them to do it for you. Adding a class to any file would work, it is tying it into the system, that you have no idea about, that is difficult.
-
That code will submit all request to the database if the strlen of the sms message is less than 5000.
-
How Can i Make a Conditon to get two diffrent Percentage
jcbones replied to allpkresults's topic in PHP Coding Help
<?php function percentage($number,$total) { return round(($number / $total) * 100); } -
If the parameter is NOT a resource, and you are passing it the result of a query, then the query must be returning false, which is boolean. A query returning false means it failed. The first recourse of action for this would be to return the query error using mysql_error. This would tell you that you have a malformed query string, which would lead you to looking up the proper http://dev.mysql.com/doc/refman/5.0/en/select.html'>SELECT syntax for a MySQL query string. You should be using mysqli_error because you should be using mysqli or PDO at this point.
-
Davhill, look into the IPN API, they do have scripts for what you are looking for. You need to focus on, 1. Submitting payment 2. have paypal call a script on your site 3. your script notifies paypal you received the notification, and updates your database at the same time. They do have an example script of that. The number 3 script could also fire off the email. paypal can also return the client to 3 different pages, 1 for payment failed, 1 for payment canceled, and 1 for payment complete. So you can set your lobby for the payment complete. From here, there is thousands of ways you could go, but that should get you started. PS. Please don't grade my writing, I've only been doing it a couple years
-
There is, but the greater question is in your database design. If you have 96 columns in your table, then I suggest that your database isn't normalized. http://http://www.youtube.com/watch?v=BGMwuOtRfqU&list=PL196FE5448948D9B4 <-data logic modeling (9 vids, must watch). The work around is to use backticks (`) around the column name.
-
MVC is great for scalability. In that once you have the main architecture written, adding pages (concepts, data objects) is quick and easy. Not to mention updating the template.
-
How to prevent customer to change price while it is variable ?
jcbones replied to moisesbr's topic in PHP Coding Help
SESSION, or re-pull it from the DB. -
MySQL has a lot of functions dealing with dates and times. So, if you are storing dates and/or times in MySQL, then you should really store them in the proper column types. Date is for storing ONLY date info. DateTime is for storing dates and times, keeping the data as you insert it. Timestamp converts the data to UTC time, then converts it back to your current timezone upon retrieval. Along with all of these functions http://http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html, it makes no sense to store dates in a varchar field.
-
how to get popup after clicking delete link ?
jcbones replied to Pradeep_Chinna's topic in PHP Coding Help
Javascript is like the Mailbox, and PHP is like the Power company. You are asking the Mailbox to keep the lights on. Since Javascript is a client side scripting language, and PHP is a server side scripting language, they don't understand each other. They need something to help them out. In comes the Mail Truck, or HTTP protocol. You must send the relevant data from the client to the server (javascript to PHP), in order to get a proper return. Your link should be: echo ("<td><a href=\"delete.php?number=$row[ID]\" onclick=\"return confirm('Do you really want to DELETE ?');\">Delete</a></td></tr>"); Your delete code should run on delete.php, using proper sanitation and validation on your $_GET parameters. You can use a header() to re-direct back to your listings, or you can use AJAX to push the url to the delete script "behind the scenes". In todays HTML world, the possibilities are nearly endless. HAVE FUN!!! -
It is hard to get css to work on dynamically created classes when you don't know what those classes will be named. If all of the different divisions are going to be styled the same, use a single class name that will work for that purpose.
-
In all honesty, you should be storing dates, datetimes, in either the date, datetime, or timestamp fields.
-
PHP Parse error: syntax error, unexpected $end
jcbones replied to phpnewbieca's topic in PHP Coding Help
Unexpected ends are almost always missing closing braces }. In your case, it is because your heredoc syntax is wrong, in that the closing line must be on it's own line WITH NO WHITESPACE BEFORE it. Which means that the script is seeing everything past $message= <<<EOF as a string. Geany editor caught it in about 2 seconds. -
Why not just get the API http://http://apidocs.mailchimp.com/api/downloads/, then use PHP to push your data to mailchimp?
-
Yes, add to: $pages = ceil($posts_topic/$posts_per_page); Adding this line under it: $pages = ($pages <= 10) ? $pages : 10; This should limit the number of pages to 10 maximum, but if you only have 8, then 8 will be shown.
-
PHP Code - Seems to run a MySQL query twice !?
jcbones replied to djb2002's topic in PHP Coding Help
djb2002, I tried to clean up your script as best as possible. The reason I hate dreamweaver and other WYSIWYG editors is because they often add redundant data that is very confusing when trying to debug your scripts. It is doubly difficult for someone else to do it, as they don't really know how it is suppose to be displayed. This cleanup job removed as much redundant stuff as possible, fully commented the script, and hopefully it will display as you wish it to. But, it may need some tweaks. <?php require_once('Connections/databaseconnect.php'); //include file exit if not found. require('functionformat.php'); //include file, exit if not found. mysql_select_db($database_stemel, $stemel); //select database. /* The following strips out the use of the % and _ wildcard characters, before running the query. */ $pattern = array('/%/','/_/','/!/','/$/','/^/','/{/','/}/','/,/','/=/','/"/','/|/','/:/','/;/'); $replace = array('',''); $search_name = preg_replace($pattern, $replace, $_POST[search_name]); $search_name = mysql_real_escape_string($search_name); //prepare string for database interaction. $unconfirmed_header = 0; //un-used. $confirmed_header = 0;//un-used. $rows_started = 0;//control variable used on line 89 if (strlen($search_name) > 2) { //if the search parameter is longer than 2 characters. /*this block is un-needed UNLESS you want pagination. * *** $maxRows_Recordset1 = 1250; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $stemel) or die(mysql_error()); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; */ //query string. $query_Recordset1 = "SELECT company_number, company_name, url, phone_no, mobile_no, home_no, mob2_no, other_info, confirmed FROM contact1 WHERE (confirmed = '0' OR confirmed = '1') AND (company_name LIKE '%$search_name%' OR other_info LIKE '%$search_name%' OR url LIKE '%$search_name%') ORDER BY confirmed DESC, company_name ASC, company_number ASC"; $Recordset1 = mysql_query($query_Recordset1); //run the query $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); //create variable storing the number of rows of database data returned. } //starting output. ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <?php /* This section passes on received values as hidden fields after validating null entries. */ include ('header.php'); ?> <link rel="stylesheet" href="search.css" type="text/css" /> <?php if (($totalRows_Recordset1) > 0) { //if there are database rows. while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { //get them until there are no more. if(++$rows_started == 1) { //using control to determine if this is the first loop of data. //if this is first loop of data, build the table headers. ?> <table width="100%" align="center" border="0"> <tr> <td><font size="2"> <div class="seperator"></div> <div class="boardcontainer"> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr><td colspan="6" class="catbg" height="18" >Main Database</td></tr> <tr> <td class="windowbg" width="28%" align="center">Company Name</td> <td class="windowbg" width="12%" align="center">Phone No</td> <td class="windowbg" width="12%" align="center">Mobile No</td> <td class="windowbg" width="12%" align="center">Home No</td> <td class="windowbg" width="12%" align="center">Personal Mobile</td> <td class="windowbg" width="24%" align="center">Other Info</td> </tr> <?php if ($row_Recordset1['confirmed'] < 1) { //if this is the first loop of data, and the confirmed returns as 0 (less than 1) then all the data returned is unconfirmed, print out a table cell stating this. ?> <tr> <td class=windowbg2 colspan="6" align=center BGCOLOR=#FFFFCC><B>No confirmed numbers have been found that match the criteria you entered. One or more have been found in the unconfirmed list, and are listed below.</B></td> </tr> <?php } //end confirmed if } // end first loop if $class = ($row_Recordset1['confirmed'] == 1) ? 'windowbg2' : 'windowuv'; //if confirmed is equal to 1, set the class to windowbg2, else it is 0 so set it to windowuv. if ((empty($last_confirmed) || $last_confirmed == 1) && $row_Recordset1['confirmed'] == 0) { //if $last_confirmed is empty(first loop) or is equal to 1 AND the current is equal to 0, then all remaining numbers are unconfirmed //print a column cell stating all numbers below are unconfirmed. ?> <tr> <td class=windowbg2 colspan="6" align=center BGCOLOR=#FFFFCC><B>Unconfirmed Numbers</B></td> </tr> <?php } //end last confirmed if. if (strlen($row_Recordset1['url']) > 2) { //if the url is longer than 2 characters, print a link, otherwise print a string. echo '<td class=' . $class . ' width=28% align=center BGCOLOR=#FFFFCC><a href=http://www.mywebsite.com/external.php?site='.$row_Recordset1['url'].' target="_blank">'.$row_Recordset1['company_name'].'</a></td>'; } else { echo '<td class=' . $class . ' width=28% align=center BGCOLOR=#FFFFCC>'.$row_Recordset1['company_name'].'</a></td>'; } //print out the rest of the row data. echo '<td class=' . $class . ' width=12% align=center BGCOLOR=#FFFFCC>*'.format_phone($row_Recordset1['phone_no']).'</td>'; echo '<td class=' . $class . ' width=12% align=center BGCOLOR=#FFFFCC>*'.format_phone($row_Recordset1['mobile_no']).'</td>'; echo '<td class=' . $class . ' width=12% align=center BGCOLOR=#FFFFCC>*'.format_phone($row_Recordset1['home_no']).'</td>'; echo '<td class=' . $class . ' width=12% align=center BGCOLOR=#FFFFCC>*'.format_phone($row_Recordset1['mob2_no']).'</td>'; echo '<td class=' . $class . ' width=24% align=center BGCOLOR=#FFFFCC>*'.$row_Recordset1['other_info'].'</td></tr>'; $last_confirmed = $row_Recordset1['confirmed']; //set the last confirmd to the current confirmed, so that on the next row we can tell if we have run out of confirmed numbers. } //end while //nothing changed below this line: ?> </tr> </table> </div><br /> <div class="seperator"> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr> <td class="titlebg" align="center" colspan="2"> Info Centre </td> </tr> <td class="windowbg2"> <div style="float: left; width: 59%; text-align: left;"> <span class="small">Please update us with any corrections as soon as possible.</span><br /> </div> <div style="float: left; width: 40%; text-align: left;"> <div class="small" style="float: left; width: 49%;"><span style="color: red;"><b>lllll</b></span></div> </div> </td> </tr> </table> </div> </font></td> </tr> </table> <?php } else { ?> <body bgcolor="#FFFFCC"> <tr><td colspan=10> <center><table border=1 bordercolor=navy cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCCFF"><div class=TableTitle> <p align="center"><b><font face="Tahoma">NO RESULTS FOUND</font></b></div></td></tr><tr><td BGCOLOR=#FFFFCC> <div align="center"> <h3> </h3> </div> <div align="center"> <h3><font face="Tahoma" size="3">Your search didn't match any records.</B></font></h3> <h3> </h3> </div> </td></tr></table></center> </td></tr></table><br> <?php } ?> <br> <?php require ('footer.php'); if (($totalRows_Recordset1) > 0) { mysql_free_result($Recordset1); mysql_close(); }else{ } ?> -
<?php foreach ($_POST as $key => $value) { //for each of the user inputs (form fields). // assign to temporary variable and strip whitespace if not an array $temp = is_array($value) ? $value : trim($value); //if the value is an array, assign it to $temp, otherwise trim all the whitespace from the value, then assign it to $temp. // if empty and required, add to $missing array if (empty($temp) && in_array($key, $required)) { //if $temp is empty AND the current $key is not in the $required array. $missing[] = $key; //assign the current $key to an array named $missing. } elseif (in_array($key, $expected)) { //If non of the above are true, but the current $key is in the $expected array. // otherwise, assign to a variable of the same name as $key ${$key} = $temp; } //assign the $temp variable to a variable of the same name as the current $key (variable variable), which is the same name as your form field name. } //any data passed that isn't in the $required array, nor in the $expected array WILL BE discarded. I tried some clarification.
-
Unexpected end is almost always a missed bracket ( } ). You need to sort through that massive file and make sure all the brackets match. Edit: reedwan_comment
- 1 reply
-
- parse error
- syntax error
-
(and 1 more)
Tagged with:
-
Most of what you are asking about is simple design: For the multi-day events, I would make a div then use css to overlay it over the days. Getting the multi-days to lay underneath single days is just a matter of data ordering.
-
Unable to input data in database - weird problem
jcbones replied to benoit1980's topic in PHP Coding Help
Sure, you started off trying to use mysqli as a object, then jumped to using the procedural functions. Try this: UNTESTED code, so don't overwrite your work. <?php require_once("config.php"); $dat_date = date('Y-m-d H:i:s'); $db = new mysqli("localhost", $username, $password, $db_name); $query = sprintf("INSERT INTO $tbl_name (id, date, phone_number, email, code, recommended, terms, notifications, name, surname, age, city, leader, department) VALUES (NULL, '$dat_date', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', NULL, NULL)", $db->real_escape_string($phone_number), $db->real_escape_string($email), $db->real_escape_string($code), $db->real_escape_string($recommended), $db->real_escape_string($terms), $db->real_escape_string($notifications), $db->real_escape_string($name), $db->real_escape_string($surname), $db->real_escape_string($age), $db->real_escape_string($city), $db->real_escape_string($leader), $db->real_escape_string($department) ); //use sprintf to setup the escaped values into a properly formed sql string. if(!$db->query($query)) { //if the query fails to run. trigger_error($db->error); //show us the error. } if($db->affected_rows != 1){ //if the affected rows does not equal 1, the database didn't add the row. (the database should ONLY EVER return 1 or 0 for this query. echo '<div align="center" class="text-not-correct">You are already already registered!<br></div>'; echo $query; $db->close(); //close the database connection. If we are using the object, keep it in the object, not procedural. }else{ echo 'something'; } ?> -
Unable to input data in database - weird problem
jcbones replied to benoit1980's topic in PHP Coding Help
No his sprintf is called right. The problem is that the OP is trying to run the query two different ways, without understanding the difference. The preferred way with mysqli is to prepare the sql, then bind the parameters, then execute the query, then bind the results, then print the results. This is so that the mysqli class can apply all needed sanitation and validation. If you choose to use the sprintf to write the query string, adding in your own validation and sanitation, then you must use the mysqli::query function. This bypasses all of the sanitation and validation available in the mysqli class, and runs the query straight to the database (much like the old mysql functions). -
I answer homework questions WHEN there has been an effort put forth, and you are stuck on a CODING issue. I'm not going to do it for you. If you are stuck at basic if/else statements, you should hit up the instructor. There is an obvious breakdown in your classroom instruction.
-
No need to encode it, it is already JSON.
-
IIRC, CURRENT_TIMESTAMP in MySQL is set to UTC time. This means that you can set the timezone in MYSQL, and it will return the correct time for the for the timezone set in MySQL. DATE and DATETIME will not do that, but return the same date as was put into MySQL. Note that you may have to use timezone offsets by default, unless the timezones have been loaded. Example mysql_query("SET timezone = '-5:00'"); $result = mysql_query("SELECT `timestamp_column` FROM `table` WHERE 1"); This will only change the timezone for the connection, which closes at the end of the script. I know this isn't what you asked for, but it adds to the discussion.
-
Find successive parent's details recursively in multidimentional array
jcbones replied to jkkenzie's topic in PHP Coding Help
There is a lot of info missing from your logic. Like: 1. How do you know what page you are on? Are you passing the index to the page somehow? 2. Why are you using 3 different arrays, instead of one multi-dem? You can do a recursive search on a single multi-dem to find which array the page is in. 3. Why not store them in a database, with a foreign key, then pull all of the parents from the foreign key?