Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I have a form with PHP validation and also a mysqli query checking for duplicates in the database for mailing address and email address in mysql. It works fine but the customers are adding spaces in the mailing address for example 111 mailing address A V E, 1 1 1 ma iling address A V E etc. and my sql query doesn't see that as an address that's a duplicate. Their alslo adding email address like my@emailaddress.com and m.y@emailaddress.com, m.y.2@emailaddress.com etc to bypass that comparision also. Is there anyway to stop this from happening?
  2. Hi, I had a chat script lying around but wanted to add a login form in case the mxitid wasn't found in the database so I made a few changes to the script to check for records in databases and retrieving the username according the mxit ID. but after I made few changes im getting syntax errors can someone maybe tell me where I made mistakes please. <?php // database connection info $conn = mysql_connect('*******','********','*******') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('************',$conn) or trigger_error("SQL", E_USER_ERROR); $query0 = mysql_query("SELECT username FROM Users WHERE mxitid=$mid", $con); $result = mysql_query($query0); $myrows = mysql_fetch_array($result); if (mysql_num_rows($query0) != 0) { echo "define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); echo "<html><br> <span style="color:red"><b><u>Chat Beta: Errors may apply please send feedback with contact us regarding problems!</u></b></span> </html>"; // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM StringyChat"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 20; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; /* * StringyChat * * Please refer to readme.txt supplied with the StringyChat distribution for information on * installing and configuring. * */ define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); include("chat_code_header.php"); $result = mysql_query("SELECT * FROM ".$ConfigTable, $db); $myrow = mysql_fetch_array($result); $domain_installed = $myrow["domain_installed"]; // The domain StringyChat is installed on $install_url = $myrow["install_url"]; // URL to install dir of StringyChat $name_size = $myrow["name_size"]; // Maximum size of the name $message_size = $myrow["message_size"]; // Maximum message size. Do not exceed 250 as this is the database limit. $line_length = $myrow["line_length"]; // Maximum length of words in a line. Anything above this value will be split. $ShowPostNum = $myrow["show_posts"]; // The number of historic posts to load and display. $email_notification = $myrow["email_notification"]; // Send email to administrator when new posts are made. 0 = No, 1 = Yes $email_notification_to = $myrow["email_notification_to"]; // The email address to send notifications to if ($_SERVER['REQUEST_METHOD'] == "POST" && !empty($_POST['StringyChat_name'])) { $StringyChat_name = $_POST['StringyChat_name']; $StringyChat_message = $_POST['StringyChat_message']; } <div id="StringyChat"> // Check if visitor's IP is banned. If so, do not display the form, // show a banned IP message instead. $name = $myrows["Username"]; if(!isset($name)) { $name = "SYSOP"; } $ip = $_SERVER["REMOTE_ADDR"]; $sql = "SELECT * FROM StringyChat_IPBan WHERE ip=\"$ip\""; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["ip"] == "") { // Checks if IP not found in banned list ?> <html><form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>"> <input type="hidden" name="StringyChat_name" class="StringyChatFrm" value="<?php echo $name ?>" size="20"> <textarea name="StringyChat_message" class="StringyChatFrm" cols="20" rows="1"></textarea> <br> <input name="StringyChat_submit" class="StringyChatFrm" type="submit" value="Post Message"> </form> </html> <? } else { echo "Posting disabled - Your IP has been banned."; } // Should we try to create a post? if (isset($StringyChat_name) && isset($StringyChat_message)) { // Remove whitespaces and slashes. $name = trim(stripslashes($StringyChat_name)); $message = trim(stripslashes($StringyChat_message)); // Check name and message have been entered. if (strlen($name) > 0 && strlen($message) > 0) { // Limit the size of the fields as per variable defnitions. if (strlen($name) > $name_size) { $name = substr($name, 0, $name_size); } if (strlen($message) > $message_size) { $message = substr($message, 0, $message_size); } // Remove new lines from name. $name = str_replace("\n", " ", $name); // Stripping out \r's so email formattnig appears correctly. $message = str_replace("\r", "", $message); // Create an email-friendly version of the message. $message_emailable = str_replace("<br>", "\n", $message); $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db); while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) { $the_word = $myrow_wordswap["word"]; $message_emailable = ereg_replace($the_word, "!*#$%",$message_emailable); } // Replace the new lines with encoded line breaks for HTML (thanks milahu). $message = str_replace("\n", "c#lb", $message); // Use HTML encoding on ame and message so database doesn't misinterpret data. $name = htmlentities($name); $message = htmlentities($message, ENT_COMPAT); // IP address of submitter and time of post. $ip = $_SERVER["REMOTE_ADDR"]; $name = $_SERVER["HTTP_X_MXIT_NICK"]; $msg = $_POST['StringyChat_message']; $post_time = date("U"); $mxitid = $_SERVER["HTTP_X_MXIT_LOGIN"]; if(!isset($mxitid)) { $mxitid = "DEFAULT"; } if(!isset($name)) { $name = "SYSOP"; } // check to see if a duplicate exists $sql = "SELECT * FROM StringyChat WHERE StringyChat_ip=\"$ip\" AND StringyChat_message=\"$msg\" AND StringyChat_time>($post_time - 1800 )"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["StringyChat_message"] == "") { // Checks if record not matching in db // Save the record $sql = "INSERT INTO StringyChat (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time) VALUES (\"$ip\",\"$name\",\"$msg\",$post_time)"; $result = mysql_query($sql); } else { echo "Duplicate post detected<br>"; } } else { echo "<font color=\"red\">You must Type a message</font><br><br>"; } unset($_POST["StringyChat_name"]); unset($_POST["StringyChat_message"]); unset($StringyChat_ip); unset($StringyChat_name); unset($StringyChat_message); unset($StringyChat_time); unset($mxit_id); } // get the info from the db $sql = "SELECT StringyChat_time, StringyChat_name, StringyChat_message FROM StringyChat ORDER BY id DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); function filterBadWords($str) { $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); $replacements = ":-x"; while($row = mysql_fetch_assoc($result1)) { $str = eregi_replace($row['word'], str_repeat(':-x', strlen($row['word'])), $str); } return $str; } // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) //while (($pmsg = $list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) { // echo data //echo ($pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) $admin = array('SYSOP','cobusbo'); if (in_array($list['StringyChat_name'], $admin)) { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<span style="color:red">' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />' . '<p>'; } else { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />' . '<p>'; } } // Load up the last few posts. The number to load is defined by the "ShowPostNum" variable. $result = mysql_query("SELECT * FROM ".$dbTable." ORDER BY StringyChat_time DESC LIMIT " . $ShowPostNum,$db); include("sort_widths.php"); while ($myrow = mysql_fetch_array($result)) { $msg = $myrow["StringyChat_message"]; // Convert the encoded line break into an actual <br> tag (thanks milahu) $msg = str_replace("c#lb", "<br>", $msg); // Convert the encoded image tag into a html tag $msg = eregi_replace("im#([a-z]{3})", "<img src=\"http://".$install_url."images/\\1.gif\" alt=\"emoticon\">",$msg); // split the lines $msg = htmlwrap($msg, $line_length); $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db); while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) { $the_word = $myrow_wordswap["word"]; $msg = ereg_replace($the_word, ":-x",$msg); } } ?> <? // end while /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?><br> <html> <i>Type your Message here...</i>:<br></html> "; } else { <html> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET"> Username:<br> <input type="text" name="username" ><br> <input type="hidden" value="<?php echo $_SERVER['HTTP_X_MXIT_LOGIN']; ?>" name"userid" > <br><br> <input type="submit" value="Submit"> </form> </html> <? $usernames = $_GET['username']; $mid = $_GET['userid']; $sql0 = "INSERT INTO Users (username,mxitid) VALUES (\"$usernames\",\"$mid\")"; $result = mysql_query($sql0); ?> }
  3. I have made a mutual friend system like facebook and it shows all the mutual friends but sometimes it shows it twice because your 2 friends might be friends with one person so it echos the same person twice so i wanna only show the person once and the most repeated should show on the top and the less repeated person should show at bottom!
  4. Hi PHP Freaks. Noobie here. Trying to learn PHP, following lecturesnippets.com PHP lessons. This is lesson 38. This seems like it should be simple, but no matter what I do, I can't get the database to update. Any help would be greatly appreciated. Thanks. Here's my code right now: <html> <head> </head> <body> <?php $con = mysqli_connect("localhost","Eric","******"); if (!$con){ die("Cannot connect:" . mysqli_connect_error()); } mysqli_select_db($con,"snippets"); if (isset($_POST['update'])){ $UpdateQuery = "UPDATE lectures SET Topic = '$_POST', Name='$_POST[name]', Attendance= '$_POST[attendance]' WHERE Topic='$_POST[hidden]'"; mysqli_query($con,$UpdateQuery); }; $sql = "SELECT * FROM lectures"; $myData = mysqli_query($con,$sql); echo "<table border=1> <tr> <th>Topic</th> <th>Name</th> <th>Attendance</th> </tr>"; while($record = mysqli_fetch_array($myData)){ echo"<form action=mydata3.php method=post>"; echo "<tr>"; echo "<td>" . "<input type=text name=topic value=" . $record['Topic'] . "> </td>"; echo "<td>" . "<input type=text name=name value=" . $record['Name'] . "> </td>"; echo "<td>" . "<input type=text name=attendance value=" . $record['Attendance'] . "> </td>"; echo "<td>" . "<input type=hidden name=hidden value=" . $record['Topic'] . "> </td>"; echo "<td>" . "<input type=submit name=submit value=update" . "> </td>"; echo "</form>"; } echo"</table>"; mysqli_close($con); ?> </body> </html>
  5. Hi guys, I am creating a piece of code that blocks a user a for 48 hours after attempting to login 5 times with the wrong password, within a 24hour period. If the user logs in successful within the 24hr and, it should reset the attempt count. The issue I'm having ATM is that with the attempt count, It is only updating the first row of that user, if i attempt more times. Here is an example of whats going on: User - Time - Attempt- count() User 1 10:00pm Attempt 1 (5) User 1 10:02pm Attempt 2 (4) User 1 10:04pm Attempt 3 (3) User 1 10:06pm Attempt 4 (2) User 1 10:07pm Attempt 5 (1) User 2 10:15pm Attempt 1 (2) User 2 10:20pm Attempt 2 (1) As you can see, all the attempts will increment (the numbers in the bracket) but the latest attempt will be set to one. How do I get it so that all the attempts are incremented so it looks like this. User - Time - Attempt- count() User 1 10:00pm Attempt 1 (5) User 1 10:02pm Attempt 2 (5) User 1 10:04pm Attempt 3 (5) User 1 10:06pm Attempt 4 (5) User 1 10:07pm Attempt 5 (5) User 2 10:15pm Attempt 1 (2) User 2 10:20pm Attempt 2 (2) Here is a snippet of my code: if (!$pw_ok) { if (isset($_SERVER["REMOTE_ADDR"])) { $str_RemoteHost = $_SERVER["REMOTE_ADDR"]; } else { $str_RemoteHost = ''; } $qry_WriteToDatabase = " INSERT INTO cms_user_login_attempts ( cula_user_id, cula_date_time, cula_remote_host, cula_attempt_count ) VALUES ( " . $db->SQLString($row->user_id) . ", Now(), " . $db->SQLString($str_RemoteHost, true) . ", 'cula_attempt_count' )"; $db->query($qry_WriteToDatabase); $qry_UpdateCount = " UPDATE cms_user_login_attempts SET cula_attempt_count = cula_attempt_count + 1 WHERE cula_user_id = " . $db->SQLString($row->user_id) . " "; $db->query($qry_UpdateCount); $qry_CheckDatabase = " SELECT CASE WHEN count(*) >= 5 THEN 0 ELSE 1 END as allowed_login FROM cms_user_login_attempts WHERE cula_date_time >= DATE_SUB(CURRENT_TIMESTAMP, interval 48 hour) AND cula_user_id = " . $db->SQLString($row->user_id) . ""; $rs_CheckDatabase = $db->query($qry_CheckDatabase); if (! (isset($qry_CheckDatabase) && $qry_CheckDatabase)) { $errors->defineError("invalid_user_pass", "Too many attempts, account locked for 48hours.", array("username","password")); } }
  6. I have just recently began learning PHP. I have a pretty solid foundation in general programming and PHP. As my first major PHP project I am trying to make myself an autobuyer for Fifa 15 using curt2008 Fifa API. He basically has everything there for me to use and I know that I have enough knowkledge to get a basic autobuyer going if I could just figure out how to log in. I have come to realize that the problem is that I have no idea what he is doing when he connects to the Fifa Web App. He has the code there for me, but I don't know what it is actually doing. I was hoping someone can point me to some documentation, a tutorial, or even exercises so that I may learn more about... logining into a web application? I don't even know what to call it. Looking at connect.php he has a bunch of functions. Login, getSessionID, Phishing, getNucleusID, getShards, and all of them do a bunch a requests and use a bunch of headers. I don't know what this terminology is or how it all works together, but I would like to learn about it. Thats why I wanted to start learning PHP, for stuff like this. I just don't know where to look. Thank You
  7. If you are using Vertabelo for creating database models and you access your database with Propel library, you'll find the following instructions useful. Vertabelo is an online, free tool for visual database design. Once you create a model of your database in Vertabelo, you can generate a Propel schema file from it. To do this you'll have to use VertabeloPropel, a PHP script which converts a Vertabelo XML file into Propel's schema.xml file. The script is available on GitHub. Installing VertabeloPropel uses Composer to manage project dependencies. In your project directory create a file composer.json: { "require": { "vertabelo/vertabelo-propel": "*" } } Then run Composer install. composer install This will download VertabeloPropel into the vendor directory in your project directory. The script will be in vendor/bin/vertabelo-propel.php file or, for Windows, in vendor\bin\vertabelo-propel.php.bat. Using VertabeloPropel script 1. Create a database model with Vertabelo. 2. Download the model as an XML file and save it in your project directory (use an option "Export model as XML file" from Vertabelo's tool bar). 3. Generate Propel's schema.xml file. If you want to use the default settings (input file model.xml, output file schema.xml, database name test, default id method native), run in Windows vendor\bin\vertabelo-propel.php.bat in Mac/Linux vendor/bin/vertabelo-propel.php If you want to change the defaults, run in Windows vendor\bin\vertabelo-propel.php.bat -i model.xml -o schema.xml / --database-name bookshop ---default-id-method native in Mac/Linux vendor/bin/vertabelo-propel.php -i model.xml -o schema.xml --database-name bookshop --default-id-method native 4. The script generates Propel's schema.xml file. 5. Proceed with your normal Propel application development (or see "How to develop a PHP+MySQL application with Propel and Vertabelo"). Script options The script options are: --input-file (shortcut -i) location of Vertabelo XML file (default value "model.xml") --output-file (shortcut -o) location of output Propel schema.xml file (default value "schema.xml") --database-name name of the database (default value "test") --default-id-method database's defaultIdMethod. Allowed values are “native” or “none”, default value is "native". --help prints the help message --------------- The above information was originaly published on Vertabelo's blog.
  8. This is posting to any row in mssql that has a matching 'start_date'. I would like it to post rows where start_date = '$start_date' and it also matches the 'meter_id' . It should perform this check of both parameters before posting to mssql. <?php $session_id = $_SESSION['id']; $comm_id = $_GET['meter_id']; $start_date = $_GET['start_date']; $payment_date = $_POST['payment_date']; $amount_paid = $_POST['amount_paid']; $check_number = $_POST['check_number']; $sql = "UPDATE [radiogates].[dbo].[ops_invoice_history] SET payment_date = '$payment_date', amount_paid = '$amount_paid', check_number = '$check_number' where start_date = '$start_date'"; $query = sqlsrv_query($conn, $sql); Thank you for any help.
  9. So I have a simple query that adds a text record into a MySQL database table. It works great with exception of one thing. I noticed that if I have "&" symbol in my paragraph, the text after that symbol won't be inserted into the table. The text before that symbol will insert fine. It seems to be doing that only with & symbol; other symbols insert and show up fine. can anyone tell me why this is happening?
  10. hello dear PHP-experts i run opensuse 13.2 i ve set up an apache webserver - well - if i type localhost into the browser then i see: it works but i want to see also phpmyadmin: the phpmyadmin on apache server - installed but not visible - what can i do now. I think that i have to check the running services on the machine!!? Which test can be done - with the terminal ? Which tests can i run on commandline ? love to hear from you greetings
  11. Hi, Just wondered if anyone can help? A contact form which has previously worked has stopped working, I presume because the PHP has been upgraded to version 5.6. If anyone is able to advise on how I need to tweak it, it would be massively appreciated! Code below: Thanks, Sarah <? // edit these lines $your_name="Company Name"; $your_email="sarah@companyname.co.uk"; $your_web_site_name="companyname.co.uk"; ?> <?php //If the form is submitted if(isset($_POST['name'])) { //Check to make sure that the name field is not empty if(trim($_POST['name']) === '') { $nameError = 'Please enter your name.'; $hasError = true; } else { $name = trim($_POST['name']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) === '') { $emailError = 'Please enter your email address.'; $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['message']) === '') { $commentError = 'Please enter your message.'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } //If there is no error, send the email if(!isset($hasError)) { $emailTo = $your_email; $subject = 'Contact Form Submission from '.$name; $body = "Name: $name \n\nEmail: $email \n\nPhone: ".trim($_POST['phone'])." \n\nComments: $comments"; $headers = 'From: '.$your_web_site_name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> <?php if(isset($emailSent) == true) { ?> <div class="ok"> <h1>Thanks, <?php echo $name;?></h1> <p>Your email was successfully sent. We will be in touch soon.</p> </div> <?php } ?> <?php if(isset($hasError) ) { ?> <div class="error2">There was an error submitting the form.</div> <?php } ?>
  12. Hi Ive currently developed a script that connects via an API to send a message, and tested it with one user and it works perfectly. But now im bit stuck to send it to multiple users. All my visitors unique IDs are being stored into a file called unique.csv all in 1 column under each other. But what im currently trying to do is to recall the info from the csv and make a contact list to broadcast the message to. The csv file looks like: Here is my current script <?php $f_pointer=fopen("unique.csv","r"); // file pointer while(! feof($f_pointer)){ $ar=fgetcsv($f_pointer); } require_once ('MxitAPI.php'); /* Instantiate the Mxit API */ $key = '****'; $secret = '*****'; $visitor = '****'; $api = new MxitAPI($key, $secret); $api->get_app_token('message/send'); $api->send_message('guniverse', '$ar[0]', '*test message*', 'true'); echo 'Success'; ?>
  13. How to convert following perl scripts to php.... my ( $ServiceSet, $Service ); eval { $ServiceSet = Win32::OLE->GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2")-> ExecQuery("SELECT * FROM Win32_Service WHERE State=\"Running\""); }; unless ($@) { print "\n"; foreach $Service (in $ServiceSet) { print $Service->{Name}, "\n"; if( $Service->{Description} ) { print " $Service->{Description}\n"; } else { print " <No description>\n"; } print " Process ID: ", $Service->{ProcessId}, "\n"; print " Start Mode: ", $Service->{StartMode}, "\n"; print "\n"; } } Above code shows running services from win32_service that i`m taken from http://msdn.microsoft.com/en-us/library/aa394418%28v=vs.85%29.aspx... Please help.. i want to display running services and display it in table form??? Thank You...
  14. I'm trying to make a quiz powered by PHP and jQuery, with all the data (questions, answers, ID's, etc.) stored in a database. My current code attaches a radio button to each answer in a list... <li class="Answer '.$QID.'-'.$Value.' '.$Correct.'" id="'.$QID.'"><label>'.$Value.'. <input name="q'.$QID.'" input data-key="'.$Value.'" type="radio"> '.$QA.'</label></li> Taking a tip from a commercial quiz I saw online, I'd like to remove the radio button (and presumably the form it's a part of, using some CSS to make each answer look something like a button... <li class="Answer '.$QID.'-'.$Value.'" id="'.$QID.'">'.$QA.'</li> However, the commercial quiz is written in JavaScript, which is very hard for me to follow. So I'm trying to create something similar using more PHP (and jQuery). I'm now trying to figure out how to "capture" a value for each question, based on the answer selected by a visitor. For example, let's say someone chose B as the answer to the first question. The ID ($QID) for that question and each associated answer is the numeral 1. The value for $QID-$Value for that particular answer is 1-B. Let's say I create a variable - $Answer1 - to store an ID or value for a user's answer choice for the first question. So, in this case, $Answer1 = '1-B' (if we go with $QID-$Value) or simply 'B' if we just go with $Value. I'm not sure exactly how to capture these values. I don't even know what I should be using - PHP, jQuery or AJAX. Just to get started, all I want to do is give $Answer1 the value for whatever answer the user chooses. So $Answer1 should equal 'B' in this case. Can anyone tell me how to do that, or at least tell me if I should be using PHP, jQuery or AJAX to accomplish it? Thanks.
  15. So while editing my .HTACCESS file I added the proper lines to redirect users that encounter errors like 404 and 500. It works like a charm if I tell it to display a specific message. However if I tell the file to redirect users to a custom error page it fails. When testing out my 404 redirect I get this: Not Found The requested URL /143/test.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80 As you can see it is stating that my ErrorDocument is not found BUT if I type my ErrorDocument URL in I can go to it myself. My .HTACCESS file looks like this: ErrorDocument 400 /error.php ErrorDocument 401 /error.php ErrorDocument 403 /error.php ErrorDocument 404 /error.php ErrorDocument 500 /error.php ErrorDocument 502 /error.php ErrorDocument 504 /error.php # supress php errors php_flag display_startup_errors off php_flag display_errors off php_flag html_errors off # enable PHP error logging php_flag log_errors on php_value error_log PHP_errors.log NOTE: I am using localhost (WAMP). Thanks.
  16. im trying to insert a value in to mysql using an experiment everything works fine after hitting the insert button but the problem arises wen i refresh the page as a empty value gets inserted in to the mysql table wen i refresh it.(pardon my english) this is the index page where i fetch an result from mysql table: <div id="container"> <div class="Container-left"> </div> <div class="container-right"> <form action="1.2.php" method="post"> <textarea height="190px" width="190px" name="text" placeholder="share wats on your mind"></textarea> <br> <input type="submit" name="button" value="Type Here" /> </form> <hr> <?php include '1.2.php'; while ($fetch = mysqli_fetch_array($query1)) { echo 'comment:'.$fetch['post'].'<br/>'; echo '<small>date:'.$fetch['date'].'</small><br/><hr>'; } ?> </div> </div> this is the page where my second code rests: <?php include 'config.php'; error_reporting(E_ALL ^ E_NOTICE); $h= htmlspecialchars($_POST['text']); $p= mysqli_real_escape_string($conn,$h); $sql = "INSERT INTO article (post) VALUES ('$h') "; $sql1="SELECT * FROM article"; $query=mysqli_query($conn, $sql); $query1= mysqli_query($conn, $sql1); if ($_POST['button']){ echo 'inserted'; } else { echo 'not inserted'. mysqli_error($conn); } what should i do to stop value getting inserted in to my table while refreshing the page. pl help and thanks in advance.
  17. I am trying to get data out off a mysql database, by using an php file. But i am not getting any output? Examples.html <html ng-app="countryApp"> <head> <meta charset="utf-8"> <title>Angular.js Example</title> <script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js"></script> <script> var countryApp = angular.module('countryApp', []); countryApp.controller('CountryCtrl', function ($scope, $http){ $http.get('category.php').success(function(data) { $scope.countries = data; }); }); </script> </head> <body ng-controller="CountryCtrl"> <table> <tr ng-repeat="country in countries"> <td>{{country}}</td> </tr> </table> </body> </html> category.php <?php $servername = "localhost:3306"; $username = "root"; $password = "root"; $dbname = "myDB"; $conn = mysqli_connect($servername, $username, $password, $dbname); if(!$conn){ die("Connection failed: " .mysqli_connecet_error()); } $showData = "SELECT id FROM myDB"; $data = array(); $result = mysqli_query($conn, $showData); if(mysqli_num_rows($result) > 0){ while($row = mysqli_fetch_assoc($result)){ $data[] = $row; } } else { echo "0 results"; }; print json_encode($data); mysqli_close($conn); echo($outp); ?>
  18. Basically what I am needing is when a visitor comes to my site and request info on a product, the form sends the product id or name. I have the site set up like product.php?Item=26 and the item number changes based on the product. The page items are being populated with info stored in the mysql databse. I need the email being sent to say something like Basically the "item info" is being pulled from the database. I have asked on different forums and I cannot get a good answer that I can use to make this happen. I might not be explaining it right. Page the form is on is (and all other new-product.php pages) http://www.packagingequipment4sale.com/new-product.php?Item=26 Any help would be greatly appreciated
  19. Hello, First time asking technical question in a forum so I beg pardon for errors. I have a third party blog module installed on opencart. The original coder helped me to fix some bugs, but he is not answering anymore to emails. I would like to add a simple pagination to the "latest articles" part, because at the moment the website display the exact number declared in "article limit" and does not show pagination if articles shown are less than the total. the code from "article_by_type.php" line 85 is the following: /*recent_article*/ if ($setting['article_type']=='recent_article') { $data = array( 'sort' => 'p.date_added', 'order' => 'DESC', 'start' => 0, 'limit' => $article_limit ); $articles = $this->model_news_article->getArticles($data); } another file "article_list.php" at line 88 and 214 already have pagination: $this->data['article_ajax_load'] = $this->getArticle($article_category_id,$page,$limit,$description_limit); $pagination = new Pagination(); $pagination->total = $article_total; $pagination->num_links = 3; $pagination->page = $page; $pagination->limit = $limit; $pagination->text = $this->language->get('text_pagination'); $pagination->url = 'index.php?route=module/article_list/getlist&cpath='.$article_category_id. '&page={page}'.'&limit=' .$limit; $this->data['pagination'] = $pagination->render(); can anyone help add pagination to "article_by_type.php" or adapt the existing pagination code to it ? article_by_type.php article_list.php
  20. hello dear PHP-experts, today i create a rescue-system for the emergency-situation: i am creating a little resque-usb for SUSE-DVD on USB-Stick currently plan to create a litle Rescue-USB while using Suse-ISO DVD on a USB medium 1:1 copied step 1. Suse-ISO download: here: http://ftp5.gwdg.de/pub/linux/suse/opensuse/distribution/13.2/iso/openSUSE-13.2-Rescue-CD-x86_64.iso step 2 copy the file onto a USB stick with the following command dd if=openSUSE-13.2-Rescue-CD-x86_64.iso of=/dev/sdX bs=32kwhere sdX=sdb or sdc is the USB stick ready - now i can test the rescue-usb
  21. Hi, Can anyone recommend some Business Intelligence tools that can be integrated into a PHP (wordpress/joomla) based website? I've had a good look around the net but they all seem to be written in Java/J2EE and appear to be software based - not sure if im after the possible or impossible here... Thanks
  22. I'm going to create a web page with <iframe> tag & want that the src of <iframe> change as value of url in query string changes.i.e. mysite.com/?url=google.com then,src of <iframe> should google.com
  23. Hi! I need to make a little signup form that contains 2 textbox for name and birthday and 2 buttons for submit and export to xml. When the user clicks on the export to xml button, there must be an xml file containing the information entered by the user that can be downloaded. I'm not really familiar to php but can you give me an idea on how to make this possible ? thank you in advance
  24. Here is what I am trying to do. Get from this http://mysite.com/post.php?id=12&title=postname to this http://mysite.com/post/12/postname/ here’s the rewrite rule. Options +FollowSymLinks RewriteEngine On RewriteRule ^post/([a-zA-Z]+)/([0-9]+)/$ post.php?id=$1&title=$2 This is my html link that links to the post.php page. <a href="post.php?id=12&title=postname"> Click here to see the post! </a> It does not change the url. I have also tried it like below and it gives me an internal error. <a href="post/12/postname"> Click here to see the post! </a> Can you see what I have done wrong? Also if the above method for the linking is correct, how do I get the "id" and "title" using the $_GET?
  25. I just want to add a css cass named "active" to my navigation links when its page opened using php. In my website the content have broken into its individual components. And those components are separated, organized, and put back together using one index file. (website bootstrap file) Actually I am modularizing this website using php. My Navigation is something similar to this code - ... <li> <a href="index.php?p=dashboard">Dashboard</a> </li> <li> <a href="index.php?p=page-two">Page Two</a> </li> <li> <a href="index.php?p=page-three">Page Page Three</a> </li> ... This is how my index.php looks like - // Validate what page to show: if (isset($_GET['p'])) { $p = $_GET['p']; } elseif (isset($_POST['p'])) { // Forms $p = $_POST['p']; } else { $p = NULL; } // Determine what page to display: switch ($p) { case 'dashboard': $page = 'dashboard.inc.php'; $page_title = 'Control Panel'; break; case 'page-three': $page = 'page-three.inc.php'; $page_title = 'Page Three'; break; case 'page-two': $page = 'page-two.inc.php'; $page_title = 'Page Two'; break; // Default is to include the main page. default: $page = 'login.inc.php'; $page_title = 'Control Panel Login'; break; } // End of main switch. // Make sure the file exists: if (!file_exists('./modules/' . $page)) { $page = 'login.inc.php'; $page_title = 'Control Panel Login'; } include('./includes/header.html'); include('./modules/' . $page); include('./includes/footer.html'); I tried it something like this - case 'dashboard': $page = 'dashboard.inc.php'; $page_title = 'Control Panel'; $class == ($page == $p) ? 'active' : ''; break; And adding this class to my navigation <li> <a class="<?php echo $class;?>">.... </li> But this is not working for me. hope somebody may help me out. Thank you.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.