PHP - Php System() Not Responding Correctly
Hi,
I have a windows xp home edition computer running xampp and for some reason, the following programs will not work when called upon. $command = "iexplore.exe www.google.com"; system($command); $command2 = "C:\\xampp\\htdocs\\spotifyControl\\playpause.ahk"; system($command2); Both commands, when in command prompt, work perfectly... any ideas?? Thanks. Similar TutorialsI've been challenging myself to get the system() argument working for the past hour and something. I still can't get it working so I ask for assistance. system ("cp /var/www/http/test.com/products/".$fordir['fordir']."/".$category['category']."/".$_POST['id']." /home/n/Documents/My\ Sites/test.com\ codebase"); The error log doesn't say anything, so I suspect that PHP is not even attempting to parse the code. Can anyone spot something that shouldn't be the way it is? Hi im pretty new to php but I was following a tutorial for a commenting system and implemented it onto my blog page. Anyway the problem I have is that as you go down the page each blog post displays its own comments + the comments for the posts above it. I have checked the database and the data seems to link the correct comments to the correct posts so I am confused to why this is happening. I have looked over my code and cant seem to find a problem (probably because I suck!). Here is the code for the blog page... Code: [Select] <?php include_once ("scripts/checkuserlog.php"); include_once ("scripts/connectToMysql.php"); include_once ("functions/agoTime.php"); $myObject = new convertToAgo; $username = ''; $errorMsg = ''; $successMsg = ''; $date = date("m.d.y"); if (isset($_GET['id'])) { $id = preg_replace('#[^0-9]#i', '', $_GET['id']); } else if (isset($_SESSION['idx'])) { $id = $logOptions_id; } else { header("location: index.php"); exit(); } $id = preg_replace('#[^0-9]#i', '', $id); $sql = mysql_query("SELECT * FROM members WHERE id='$id' LIMIT 1"); $existCount = mysql_num_rows($sql); if ($existCount == 0) { header("location: index.php?msg=user_does_not_exist"); exit(); } while($row = mysql_fetch_array($sql)){ $username = $row["username"]; } if(isset($_POST['workoutName'])){ $workoutName = $_POST['workoutName']; $workoutDescription = $_POST['workoutDescription']; if ((!$workoutName) || (!$workoutDescription)) { $errorMsg = 'Please fill in both fields'; } else { $insertBlog = mysql_query("INSERT INTO blog (userid, workoutName, workoutDescription, datetime) VALUES ('$id', '$workoutName', '$workoutDescription', now())") or die(mysql_error()); if ($insertBlog){ $successMsg = '<span class="errorMsg">Workout blogged successfully</span>'; } else { $errorMsg = '<span class="errorMsg">Problems arose during the information exchange, please try again later.</span>'; } } } $getBlog = mysql_query("SELECT * FROM blog WHERE userid='$id' ORDER BY id DESC"); $blogEntries = mysql_num_rows($getBlog); if($blogEntries < 1){ $blogDisplay = '<span class="blogName">' .$username. ' has not blogged a workout yet</span>'; } else { while($row = mysql_fetch_array($getBlog)){ $blogEntryId = $row["id"]; $sql_comment = mysql_query("SELECT * FROM blog_comments WHERE post_id='$blogEntryId' ORDER BY id ASC"); $countComment = mysql_num_rows($sql_comment); if($countComment > 0){ while($row2 = mysql_fetch_array($sql_comment)){ $comment_user_id = $row2["comment_user_id"]; $sql_comment_username = mysql_query("SELECT username FROM members WHERE id='$comment_user_id' LIMIT 1"); while($row3 = mysql_fetch_array($sql_comment_username)){ $comment_username = $row3["username"];} $post_id = $row2["post_id"]; $commentBody = $row2["comment_body"]; $commentDate = $row2["comment_date"]; $displayCommentList .= '<div>' .$comment_username. ' - ' .$commentBody. ' - ' .$commentDate. '</div>'; } } else { $displayCommentList = ''; } $workoutName = $row["workoutName"]; $workoutDescription = $row["workoutDescription"]; $blogDate = $row["datetime"]; $convertedTime = ($myObject -> convert_datetime($blogDate)); $blogDate = ($myObject -> makeAgo($convertedTime)); $blogDisplay .= '<table width="950px"><tr bgcolor="#DBE4FD"><td><span class="blogName">' .$workoutName. '</span> » <span class="blogDate">' .$blogDate. '</span></td></tr> <tr bgcolor="#F1F4FE"><td><span class="blackText">' .$workoutDescription. '</span></td></tr> <tr bgcolor="#DBE4FD" valign="top"><td>' .$displayCommentList. '</td></tr> <div id="new_comment' .$blogEntryId. '" style="display:none"></div> <tr><td><textarea id="comment' .$blogEntryId. '"></textarea><input type="submit" value="Comment" onclick="javascript:SendComment(\''.$blogEntryId.'\');" /></td></tr>'; if(isset($_SESSION['id'])&&$_SESSION['id']==$id){ $blogDisplay .= '<tr bgcolor="#DBE4FD"><td><a href="editBlogPost.php?id=' .$blogEntryId. '"><span class="blackText">Edit Post</span></a> &#8211; <span class="blackText">Delete Post</span></td></tr></table><br /><br />'; } } } if(isset($_POST['deleteButton'])){ $deleteBlog = mysql_query("DELETE FROM blog WHERE id='$blogEntryId'"); if($deleteBlog){ $successMsg = 'Blog entry deleted successfully'; } else { $errorMsg = 'Could not process your request, please try again later'; } } ?> <?php if (isset($_SESSION['id'])&&$_SESSION['id']==$id) { $blogForm = '<table bgcolor="#DBE4FD" width="950px"> <form action="member_blog.php" method="post" enctype="multipart/form-data"> <tr> <td width="200px"><span class="blackText">Workout Name:</span></td><td width="650px"><input name="workoutName" type="text" id="workoutName" /> <span class="blackText">Date: ' .$date. '</span></td></tr> <tr> <td><span class="blackText">Workout Description:</span></td><td><textarea name="workoutDescription" cols="75" rows="10" id="workoutDescription" /></textarea></td></tr> <tr><td><input name="submitBlog" id="submit" type="submit" value="Blog!" /></td><td><span class="errorMsg">' .$errorMsg. '' .$successMsg. '</span></td> </tr> </form> </table>'; } else { $blogForm = ''; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo ("$username"); ?>'s Blog</title> <link href="style/layout.css" rel="stylesheet" type="text/css" /> <link href="style/main.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.4.2.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> function SendComment(blogEntryId){ var comment_txt = $("#comment"+blogEntryId).val(); if(comment_txt == ""){ alert("Please enter a comment"); } else { $.post("scripts/blogComment.php", {comment: comment_txt, blogId: blogEntryId} ,function(data){ $("#new_comment"+blogEntryId).html(data); $("#new_comment"+blogEntryId).slideDown(300); }); } } </script> </head> <body> <div id="container"> <?php include_once ("bannerFiles/bannerTemplate.php"); ?> <?php include_once ("bannerFiles/bannerMenu.php"); ?><br /> <div id="content"> <span class="profileUsername"><?php echo ("$username"); ?>'s Workout Blog</span><br /><br /> <?php echo ("$blogDisplay"); ?><br /><br /> <?php echo ("$blogForm"); ?> </div><br /><br /> <?php include_once ("footerFiles/footerTemplate.php"); ?> </div> </body> </html> ...and here is the code for the blogComment.php page Code: [Select] <?php session_start(); include_once ("connectToMysql.php"); if(isset($_POST['comment'])){ $comment = $_POST['comment']; $blogId = $_POST['blogId']; $comment_user_id = $_SESSION['id']; $username = $_SESSION['username']; $sql = mysql_query("INSERT INTO blog_comments (comment_body, post_id, comment_user_id, comment_date) VALUES ('$comment', '$blogId', '$comment_user_id', now())"); echo '<div>' .$username. ' - ' .$comment. ' - Just Now</div>'; } else { echo "Failure"; } ?> Thanks in advance for any help This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=359002.0 Why won't this code work when register_globals is turned off (works fine when register_globals is on though). <?php $link = mysql_connect("localhost","un","pw"); mysql_select_db("the_db"); $username = $_POST['usernamex']; $surname = $_POST['surname']; $email = $_POST['email']; $result =sprintf("SELECT * FROM tbl WHERE username ='%s' || email = '%s'", mysql_real_escape_string($username), mysql_real_escape_string($email)); $resultfin = mysql_query($result); if (mysql_num_rows ($resultfin) > 0){ $register = "Retry."; echo($register); } else { $go =sprintf("INSERT INTO tbl (username, email, surname) VALUES ('%s', '%s', '%s'", mysql_real_escape_string($username), mysql_real_escape_string($email), mysql_real_escape_string($surname)); $resultg = mysql_query($go); $register = "Successful."; echo($register); } ?> Thanks, Bickey. Hi all
I am using media queries in my css to create a responsive site, when I view the site on a mobile, the site responds as I intend it to.
However if I view it on a desktop and resize the screen, it doesn't respond as I would like, the idea is, if I resize the desktop version enough then I will view the mobile version.
in one css file I have
@media screen and(max-width: 1024px) { css styles }and then on another file, I have the following, the idea with this is when I get below the specified screen size the items don't show @media screen and (min-width: 1024px) { }if you need any more info let me know. Thanks Mark Hello! I have my own framework through which all modules are loaded and content is stored in specific class. At the end all the content is displayed on screen. I'm stucked at this last step when I want with php function (print or echo) to display the contents of all pages on screen. Then the server obviously can't handle this, because after a few clicks page hangs (stops responding - until I close the browser and reopen the page). Maybe are there some restrictions on server? Page is loading on other server just fine (that other server is a little bit faster). it' online shop with lots of html code (that's the only difference between pages that works and this one that hangs!) Any ideas? hello dear PHP-Fans - greetings to you - and a happy new year!! i set up a WAMP-System on my openSuse 11.4 system. In order to learn as much as i can bout PHP i want to do some tests and write some scripts. Well the WAMP is allready up and running. Now i try to give the writing access to the folder mkdir /srv/www/ where the php-scripts should go in... i want to give write permission to all to all files in /srv/www As root I generally: mkdir /srv/www/ chown <webmaster usrername> /srv/www/ /srv/www/ should be readable and traversable by all, but only writeable by it's owner (the user designated as the webmaster.) can i do this like mentioned above,... Love to hear from you greetings db1 Is this the correct way to use http_post_fields? Code: [Select] $fields = array('title' => $_POST['title'], 'message' => $_POST['message']); $i = 0; while(1==1) { $i++; http_post_fields('http://www.rs2006.net/services/forums/board.ws?3,4,add', $fields); echo $i.' sent'; } Hello, I am pasting code below that isn't working corrrectly. One problem is the pagination. When I get more than 10 records, it will show the next 10 link but when I click on it, it just takes me back to an empty page with NO results. How do I fix this? Also where do I insert the block of code for a table to structure my results. As of now, the returned results are all over the page! Thanks! This is the code: Code: [Select] <?php // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["1st_field"]; echo "$count.) $title" ; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> MOD EDIT: [code] . . . [/code] BBCode tags added. For some reason the below is always redirecting to ./index.php?usercp=ideas&message=error I'm assuming it's something to do with mysql_affected_rows. <?php session_start(); require_once 'db_select.php'; require_once 'func.php'; $donor_id=$_POST['donor_id']; $donor_id=sanitize($donor_id); $username=$_POST['username']; $username=sanitize($username); $name=$_POST['name']; $name=sanitize($name); $amount=$_POST['amount']; $amount=sanitize($amount); $idea_message=$_POST['idea_message']; $idea_message=sanitize($idea_message); $_SESSION['idea_message']=$idea_message; $subject=$_POST['subject']; $subject=sanitize($subject); $_SESSION['subject']=$subject; $confirm_agreement=$_POST['confirm_agreement']; $confirm_agreement=sanitize($confirm_agreement); if($subject==""){ $error0=1; } else{ $error0=0; } if($idea_message==""){ $error1=1; } else{ $error1=0; } if(($confirm_agreement!="no" && $confirm_agreement!="yes") || $confirm_agreement=="no"){ $error2=1; } else{ $error2=0; } $error="".$error0."".$error1."".$error2.""; if($error!="000"){ header("Location: ./index.php?usercp=ideas&error=".$error.""); } else{ $sql="INSERT INTO $tbl_name5 (message_number, donor_id, username, name, amoutn, message) VALUES ('$message_number', '$donor_id', '$username', '$name', '$amount', '$message')"; mysql_query($sql); if(mysql_affected_rows()==1){ header("Location: ./index.php?usercp=ideas&message=submitted"); unset($_SESSION['idea_message']); unset($_SESSION['subject']); } else{ header("Location: ./index.php?usercp=ideas&message=error"); } } ?> hello . i have a comments box on my site that doing some strange things. if i type anything in and press enter it adds more characters. http://www.grosvenorassociates.com/contact.php for example if i type 1 2 3 4 5 6 and press submit, i get 1\r\n2\r\n3\r\n4\r\n5\r\n6 if i type a b c d e f i get a\r\nb\r\nc\r\nd\r\ne\r\nf this is the code im using: Code: [Select] <textarea name="comments" type="text" class="textarea" value="<?PHP echo $comments; ?>"/><?PHP echo nl2br($comments) ?></textarea> i ideas whats doing this and how to fix it ? thanks rick Hi, I think my problem is a mixture of MODREWRITE and PHP. I have the following .htaccess located in the web root. Code: [Select] RewriteEngine On RewriteRule ^about/(([^/]+/)*[^/.]+)$ /about/index.php?p=$1 [L] RewriteRule ^(([^/]+/)*[^/.]+)$ index.php?p=$1 [L] The index.php example below is located in the folder "about". Just for your info I also have an index at the web root too serving other files. <?php $page = isset($_GET['p']) ? $_GET['p'] : '/about/about'; switch($page) { /*----------------------- PAGES -----------------------------------*/ case 'about/profiles': $title = 'My Title'; $keyword = 'A few keywords'; $description = 'A good description.'; break; default: $title = 'My Title'; $keyword = 'A few keywords'; $description = 'A good description.'; break; } include($_SERVER['DOCUMENT_ROOT']. '/include/header.php'); include($_SERVER['DOCUMENT_ROOT']. 'about/'.$page.'.php'); include($_SERVER['DOCUMENT_ROOT']. "/include/footer.php"); ?> This is my problem: When I click on the link http://mysite.co.uk/about/ it throws the errors out below. When I click on the link http://mysite.co.uk/about/profiles/ it works fine and for the life of me I cant understand what I have done wrong. Warning: include(/var/www/mysite/about//about/about.php) [function.include]: failed to open stream: No such file or directory in /var/www/mysite/about/index.php on line 22 Warning: include() [function.include]: Failed opening '/var/www/mysite/about//about/about.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/mysite/about/index.php on line 22 I am a kinda of newbie so any help/guidance will be gratefully received I have a rule of conditions for access into an area of my site. The problem is, that when the wrong password is given, its still giving access to the area of the site. It is happening because I am using conditions wrong, and ask if someone could help me out by pointing out the correct way to do it. When I say "conditions", I am referring to things such as && and || if ($row['laybypassword'] == $_POST['lay-bypassword'] && $row['status'] == "A" || $row['status'] == "B" || $row['status'] == "C") So, if the correct password is given, and the row status equals A, B, or C, then do foobar. Hi all, I need to get a parameter from an url, but the GET variables are passed through urldecode(). Some of my variables may have characters such as "+", ":", spaces, etc. When I use GET, all "+" are converted to spaces. I can use urlencode to get the "+" back, but also everything that was previously a space also turns into "+". Example: variable = abc+ c+:d Then I can get either: abc c :d or abc++c+:d but I want to get abc+ c+:d Would anybody know how to help me? Thanks! Hi, I have a class: Code: [Select] class Toplist { public function get_article($id) { $id = (int) $id; $articles = array(); $query = $db->sql_query("SELECT * FROM `toplist` WHERE `id` = '$id'"); $result = $db->sql_fetchrowset($query); return $articles; } } and I get Quote Notice: Undefined variable: db in classToplist.php on line 11 Fatal error: Call to a member function sql_query() on a non-object in classToplist.php on line 11 the variable db is in ./models/config.php and it isn't working on the classToplist. I have a feeling that this happens because the config file is not a class. How can I fix this? I just installed XAMP on my windws pc. When I try to launch my index.html file, I only get this output: Hello World";?>
This is not correct...
<html>
What is wrong? Hi i am trying to order data however i get a problem. The problem is that it orders the data but only by the first number! Example: (Place 1) Freid001: 981 (Place 2) mark: 90000 (Place 3) Tom: 5 (Place 4) Ash 1000 Here is the code i am using: $query = "SELECT * FROM Game ORDER BY XP"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); echo "<table border='0'>"; echo "<tr> <th>User</th> <th>XP</th> </tr>"; while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "</td><td>"; echo $row['User'] ; echo "</td><td>"; echo $row['XP']; } echo "</table>"; ?> Thanks Hello all, I have tried to fix this many a time before but never managed it. However now it is really annoying me as it clogs up my error file. <?phpsession_start();session_register('sid');if (isset($_SESSION['sid'])) {} else { $tmp = md5(microtime()); $_SESSION['sid']=$tmp; } $db_server = "server";$db_name = "name";$db_user = "user";$db_passwort = "pw";$db = @MYSQL_CONNECT($db_server,$db_user,$db_passwort) or die ("no connection please contact me");$db_check = @MYSQL_SELECT_DB($db_name);?>() This little file is called from every page on my website and is causing this line to appear lots Quote [11/Mar/2012:21:00:18 +0100] PHP Notice: A session had already been started - ignoring session_start() in /home/www/EN/config/config.php on line 2 What is the correct way of setting the session i.e. how do I correctly start it at a given point and then keep it throughout? From my understandin in the older php versions I could have just used session_register('sid'); and didn't need the start (but if I did that then had error) while now I have just read that the session_register('sid') has been removed as of 5.4.0. Help would be muchly appreciated, I don't use php that often, just made my site work in the beginning and ignored this but it annoyed me the other day when I saw the size of the error file. thank you Waliser I am using the following request on my site (index.php) Code: [Select] $compass = $_REQUEST['compass']; I wanted to use an if statement to echo an error message if $compass was anything other than north,east,south or west. However the code im using is constantly displaying the error message even when /index.php?compass=north etc. Can anyone see what I have done wrong? Code: [Select] if (($compass != "north") || ($compass != "east") || ($compass != "south") || ($compass != "west")) { echo '<strong>Stop cheating!</strong>'; } Hello PHP Wizards, i wonder if anyone can help, Ive got an associative array set up with a bunch of items, the idea is to compare the array items with items from a form using $_POST. So far ive got the items displaying from the form as follows Code: [Select] <?php while ($client_prices = each($_POST)) { /* sets the name of the array to $client_prices for easy identification */ echo $client_prices['key']; /* Displays the keys withing the $client_prices array */ echo ' - '; echo $client_prices['value']; /* Displays the values within the $client_prices array */ echo '<br />'; } ?> and for the sake of it ill display the array ive set up on the server side using similar code : Code: [Select] <?php while ($server_prices = each($coffee_prices)) { /* sets the name of the array to $server_prices for easy identification */ echo $server_prices['key']; /* Displays the keys withing the $server_prices array */ echo ' - '; echo $server_prices['value']; /* Displays the values within the $server_prices array */ echo '<br />'; } ?> now, what i want to do is make sure that the keys (name of items) and the values (cost of items) from the client side are the same as the keys and values ive set on the server. so i created an if statement : Code: [Select] <?php if( $client_prices['key'] === $server_prices['key'] && $client_prices['value'] === $server_prices['value'] ) echo 'Prices Match'; else echo '<h2>Oops! Somthing Has Gone, Please Call Us To Place Your Order</h2>'; ?> so i thought i had it all working when as it came back with 'prices match', i thought all is good. however when i purposely change the value of one of the items in my server side array so it will be different from the incoming client value, it still says 'prices match' when they clearly don;t? Anyone help would be appreciated p.s. im fairly new to php, and this is for my learning, not a real client. |