PHP - Moved: Word Press Php Coding
This topic has been moved to PHP Applications.
http://www.phpfreaks.com/forums/index.php?topic=326314.0 Similar TutorialsThis topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=330095.0 Hello! This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=316747.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=345438.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=306863.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=354819.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=350418.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=334042.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=345250.0 This topic has been realloc()d to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=345803.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=353714.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=345920.0 This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=331336.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=343748.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=333654.0 This topic has been moved to Editor Help (Dreamweaver, Zend, etc). http://www.phpfreaks.com/forums/index.php?topic=355418.0 Hello, what's the correct use of GD library to compress JPG images please? I am using this upload script with TinyMCE. See below : I have this snippet but it doesn't compress the image: // Accept upload if there was no origin, or if it is an accepted origin // If image is JPEG compress with GD library $filetowrite = $imageFolder . $temp['name']; if (in_array(strtolower(pathinfo($temp['name'], PATHINFO_EXTENSION)), array("jpg", "jpeg"))) { imagejpeg($temp['tmp_name'], $filetowrite, 75); } else { move_uploaded_file($temp['tmp_name'], $filetowrite); } <?php $accepted_origins = array("http://localhost", "http://127.0.0.1", "http://192.168.1.1", "http://example.com"); $month = strtolower(date('M')); $year = date('Y'); $newspath = "img/news/"; if (!is_dir("$newspath/$year/$month")) { mkdir("$newspath/$year/$month", 0777, true); } $imageFolder = "$newspath/$year/$month/"; reset ($_FILES); $temp = current($_FILES); if (is_uploaded_file($temp['tmp_name'])){ if (isset($_SERVER['HTTP_ORIGIN'])) { // same-origin requests won't set an origin. If the origin is set, it must be valid. if (in_array($_SERVER['HTTP_ORIGIN'], $accepted_origins)) { header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']); } else { header("HTTP/1.1 403 Origin Denied"); return; } } /* If your script needs to receive cookies, set images_upload_credentials : true in the configuration and enable the following two headers. */ // header('Access-Control-Allow-Credentials: true'); // header('P3P: CP="There is no P3P policy."'); // Sanitize input if (preg_match("/([^\w\s\d\-_~,;:\[\]\(\).])|([\.]{2,})/", $temp['name'])) { header("HTTP/1.1 400 Invalid file name."); return; } // Verify extension if (!in_array(strtolower(pathinfo($temp['name'], PATHINFO_EXTENSION)), array("gif", "jpg", "jpeg", "png"))) { header("HTTP/1.1 400 Invalid extension."); return; } // Accept upload if there was no origin, or if it is an accepted origin // If image is JPEG compress with GD library $filetowrite = $imageFolder . $temp['name']; if (in_array(strtolower(pathinfo($temp['name'], PATHINFO_EXTENSION)), array("jpg", "jpeg"))) { imagejpeg($temp['tmp_name'], $filetowrite, 75); } else { move_uploaded_file($temp['tmp_name'], $filetowrite); } // Respond to the successful upload with JSON. // Use a location key to specify the path to the saved image resource. // { location : '/your/uploaded/image/file'} // echo json_encode(array('location' => $filetowrite)); $passpath = $year.'/'.$month.'/'.$temp['name']; echo json_encode(array('location' => $passpath)); } else { // Notify editor that the upload failed header("HTTP/1.1 500 Server Error"); } ?>
I am making a pos(point of sale) application using object oriented php. I have found thermal receipt printers support ESC/POS . i want that when i will press button to print directly , it will do automatically. anyone can help me please. Thanks in advance. I am trying to find a good IDE for PHP and JavaScript. I fiddled around with Visual Code and it was very buggy. The GitHub page said over 800 open errors?!?!? Now I'm looking at PHPStorm and it reads that only PHP in a PHP page or JavaScript in a JavaScript page may be debugged. I am wondering if this is always possible to separate the code like this.
Also, in the following code, what do you all think about using a XMLHttpRequest() to call this right in the beginning of the page with no button or anything. Is this bad form? It creates a dropdown list from the database. Right now it just sits there. This code isn't ready for prepare yet.
<?php $host = 'localhost'; $user = 'root'; $pass = ''; $database = 'ecommerce'; $options = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false ); $dbo = new PDO("mysql:host=$host;dbname=$database", $user, $pass, $options); $q4 = "SELECT categories.title FROM categories INNER JOIN customers on customers.CustomerID = categories.CustomerID and customers.CustomerID = 1"; echo '<select id = "dropDown1" >'; foreach ($dbo->query($q4) as $row) { echo "<br>"; echo '<option value = " '; echo $row['title']; echo '">'; echo $row['title']; echo '</option>'; } echo "<br>"; echo '</select>'; ?> I'm using AJAX.
Edited January 2 by JoshEir Hi guys,
Having some trouble entering some php into my wordpress site that runs on Optimize Press.
I'm trying to insert this URL/ tracking code into my page as a hyperlink - 'Click Here Now'.
http://www.mysite.co...1_50onRed&sub1=<?php echo $sub1; ?>&sub2=<?php echo $sub2; ?>&sub3=<?php echo $sub3; ?>&sub4=<?php echo $sub4; ?>&sub5=<?php echo $sub5; ?>&lpid=<?php echo $lpid; ?>
This is what I have done so far:
<a href="http://www.mysite.co...;sub1=<?php echo $sub1; ?>&sub2=<?php echo $sub2; ?>&sub3=<?php echo $sub3; ?>&sub4=<?php echo $sub4; ?>&sub5=<?php echo $sub5; ?>&lpid=<?php echo $lpid; ?>">Click Here Now</a>
This does generate a hyperlink, however when I click it, I get: 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 '=' at line 2
I understand for this code to work the page has to be saved in php. I thought wordpress did this automatically?
Can anyone help please? Also, please bear in mind I am using the Optimize Press plugin.
Many thanks in advance!
Tom
|