|
how to status active inactive with ajax
|
|
|
|
|
My SELECT query works fine when I've got records. Whether there are no records, or not in the result set I get a warning
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given I've tested the result agains
FALSE, NULL, null (both null and NULL seem to be used in examples and the manual)and calling
is_null($result) but I don't pick it up. Why? I just want to be able to differ between technical failure and return of zero records.
$query = 'SELECT CommentId, ParentId, Subject, Name, DATE_FORMAT(TimeStamp,"%k::%i %d-%m-%Y (GMT)"), Comment FROM commentdata WHERE ArticleId = ' . $ArticleId . ' ORDER BY COALESCE ( ParentId, CommentId)';
$result = mysqli_query($connect, $query);
if(TRUE == $result)
{
echo 'TRUE returned on query for data: ' . mysqli_error($connect) . '<br/>';
}
if(FALSE == $result)
{
echo 'FALSE returned on query for data: ' . mysqli_error($connect) . '<br/>';
mysqli_close($connect);
die("Connection closed after FALSE returned on query for data: " . mysqli_error($connect));
}
if(NULL == $result))
{
echo 'NULL returned on query for data: ' . mysqli_error($connect) . '<br/>';
mysqli_close($connect);
die("Connection closed after NULL returned on query for data: " . mysqli_error($connect));
}
if(null == $result))
{
echo 'null returned on query for data: ' . mysqli_error($connect) . '<br/>';
mysqli_close($connect);
die("Connection closed after null returned on query for data: " . mysqli_error($connect));
}
if(is_null($result))
{
echo 'NULL returned on query for data: ' . mysqli_error($connect) . '<br/>';
mysqli_close($connect);
die("Connection closed after NULL returned on query for data: " . mysqli_error($connect));
}
$rowcount = mysqli_num_rows($result);
modified 10-Sep-13 10:03am.
|
|
|
|
|
Hello Sir.
I am trying to convert the MYSQL data into XML using the following code :
\n";
$output .="<tables>\n";
// iterate over each table and return the fields for each table
foreach ( $tables as $table ) {
$output .= "\n";
$result_fld = mysql_query( "SHOW FIELDS FROM ".$table, $dbhandle );
while( $row1 = mysql_fetch_row($result_fld) ) {
$output .= "<field name="\"$row1[0]\"" type="\"$row1[1]\"";
$output" .="($row1[3]" =="PRI" )="" ?="" "="" primary_key="\"yes\"">\n" : " />\n";
}
$output .= "\n";
}
$output .="\n";
// tell the browser what kind of file is come in
header("Content-type: xml");
echo $output;
$handle = fopen("MyXML.xml", "w") or die("unable to create file");
file_put_contents("MyXML.xml", $output);
fclose($handle);
// close the connection
mysql_close($dbhandle);
?>
Sir , I have 2 questions :
how can i update the code in order to show the content of the data in MYSQL ? This code is only showing the table and fields name and the fields types.
How i can update the code in order to show the foreign key and relation between tables ?
It is Showing only the primary key .
Help Please.
Thank you
|
|
|
|
|
I need to pass client credentials into a .asmx webservice and return data using php. How do I input/read from this xml file?
POST /Topblah.asmx HTTP/1.1
Host: client.blah.co.za
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.blah.co.za/CheckClient"
="1.0"="utf-8"
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CheckClient xmlns="http://www.blah.co.za/">
<PolicyNr>string</PolicyNr>
<IDNumber>string</IDNumber>
</CheckClient>
</soap:Body>
</soap:Envelope>
|
|
|
|
|
i want to initialize a php session variable when user clicks on a link, using a php function or any other way.
for example
<a href="http://bytes.com/submit/g/#" onclick="phpfunction()"> link</a>
|
|
|
|
|
u can use ajax.
u must create a function in your javascript code that send ajax request to your php file and get response from that.
function getXMLHttpRequest()
{
if (window.XMLHttpRequest) {
return new window.XMLHttpRequest;
}
else {
try {
return new ActiveXObject("MSXML2.XMLHTTP.3.0");
}
catch(ex) {
return null;
}
}
}
function do_somting(){
xhr= getXMLHttpRequest();
xhr.onreadystatechange=function()
{
if(xhr.readyState==4 && xhr.status==200)
{
}
}
xhr.open("GET","file.php",true);
xhr.send(null);
}
and in php file that contains php functions.
<?php
your php code's goes here
echo result;//=responseText in js file
?>
|
|
|
|
|
|
Ok, so I'm relatively new to web programming, so hopefully this is not a stupid question and hope someone can help.
I'm using the Bootstrap framework for design and have a contact form. From the contact form the action goes to "process.php" which then adds a user to my database and sends me a contact email.
Anyway, before I get to that stage, I'm looking for some simple error validation, such as if the name, email and message fields are blank then highlight the textbox and show a message underneath stating as such. This seems like a really simple concept, but pretty much everything I've seen online using "die" which isnt what I'm after or redirects to a thankyou or error page, again, which isnt what i'm after.
So, can someone point me in the right direction or give me some tips?
Many thanks.
|
|
|
|
|
Look up JavaScript Validation. You want to do the checks on the client side before the form is submitted.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
New HTML5 inputs have for an example a type of "email" along with the "required" attribute which will do some basic validation automatically. Check out this link []
vbmike
|
|
|
|
|
thanks man, thats exactly what i did in the end.
|
|
|
|
|
Greetings
I am using PHP to read the contents of a log file. I am trying to find all occurrences of a string (with spaces) in this file. I understand reading the entire file is inefficient, but its the only to grab the log data.
Log output (/sda1/user/dns/log/dnsmasq.log):
Jul 5 11:28:25 dnsmasq[22873]: reply 1.courier-push-apple.com.akadns.net is xx.xxx.xx.xxx
Using PHP I am trying to count the number of occurrences the string 'Jul 5' appears in the file.
Depending on how I open the file (to a string) I can use
$instances = substr_count($string, 'Jul 5 ');
However, the space between Jul and 5 seems to be causing some problems. If I just search for 'Jul' it works, but returns 0 on 'Jul 5'.
I have also tried:
$today = date("M j");
$file = file('/sda1/user/dns/log/dnsmasq.log');
$occurrences = preg_match_all('/'.$today.'/', $file);
This works, but reading from a file does not.
$getText = 'Jul 5 is todays dataJul 5 is today today is Jul 5';
$occurrences = substr_count($getText, $today);
echo $occurrences;
Any help getting PHP to find all occurrences of a string with spaces from a file would be greatly appreciated.
|
|
|
|
|
I'm not familiar with that log file, but my guess is that there are multiple spaces or tab characters.
Try using a regular expression that will match any white space: /Jul\s+5/
|
|
|
|
|
Thanks. That seems to be working now.
|
|
|
|
|
If I have this entry in my log file
Quote: Jul 10 10:32:04 dnsmasq[29137]: query[A] RASPBERRYPI.domain.actdsltmp from 192.168.1.106
I can use this code to find how many entries I have for the current month and day
$queries = preg_match_all(" /".$cur_month."\s+".$cur_day_nf ."/", $getText);
If I wanted to take this a step further and find all occurrences of an entry with a specified IP and matching string... example:
find all occurrences where ip = 192.168.1.106 and query = A return month, day and domain.
Jul 17 10:32:04 dnsmasq[29137]: query[A] RASPBERRYPI.domain.actdsltmp from 192.168.1.106
This example will only return an exact match... and not all entries have query[A]
<?php
# URL that generated this code:
# http:
$getText = file_get_contents("/sda1/user/dns/log/dnsmasq.log", true);
$re1='((?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Sept|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?))'; # Month 1
$re2='.*?'; # Non-greedy match on filler
$re3='((?:(?:[0-2]?\\d{1})|(?:[3][01]{1})))(?![\\d])'; # Day 1
$re4='.*?'; # Non-greedy match on filler
$re5='\\[.*?\\]'; # Uninteresting: sbraces
$re6='.*?'; # Non-greedy match on filler
$re7='(\\[.*?\\])'; # Square Braces 1
$re8='.*?'; # Non-greedy match on filler
$re9='(192\\.168\\.1\\.106)'; # IPv4 IP Address 1
if ($c=preg_match_all ("/".$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8.$re9."/is", $getText, $matches))
{
$month1=$matches[1][0];
$day1=$matches[2][0];
$sbraces1=$matches[3][0];
$ipaddress1=$matches[4][0];
print "($month1) ($day1) ($sbraces1) ($ipaddress1) \n";
}
#-----
# Paste the code into a new php file. Then in Unix:
# $ php x.php
#-----
?>
Any additional help is greatly appreciated.
|
|
|
|
|
echo
echo
==============================
Nothing to say.
|
|
|
|
|
what do you want?
Help people,so poeple can help you.
|
|
|
|
|
I'm hoping the Code Project community can help where other forums have been unable to!
I am attempting to have my code count how many top level menu items there are and then determine what position each menu item is in. So, if it is the first, it will append the class of that item to "first" and if it is the last, it will append the class to "last."
I did the same thing with other variables and it worked. For example, I have the code set to append the class to "parent" if there are subitems and also "active" if it is the current link. However, I am running into difficulty with first/last. I've been through several attempts. My first incarnation was:
<?php
class MenuDefault extends Menu {
public function process($module, $element) {
self::_process($module, $element->first('ul:first'));
return $element;
}
protected static function _process($module, $element, $level = 0) {
if ($level == 0) {
$element->attr('class', 'menu '.$module->menu_style);
} else {
$element->addClass('level'.($level + 1));
}
foreach ($element->children('li') as $li) {
if ($active = $li->attr('data-menu-active')) {
$active = $active == 2 ? ' active current' : ' active';
}
$ul = $li->children('ul');
$parent = $ul->length ? ' parent' : null;
$lis = $element->children("li");
for($forl=0,$imax=$lis;
$forl<$imax;$forl++){
if ($forl==0) $position_n = 'first';
elseif ($forl==$imax-1) $position_n = 'last';
else $position_n = null;}
$li->attr('class', sprintf('level%d item%s '. $position_n .$parent.$active, $level + 1, $li->attr('data-id')));
foreach ($li->children('a,span') as $child) {
$title = $child->first('span:first');
$subtitle = $title ? explode('||', $title->text()) : array();
if (count($subtitle) == 2) {
$li->addClass('hassubtitle');
$title->html(sprintf('%s%s', trim($subtitle[0]), trim($subtitle[1])));
}
if ($image = $li->attr('data-menu-image')) {
$title->prepend(sprintf(' ', $image));
}
$child->addClass(sprintf('level%d'.$parent.$active, $level + 1));
}
if ($ul->length) {
self::_process($module, $ul->item(0), $level + 1);
}
}
}
}
However, that generated "first" for every menu item. See below for example:
<ul class="menu menu-dropdown">
<li class="level1 item24 first">...Subcode...</li>
<li class="level1 item22 first parent">...Subcode...</li>
<li class="level1 item23 first active current">...Subcode...</li>
<li class="level1 item20 first">...Subcode...</li>
<li class="level1 item19 first">...Subcode...</li>
</ul>
What I wanted was:
<ul class="menu menu-dropdown">
<li class="level1 item24 first">...Subcode...</li>
<li class="level1 item22 parent">...Subcode...</li>
<li class="level1 item23 active current">...Subcode...</li>
<li class="level1 item20">...Subcode...</li>
<li class="level1 item19 last">...Subcode...</li>
</ul>
Then in another forum, it was suggested to me that " Your basic logic for determining first and last is correct, but you should not add a new loop to do it; instead you need to make it part of the loop that is already looping over the li's (ie: the foreach loop at the top of the snippet I posted). Because of the use of the foreach statement, you need to do a little extra work in order to obtain numerically useful index values.
$children_elements = array_values($element->children('li')); [/U]
$last_child_index = count($children_elements)-1;
foreach($children_elements as $child_index => $li) {
if ($forl==0) $position_n = 'first';
elseif ($forl==$imax-1) $position_n = 'last';
else $position_n = null;}
That brought a bunch of errors
Warning: array_values() [
function.array-values
]: The argument should be an array in ... on line 59
Warning: Invalid argument supplied for foreach() in ... on line 61
Warning: array_values() [
function.array-values
]: The argument should be an array in ... on line 59
Warning: Invalid argument supplied for foreach() in ... on line 61
Warning: array_values() [
function.array-values
]: The argument should be an array in ... on line 59
Warning: Invalid argument supplied for foreach() in ... on line 61
Warning: array_values() [
function.array-values
]: The argument should be an array in ... on line 59
Warning: Invalid argument supplied for foreach() in ... on line 61
Warning: array_values() [
function.array-values
]: The argument should be an array in ... on line 59
Warning: Invalid argument supplied for foreach() in ... on line 61
Warning: array_values() [
function.array-values
]: The argument should be an array in ... on line 59
Warning: Invalid argument supplied for foreach() in ... on line 61
Warning: array_values() [
function.array-values
]: The argument should be an array in ... on line 59
Line 59 being $children_elements = array_value($element->children('li'));
So it seemed like $children_elements was either empty or not an array so I tested with this:
if(empty($children_elements)) {
echo hi;
}
Hi was generated. So it seems empty.
Sorry if this was long but I had no idea how to explain quicker. Please help. I'm stumped and if I can't get this working, a large portion of my time will go to waste as I'll have to scrap the theme design completely.
Thanks in advance.
|
|
|
|
|
I couldn't figure it out except I knew that there must be some native wordpress functionality I could use with wp_nav_menu so I created this code and it works well to have wordpress count and mark first/last (excluding child items for last) with an added function and filter.
Seems to work well. Here it is for anyone else with a similar problem:
function nb_first_last_menu_class( $objects, $args ) {
$ids = array();
$parent_ids = array();
$top_ids = array();
foreach ( $objects as $i => $object ) {
if ( 0 == $object->menu_item_parent ) {
$top_ids[$i] = $object;
continue;
}
if ( ! in_array( $object->menu_item_parent, $ids ) ) {
$objects[$i]->classes[] = '';
$ids[] = $object->menu_item_parent;
}
if ( in_array( '', $object->classes ) )
continue;
$parent_ids[$i] = $object->menu_item_parent;
}
$sanitized_parent_ids = array_unique( array_reverse( $parent_ids, true ) );
foreach ( $sanitized_parent_ids as $i => $id )
$objects[$i]->classes[] = 'last';
$objects[1]->classes[] = 'first';
$objects[end( array_keys( $top_ids ) )]->classes[] = 'last';
return $objects;
}
add_filter( 'wp_nav_menu_objects', 'nb_first_last_menu_class', 10, 2 );
|
|
|
|
|
Hello to all,
I'm new to this forum and a few days ago I started to learn web design.
I have a porjet to start in September and I am looking to make effective technical.
I have to send daily sms to customers and I diffenrents around 25,000 customers each with 25,000 different phone numbers and different addresses.
My socui is to do all this from a website.
I want to send emails to smss and internet party.
I will create a database and sales agents will charge to send the data by group. Chauqe day I have to meet about 20 000 people.
So my problem is what solution I need? I mean how to make it be effective?
- I want my system to be independent, I do not want to depend on a GSM operator here, it will not be possible given the daily flow and no operator still offers unlimited sms offers here (I am in West Africa ).
- I would like for example to specify the sender according to the groups of my clients.
I am ready to buy equipment, I made a few searches on the net and I saw devices like sms gateway but I do not know how these devices work.
Is it possible to do this with php? and be totally independent?
Is there a solution where I can use the services of an operator in Europe or Canada or state States?
I want my system to be truly independent as far as possible.
What equipment do I need?
How to proceed?
I hope I have your good detailed answers.
|
|
|
|
|
Hello !
I don't know if you are looking for this:
A gesture system to manage your customers.
You can do this with php, mysql and a cronjob (to execute functions when you want)
I think that I can create this system for you, please send me a email: herlon214@gmail.com to talk about.
Thank you !
Forgive my bad english.
|
|
|
|
|
Can anyone suggest me a video gallery plugin for my wordpress site. I am not able get a good video gallery for my site.
|
|
|
|
|
You can use Wordpress Pods FrameWork by Scott-Clark. Basically you need to create custom post types using the plugin and then in your gallery template page, call up the videos and render them as you wish using css.
In the admin, users will have a dedicated custom post type (videos), which will allow them to upload or delete videos on the website.
|
|
|
|
|
I need to store an image into mysql database, but image is QR Code:
Can you help me please?!
|
|
|
|
|
Hello,
When it comes to storing an image into database, it really doesn't matter whether it's a QR Code Image or a photograph. Please have a look at this tutorial.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|