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. Please help: I'm trying to figure out what is going on with a custom made PHP contact form on my company's multiple websites. Check it out here: www.TacticalSolar.com This custom form was made by a former employee and USUALLY works great. Validation, spam checking, database connection, etc. But I've discovered a bug. The form does not always actually send the data to us when it says it does! This problem almost always happens in Internet Explorer and Safari browsers. But sometimes that data shows up. This does not effect Firefox or Chrome. I've been looking everywhere, but no idea what is causing this. Thoughts? Ideas? I'm no PHP coder so even obvious places to look are welcome.
  2. Hello Every one Please see my code <?php include ("includes/config.php"); $afurl = $_SERVER['REQUEST_URI']; $afurl = preg_replace('/\/+/', '', $afurl); $afurl = preg_replace('/\;+/', '', $afurl); $afurl = preg_replace('/\&+/', '', $afurl); $afurl = preg_replace('/\#+/', '', $afurl); $afurl = preg_replace('/\|+/', '', $afurl); $afurl = preg_replace('/\@+/', '', $afurl); $afurl = preg_replace('/\%5B+/', '', $afurl); $afurl = preg_replace('/\%5D+/', '', $afurl); $afurl = preg_replace('/\%27+/', '', $afurl); $afurl = preg_replace('/\%C2+/', '', $afurl); $afurl = preg_replace('/\%BB+/', '', $afurl); $afurl = preg_replace('/quot+/', '', $afurl); $afurl = preg_replace('/\%E2+/', '', $afurl); $afurl = preg_replace('/\%80+/', '', $afurl); $afurl = preg_replace('/\%93+/', '', $afurl); $afurl = preg_replace('/\$+/', 'c', $afurl); $afurl = preg_replace('/\"+/', '', $afurl); $afurl = preg_replace('/\?+/', '', $afurl); $afurl = preg_replace('/\.html+/', '', $afurl); $afurl = preg_replace('/\-+/', ' ', $afurl); $queryArray = explode(" ", $afurl); for ($i=0; $i< count($queryArray); $i++) { $keyworddd = mysql_real_escape_string($queryArray[$i]).","; echo $keyworddd; } ?> I Want Set $keyworddd at here: <meta name="keywords" content="$keyworddd"> Can anyone tell me how to do this please?
  3. Hi I'm currently having a problem with my chat script each time I'm trying to insert " or brackets etc... I get the error Here is the lines at line 201 // check to see if a duplicate exists $sql = "SELECT * FROM StringyChat WHERE StringyChat_ip=\"$ip\" AND StringyChat_message=\"$msg\" AND StringyChat_time>($post_time - 30 )"; $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); $theTo = $email_notification_to; $theSubject = "New StringyChat post at ".$domain_installed; $theMessage = "A new StringyChat post has been made.\n\n"; $theMessage .= $name . "\n"; $theMessage .= date("H:i - d/m/y", $post_time) . "\n"; $theMessage .= $message_emailable . "\n\n"; $theMessage .= "Visit ".$domain_installed." to view StringyChat and much more!"; $theHeaders = "From: StringyChat at ".$domain_installed." <".$email_notification_to.">\r\n"; mail($theTo,$theSubject,$theMessage,$theHeaders); } else { echo "<span style='color:#10ce59'>Duplicate post detected!</span><p>"; } } else { echo "<span style='color:#10ce59'>You can't send blanks!</span><br><br>"; } My full script is <?php define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); ?> <html><br> <b><u>Chat Beta:</u></b> <span style="color:#ff0000"><br>Errors may apply please send feedback with contact us regarding problems!</span> <br><a href="page.php">Reload</a> </html> <? // 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); // 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 = $_SERVER["HTTP_X_MXIT_NICK"]; 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 "<span style='color:#10ce59'><u>Dear User, you have been banned from the Chat due to not following the rules. You will need to come back regularly to see if you were unbanned. Until then, goodbye!</u></span>"; } // 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 - 30 )"; $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); $theTo = $email_notification_to; $theSubject = "New StringyChat post at ".$domain_installed; $theMessage = "A new StringyChat post has been made.\n\n"; $theMessage .= $name . "\n"; $theMessage .= date("H:i - d/m/y", $post_time) . "\n"; $theMessage .= $message_emailable . "\n\n"; $theMessage .= "Visit ".$domain_installed." to view StringyChat and much more!"; $theHeaders = "From: StringyChat at ".$domain_installed." <".$email_notification_to.">\r\n"; mail($theTo,$theSubject,$theMessage,$theHeaders); } else { echo "<span style='color:#10ce59'>Duplicate post detected!</span><p>"; } } else { echo "<span style='color:#10ce59'>You can't send blanks!</span><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('cobusbo','Admin+TT'); 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> <span style="color:grey"><i>Type Your Message NOW!</i></span> <p><a href="page.php">Reload</a> | <a href="http://tt.2fh.co">Home</a><br></html> Any help please... If I send normal messages I don't get any errors...
  4. Dear Sir, I am building a small framework and going to check on my local computer by using "XAMPP Server" so i have 2 folder and 5 file the hierarchy is: - inc - config.php (Contains all configuration of website like, Directory Separator, Include Path .. etc.) - autoload.php -classes - Url.php (Class) - Core.php (Class) - index.php when i try to run this application i got following Error: I have also tried to change settings of include_path php.ini changes are following: 1. remove ',;' from include_path 2. try to change to this '\php\PEAR' 3. put ';' in starting og php_include_path my current default setting of php include is: Now what i see after doing the changes in php.ini file. When i add ';' in starting of include_path website seems to work but files locations are changed and file not able to access properly means the URL looks like this, URL: localhost/images/abc.png The proper URL is: Proper URL: localhost/project-name/images/abc.png Kindly tell me what i do to solve this problem Thanks
  5. Hello, I have started a DB for simple web based inventory system, I have only dabbled in PHP before 6 weeks ago, within the last 6 weeks with some help and going through countless tutorials and asking questions when I need. At this time setup an insert, delete and update function for this db and are working perfectly, now what I need to know is there a way to display something like 'in stock' and 'out of stock' using php, based on the value of the quantity in my db next to the item in a table? Example : when the table is generated it will display: | Part number | Description | Stock | (normally Stock would show the quantity of each part, I just wish to |10-1111 | Some info | In Stock | display In or out os stock) |10-1112 | Some Info | Out of Stock | I the only code I have is the tables and just not sure what to do next to get the results I have described above. So I will include the table code I have and see where we can go from there. Or if you have some webs site that I can read through that will be great as well as long as it can give me basic instruction on how to do this. Reminder, I am self taught and still learning. <?php $con = mysqli_connect("localhost","user","pass","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20"); echo "<table border='1'> <tr> <th>ID</th> <th>Part number</th> <th>description</th> <th>location</th> <th>Quantity</th> </tr>"; while ($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['amp20ptid'] . "</td>"; echo "<td>" . $row['partnum'] . "</td>"; echo "<td>" . $row['description'] . "</td>"; echo "<td>" . $row['location'] . "</td>"; echo "<td>" . $row['quantity'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); } ?>
  6. I'm currently running a classified ads site and planning to display my own content from database combined with and external site rss. So here is what i got right now after the db query for the jobs ads (procedural php), while ($row = mysqli_fetch_array($results, MYSQLI_ASSOC)){ echo '<div class="media margin-none"> <a class="pull-left bg-inverse innerAll text-center" href="#"><img src="'.$foto.'" share_alt="" width="100" height="100"></a> <div class="media-body innerAll"> <h4 class="media-heading innerT"> <a href="' . $row['title'] .'-da' . $row['id_ad'] . '" class="text-inverse">'. $remuneracion .' ' . substr(ucfirst(strtolower($row['title'])), 0, 53) . '</a> <small class="pull-right label label-default"><i class="fa fa-fw fa-calendar-o"></i> ' . $row['date_created'] . '</small></h4> <p>' . substr(ucfirst(strtolower($row['description'])), 0, 80) . ' ...</p>'; echo '</div> </div> <div class="col-separator-h"></div>'; } echo pagination($statement,$per_page,$page, $url_filtros, $filtros); ?> it is the while loop that i use to display ads from my database, what could be the best way to display (in this same loop?) other site's rss feed so i can show my content combined with the external rss? Thanks
  7. Hi All I have directory fiole like this my_website/flash/file.html I want to disable redirect to file.html via URL. I have create .htpasswd and create .htaccess in flash folder with this code # the auth block AuthName "Please login." AuthGroupFile /dev/null AuthType Basic AuthUserFile C:/xampp/htdocs/.htpasswd # Here is where we allow/deny Order Deny,Allow Satisfy any Deny from all Require valid-user Allow from env=noauth Satisfy any its Work, people cant redirect via change the URL but it also occurs with valid user via Login Session. How to Set .htaccess file for bypass the .htpasswd via login Session user ? How to solve it? thanks
  8. I want to know how to hit a webpage that is not on your domain. I am doing an AJAX request right now, but receiving the following error in my console: The site I'm trying to hit does this weird cookie thing. I already spoke with their web administrator and he said the first time they access that site, it sets the cookie so they have to refresh in order to see if they can bypass a webpage they are trying to access.. I'm not sure if there is anyway to go about doing this since I can't go the AJAX route. But I don't have the capability of refreshing the user once they go on that page since it's not under my server or whatever. The only thing I could think of was AJAX which is not an option now. <?php include('scripts/config.php'); //Declare Variables $filter = new Filter(); $byPasscode = $filter->getBypassCode(); $openDns = "https://bpb.opendns.com/a/" . $_GET['url']; echo 'Redirecting...'; ?> <html> <head></head> <body> <form method="post" name="bypassForm" id="bypassForm" action="<?php echo $openDns ?>" style="display:none"> <input type="text" size="15" name="textBypassCode" id="textBypassCode" autocomplete="off" value="<?php echo $byPasscode; ?>" /> <input type="password" size="15" name="passwordBypassCode" id="passwordBypassCode" style="display:none;" value="<?php echo $byPasscode; ?>" /> <input type="hidden" name="code" id="bypassCode" value="<?php echo $byPasscode; ?>" /> <input type="submit" value="Continue" /> </form> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript"> //setTimeout(function(){ var textBypassCode = $('#textBypassCode').val(); var passwordBypassCode = $('#passwordBypassCode').val(); var bypassCode = $('#bypassCode').val(); $.ajax({ type: 'POST', url: $('#bypassForm').attr('action'), data: { textBypassCode: textBypassCode, passwordBypassCode: passwordBypassCode, bypassCode: bypassCode } }) .done(function(data) { //$('#bypassForm').submit(); }); //}, 3000); </script> </body> </html> Up above you can see my code. Thanks for any other options that you may think of.
  9. Hello Happy Campers. Wonder if someone can point me in the right direction if it's not too much trouble. I have a script that allows an EU to edit a database entry. The users edits the information and hits submit which then edits the content and it all works spiffingly. My problem however arises when I go to upload a new image. The "Add" function uploads images to a directory and the location is saved in the database. When editing the image however, it unlinks it but it does not allow me to upload a new image. The code is as follows: ini_set('display_errors',1); error_reporting(E_ALL); $conn = mysqli_connect("HOST","DB","PWRD","DBTBL") or die('Cannot Connect to the database'); $i = mysqli_real_escape_string($conn,$_POST['newsid']); $t = mysqli_real_escape_string($conn,$_POST['title']); $st = mysqli_real_escape_string($conn,$_POST['stat']); $sn = mysqli_real_escape_string($conn,$_POST['snip']); $s = mysqli_real_escape_string($conn,$_POST['stry']); $c = mysqli_real_escape_string($conn,$_POST['cap']); $f = $_POST['oldim']; $s = nl2br($s); if(!is_uploaded_file($_FILES['file']['tmp_name'])) { $naquery = "UPDATE news SET newstitle='$t',newssnip='$sn',newsarticle='$s',newsstatus='$st' WHERE newsid=$i"; } else { if ($_FILES['file']['type'] != "image/gif" && $_FILES['file']['type'] != "image/jpeg" && $_FILES['file']['type'] != "image/jpg" && $_FILES['file']['type'] != "image/x-png" && $_FILES['file']['type'] != "image/png") { $naquery = "UPDATE news SET newstitle='$t',newssnip='$sn',newsarticle='$s',newsstatus='$st' WHERE newsid=$i"; } else { $finame = $_FILES["file"]["name"]; $result = move_uploaded_file($_FILES['file']['tmp_name'], "../news/$finame"); if ($result == 1) { $naquery = "UPDATE news SET newstitle='$t',newssnip='$sn',newsarticle='$s',newsimage='$finame' newscaption='$c',newsstatus='$st' WHERE newsid=$i"; $d = "../news/"; unlink("$d$f"); } else { $naquery = "UPDATE news SET newstitle='$t',newssnip='$sn',newsarticle='$s',newsstatus='$st' WHERE newsid=$i"; } } } $result = mysqli_query($conn, $naquery); if($result){ header('Location: ../news.php'); } else { echo "Oh No! Something has gone wrong and the data could not be uploaded"; echo "<br />"; echo "click <a href='Link'>here</a> to return to News"; } mysqli_close($conn); I am not getting an error message from PHP, I am just getting the generic "Something has gone wrong" that I have coded in myself. Is there anyone who can point me in the right direction please? Cheers
  10. how to take a word in php or explode based on luas Bangunan :xxx For example I have string $string =" Kondisi Properti : Bagus Dilengkapi Perabotan : Unfurnished Sertifikat : Lainnya Daya Listrik : 2200 Watt Kamar Tidur : 3/1 Kamar Mandi : 2/1 Luas Bangunan : 92 m² Luas Tanah : 126 m² Jumlah Lantai : - Kondisi Properti : Bagus Sekali Dilengkapi Perabotan : Unfurnished Sertifikat : SHM - Sertifikat Hak Milik Daya Listrik : 6600 Watt Saluran Telepon : 1 Garasi : 3 Kamar Tidur : 4/1 Kamar Mandi : 3/1 Luas Bangunan : 300 m² Luas Tanah : 228 m² Jumlah Lantai : 2.5 "; eg I want to take every "Luas bangunan: xxx" Thanks
  11. Hey guys, I need some help with a simple script a friend wrote for me but isn't returning the correct values. I'm looking to get this script working but my PHP skills are abysmal and I can't for the life of me figure out whats the best way to do this. I've tried contacting my friend but he's moving cross-country so I'm hoping you guys can give me some advice. The script is supposed to return a total shipping price based on the weight of products that are passed to it via an API and the location of the visitor. There are a total of 3 different products (Product A, Product B, Product C) each with it's own weight in grams and it's own shipping rate. The script is needs to follow the following rules: When 1 product (either Product A, B, or C) is in the cart it returns the full fixed shipping price for either US or International Shipping based on $isInternational When 2 or more of Product A or B are added to the cart the full shipping is taken for the heaviest item and a fixed price is added for each additional item (Product and B each have their own fixed prices) When Product C is added to the cart it returns a fixed based on US or International (Product C ships separately and doesn't depend on the weight/prices of Product A or B) The product weights/prices are: Product A: Weight (grams): 250 Us Shipping for first instance: $6.00 International Shipping for first instance: $10.00 Each additional instance: $1.00 Product B: Weight (grams): 300 Us Shipping for first instance: $8.00 International Shipping for first instance: $11.00 Each additional instance: $2.50 Product C: Weight (grams): 120 Us Shipping for each instance: $8.00 International Shipping for each instance: $20.00 An example would be if the cart contained 2 of Product B, 1 of Product A, and 2 of Product C shipping to the US: The price would be 8+2.50+1+8+8=27.50 The script currently ignores the addition of more instances of the items and doesn't take into account US vs International: <? header('Content-Type: application/json'); $json = file_get_contents('php://input'); $request_body = json_decode($json, true); if (is_null($request_body) or !isset($request_body['eventName'])) { header('HTTP/1.1 400 Bad Request'); $response = array( "rates" => "" ); die(json_encode($response)); } switch ($request_body['eventName']) { case 'shippingrates.fetch': // ============= recieve data from cart ============== $country_code = $request_body["content"]["billingAddressCountry"]; $state_code = $request_body["content"]["billingAddressProvince"]; $isInternational = ($country_code != "US"); $quantity = 0; $maxWeight = 0; $cost = 0; $description = "International Shipping"; if($request_body["content"] && $request_body["content"]["items"]){ foreach ($request_body["content"]["items"] as $cart_item){ $quantity += $cart_item["quantity"]; if($cart_item["weight"] >= 300){ $cost += 2.50; } else if($cart_item["weight"] >= 200){ $cost += 1.0; } else if($cart_item >= 100){ $cost += ($isInternational)? 15.0 : 8.0; } if($cart_item["weight"] > $maxWeight){ $maxWeight = $cart_item["weight"]; } } } if($maxWeight >= 300) { $cost += ($isInternational) ? 11.0 : 8.0; $cost -= 2.50; } else if ($maxWeight >= 200) { $cost += ($isInternational) ? 10.0 : 6.0; $cost -= 1; } if($isInternational){ $description = "International Shipping"; } else { $description = "USPS Standard Shipping"; } // =========== return data to cart =============== $rates = array( array( "cost" => $cost, "description" => $description ), ); $response = array( "rates" => $rates ); header('HTTP/1.1 200 OK'); echo(json_encode($response)); break; default: header('HTTP/1.1 200 OK'); break; } ?> Thanks for any help you guys can give!
  12. I am trying to build a website, where: 1) User logs in (UserA) 2) Inserting a name in the search box and pressing "Search", a list of all users matching that name is shown 3) The user selects a user (UserB) from that list (among several results) 4) By selecting the user (UserB) , a message box appears to insert text 5) The user(UserA) types the message 6) The user(UserA) presses the SUBMIT button and sends the message to the other user(UserB) The problem i face is how to pass the variables from my PHP script to the JavaScript script. Its easy for me to get the values of input fiedls, select fields or any other DOM element value. But if the value i need to pass to Javascript file to perform an AJAX call isnt inside a DOM element, how do i do it? For example, for me to determine the user that will send the message (userA), i will need several data. This data, i have them inside the PHP script as variables, but dont know how to pass them to Javascript file. Getting the data from the URL, or from a hidden input field or any other DOM element, is a solution, but i want to know the way that is safer and better. To summarize: -->[pass necessary data from PHP to JavaScript file]-->[perform an AJAX call] --> [return data to PHP Script] How do i do it? Thanks in advance.
  13. Hi, I am a bit of a MYSQL newbie so please bear with me. I have a database created about football/soccer stats. The database at the moment contains the following tables but more maybe added: Players Clubs Seasons Competitions I will create php pages for these tables that add, edit and delete records for each. But the problem I can't get my head around is how to add a record that uses data from other tables, for example we would add a... player -> club-season-competition Lets say we want create a player called 'Joe Bloggs' and want to add his details, we need somehow for the page to display an option for club, season and competition. Maybe they can be drop down boxes but how does one fill those drop down boxes with records that are already added in the database for each table? Thanks
  14. Hi all, I've got a problem with a php code on my website. I don't know why, but the hyperlink is wrong, because it's taken also the link of the current page, before the one of the page of destination. (see the attachment) Where is the mistake? Thanks all for the help $post_id = $instance['posts_name']; $title = apply_filters('widget_title', $instance['title']); if ( empty($title) ) $title = false; echo '<div class="widget top-story">'; if ( $title ) echo $before_title . $title . $after_title . "\n"; ?> <div> <?php $post = get_post( $post_id ); ?> <a href="<?php echo $post->post_name; ?>" class="image"><?php echo get_the_post_thumbnail( $post_id, 'top-story'); ?><span class="comment-icon"><?php echo $post->comment_count; ?></span></a> <span><?php the_time('d.m.Y | g:i A'); ?></span> <span class="rating"><a href="#" class="active"></a><a href="#" class="active"></a><a href="#"></a><a href="#"></a><a href="#"></a></span> <p><a href="<?php echo $post->post_name; ?>"><?php echo $post->post_title; ?></a></p> </div> <?php echo '</div>'; } /* Update widget settings */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['posts_name'] = $new_instance['posts_name']; return $instance; } /* Widget form */ function form( $instance ) { $defaults = array( 'title' => '', 'posts_name' => '', ); $instance = wp_parse_args( (array) $instance, $defaults ); ?> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label> <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" /> </p> <p> <label for="<?php echo $this->get_field_id('posts_name'); ?>">Choose Post:</label> <select name="<?php echo $this->get_field_name('posts_name'); ?>" id="<?php echo $this->get_field_id('posts_name'); ?>" class="widefat"> <?php $posts_array = get_posts( array('numberposts' => -1) ); ?> <?php foreach( $posts_array as $post ) : setup_postdata($post); ?> <option value="<?php echo $post->ID; ?>"<?php selected( $instance['posts_name'], $post->ID ); ?>><?php echo $post->post_title; ?></option> <?php endforeach; ?> </select> </p> <?php } }
  15. I have this PHP script to fetch whois information of domain. It works, but when I try to connect whois server via proxy, then it doesnt work. The proxy ip is taken from proxylist.hidemyass.com. What I do wrong? Thank you for help. $server = "whois.nic.cz"; $domain = "klikzone.cz"; function QueryWhoisServer($server, $domain){ $proxy = "85.111.25.189:8080"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $server); curl_setopt($ch, CURLOPT_PORT, 43); curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $domain . "\r\n"); $data = curl_exec($ch); curl_close($ch); return $data; }
  16. I forked a project from M. Schwartz in Adafruit about wifi controlled robot, and he uses local web server to access it. Now I wanted to the host online the server files. My only problem is this part of his php file <?php // Load JSON state $string = file_get_contents("robot_state.json"); $json_a= json_decode($string,true); // Handle GET request $json_a['speed'] = $_GET["speed"]; $json_a['direction_left'] = $_GET["directionLeft"]; $json_a['direction_right'] = $_GET["directionRight"]; $json_a['reverse'] = $_GET["reverse"]; // Save JSON file $fp = fopen('robot_state.json', 'w'); fwrite($fp, json_encode($json_a)); fclose($fp); // Create a TCP/IP socket & connect to the server $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); $result = socket_connect($socket, "192.168.1.6", "8888"); // Request $in = "HEAD / HTTP/1.1\r\n"; $in .= "Content-Type: text/html\r\n"; $in .= $json_a['speed'] . "," . $json_a['direction_left'] . "," . $json_a['direction_right'] . ",". $json_a['reverse'] . ",\r\n\r\n"; $out = ''; // Send request socket_write($socket, $in, strlen($in)); // Read answer while ($out = socket_read($socket, 4096)) { echo $out; } // Close socket socket_close($socket); ?> notice Line 19: socket_connect($socket, "192.168.1.6", "8888"); This is the part where it communicates to the wifi shield of the arduino. I know this simply wouldn't work now since this is only a private address and the files are now hosted in the internet. Can you guys teach me how to implement because I know this part of code will be quite different.
  17. Hey guys, i'm new to this site and would need some help with coding. So i'm making a car part website which should has brand/model search. It's a dropdown search which will get the brand / model from database and should display all the parts for that exact model, from folder. Database structure which i have is id, master, name. ( Here's some pictures to clear out what i'm doing. http://imgur.com/a/7XwVd ) So the problem is that it does not get the images from folder named ex: *_audi_a3.jpg. And link to codes what have been written already. Parts.php: http://pastebin.com/q6vdypge Update.php: http://pastebin.com/DymhGQ17 Search_images.php: http://pastebin.com/LF5Q0i8f Core.js: http://pastebin.com/bgc0y4TS I don't know what's wrong with it sadly. One thing i noticed when i used firebug it gives error on category when searching error:true. Hope you guys understand what i mean here, and also all help is appreciated. And move this post if it's in wrong place. Thanks!
  18. I have my IP camera with the streaming URL : http://x.x.x.x:81/livestream.cgi?user=admin&pwd= Now i want to record the streaming using PHP . Now please anyone help how to do this ? Any help would be appreciated .
  19. Hello, I'm Paul Ryan. I am 23 years old and have around 8 years experience in programming with the following languages: - PHP - MySQLi - HTML - CSS - JavasScript (jQuery, AJAX) I have worked on many project over the years, including the following: - BoxSelect.com - Taccd.com - FTA.ie - BelfastCookerySchool.com - Dittnyebad.no - MassasjeShop.no - Project: Universe (Personal Project) I have worked on many other smaller jobs, updating outdated code, database and code optimizations etc. You can contact me via the following methods: - PHP Freaks Personal Message - Skype: paulryanmc91 - E-mail: paul.ryan.mclaughlin@gmail.com I am available to start work immediately whether the job be big or small, don't hesitate to contact me. Thanks for your time, look forward to hearing from you. Kind Regards, Paul Ryan
  20. Hi, please help me for school i need to make an assignment and i need to make an script with regular expressions to get an image from a site named asaphshop.nl. but the only thing happens is that it's searching in the localhost what should be on the site. this is my code: ​ <?php header('Content-Type: text/html; charset=utf-8'); $url = "http://www.asaphshop.nl/epages/asaphnl.sf/nl_NL/?ObjectPath=/Shops/asaphnl/Products/80203122"; $htmlcode = file_get_contents($url); $pattern = '#class="noscript">.*(<img.*>).*</div>#isU'; preg_match_all($pattern, $htmlcode, $matches); //print_r ($matches); $image = ($matches[0]); print_r ($image); ?> in the attached file is the thing i get
  21. Code what i made so far. $inputText = 'This is testing http://www.youtube.com'; $allowedDomains = 'www.google.com youtube.com/ http://www.test.org'; $array = preg_split('/[\s]+/', $allowedDomains); $regex = '';//Need this line if(preg_match($regex, $inputText)){ print 'Domain match!'; }else{ print 'Domain not match!'; }
  22. In drive.php public function insert($postBody, $optParams = array()) { $params = array('postBody' => $postBody); $params = array_merge($params, $optParams); return $this->call('insert', array($params), "Google_Service_Drive_DriveFile"); } In resource.php public function call($name, $arguments, $expected_class = null) { if (! isset($this->methods[$name])) { throw new Google_Exception( "Unknown function: " . "{$this->serviceName}->{$this->resourceName}->{$name}()" ); } firstpro.php
  23. I am working on a quiz app image 1 shows the index.php page image 2 shows the first question image 3 shows the second question image 4 shows the third question image 5 shows the result after completing the quiz image 6 shows the database 'quizzer' and its tables image 7 shows the 'questions' table image 8 shows the 'choices' table THIS LINK CONTAIN ALL THE CODE (and images) I HAVE DONE SO FAR https://www.mediafire.com/folder/g5ao7f5q0fe6y/quiz 1.Now my question is how to select the question RANDOMLY from 'questions' table along with 'choices' (by adding code to the existing file or create a new one). 2.If user refresh/reload the page before starting ('Start Quiz') or click 'Take Again' after finishing the quiz, the question should appear randomly. 3.Basically I want to change the order of question appearing in the browser each time I refresh. 4.My work so far is mentioned above.........Please help me with this "RANDOM" problem !! P.S - Will it be possible, by creating a random function in PHP which will check for repeat questions in a session and check for the 'id' of the question and if it is new display it on the page. If so what should I do and if no then how to do?
  24. i can do stuff in html, php, flash, java and server developement and work for more then 8 years in different segments for webprogramming. german.
  25. Ok this is puzzleing. I am geting "Could not delete data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1". but its is deleting the entry that needs to be removed. The "1" is the entry. Just not sure what is causing the error. I do have another delete php but I have put that on the back burning for the time being. <?php $con = mysqli_connect("localhost","user","password","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20 "); $amp20ptid = $_POST['amp20ptid']; // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); mysqli_query($con, "DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $amp20ptid)); { die('Could not delete data: ' . mysqli_error($con)); } echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?>
×
×
  • 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.