-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
I was just on there a few minutes ago and then suddenly my chrome browser said the site contained malware! Really strange. This is what could apparently be causing it https://news.ycombinator.com/item?id=6604251. Its interesting reading the google forum above the devs couldn't even find a way to request a review to take down the notice. If you need to access the manual head over to http://devdocs.io/php/
-
What is the variable $session_user_id set to? It will only update the table if the sender or receiver matches the value of that variable.
-
using either the mysql console or phpmyadmin check that the queries work using hard coded values, example UPDATE `conversations` SET `sdelete` = '1' WHERE (`conversationID` = '1' OR parent='1') UPDATE `conversations` SET `rdelete` = '1' WHERE (`conversationID` = '1' OR parent='1') If they work, then make sure the PHP code actually works by actually submitting data to it via form <form action="delpage.php" method="post"> ID: <input type="text" name="id" value="" placeholder="Enter id value" /> <input type="submit" /> </form>
-
Also you're trying to update/delete records where Name=$_POST[hidden]. The form field named hidden contains the records ID value echo '<td><input type="hidden" name="hidden" value="' . $row['ID'] . '" /></td>'; The queries need to update/delete records where the ID column equals to $_POST[hidden]. <?php $con = mysqli_connect("localhost","root","","lcm"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //updates table. if (isset($_POST["update"])) { $name = mysqli_real_escape_string($con, $_POST['name']); $address = mysqli_real_escape_string($con, $_POST['address']); $hidden = mysqli_real_escape_string($con, $_POST['hidden']); $UpdateQuery = "UPDATE tbl_contactinfo SET Name='$name', Address='$address' WHERE ID='$hidden'"; mysqli_query($con, $UpdateQuery); } if (isset($_POST['delete'])) { $hidden = mysqli_real_escape_string($con, $_POST['hidden']); $DeleteQuery = "DELETE FROM tbl_contactinfo WHERE ID='$hidden'"; mysqli_query($con, $DeleteQuery); } //selects the table. $sql = "Select * from tbl_contactinfo"; if ($result = mysqli_query($con, $sql)) { echo "<table border='1'> <tr> <th>Name</th> <th>Address</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo '<form action="index1.php" method="post">'; echo '<tr>'; echo '<td><input type="text" name="name" value="' . $row['Name'] . '" /></td>'; echo '<td><input type="text" name="address" value="' . $row['Address'] . '" /></td>'; echo '<td><input type="hidden" name="hidden" value="' . $row['ID'] . '" /></td>'; echo '<td><input type="submit" name="update" value="update" /></td>'; echo '<td><input type="submit" name="delete" value="delete" /></td>'; echo '</tr>'; echo '</form>'; } echo "</table>"; } ?> <html> <body> <form action="insert.php" method="post"> Name: <input type="text" name="Name"> Address: <input type="text" name="Address"> <input type="submit" name="submit"> </form> </body> </html>
-
Because you're using smart quotes (i think that is what they are called) name=”comments” Instead of normal quotes name="comments"
-
looking at your javascript code at jsfiddle. This line var id = $(this).parent().parent().attr('id'); cant find the id value. The id value you need is from the delete button right? <input type='submit' id='1' class='delete' value='Delete'> If is then you need to use $(this).attr('id') to get the id value from the delete button.
-
Oh, didn't realise default.php was in card directory. Yes that should still work with either site.com/card/somepage/otherpage/ and site.com/card/somepage/otherpage/?id=345 Have you tried it?
-
Try the following rewrite rule RewriteRule ^card/somepage/otherpage/ default.php [QSA] default.php should be in your sites root folder
-
When the form is submitted you'll need to save the contents of the $servers array to some form of storage, such as a text file, or database. When your PHP script gets the ajax request you'll need to get the server data from the storage to repopulate the $servers array and then check the status of the servers. An easy way to write the contents of an array to a text file is to serialize it and then use file_put_contents to write the data to a file. To read the file you'll use file_get_contents and then unserialize it to repopulate the $servers array. Note make sure you only write the server data to the storage when a POST request has been made, otherwise the data will be overwritten on any request.
-
Dont use absolute http urls for the replacement url. This will cause a redirect. Just provide the path to the file the rewrite rule should perform the request to RewriteEngine On RewriteRule ^/card/somepage/otherpage/ default.php [QSA] The url site.com/card/somepage/otherpage/ and site.com/card/somepage/otherpage/?id=345 should call default.php. To get the id from the query string use the $_GET['id'] superglobal variable
-
Your code should work when you first submit the form. The $servers array should be populated with the values from the form. However when you are doing the ajax request to check the status of the servers defined in the $servers array, it will be empty! The values from POST wont be remembered during the ajax request.
-
rename will rename the file. Use copy instead copy('path/to/oldfilename', 'path/to/newfilename');
-
You need to use mysqli_affected_rows to check if the query did actually update the table. if ($delete === true) { if (mysqli_affected_rows($db)) { $_SESSION['success'] = 'Message has been successfully deleted!'; } else { // record was not updated } }else { $_SESSION['error'] = "Error description: " . mysqli_error($db); }
-
If the script stops on mysql_query() then there is a problem with the query. To see if there is an error use mysql_error() to get the error from mysql. $sql="SELECT * FROM grid WHERE `id` = $nextcell LIMIT 1"; if($result=mysql_query($sql)) // check that query executed { $numrows = mysql_num_rows(); if ($numrows=0){ //nothing here, input data //code to insert } } // mysql_query returned false, probably due to error else { echo 'MySQL Error: ' . mysql_error(); // display error from msyql }
-
Because your trying to reference $buttons from within your class you need to make the $buttons array accessible from your controller and/or view class. You're better of making a helper function to render your buttons in your view function Button($name) { global $buttons; // access the global $buttons array if(isset($buttons[$name])) { foreach($buttons[$name] as $attr_name => $attr_value) $attrs[] = sprintf('%s="%s"', $attr_name, $attr_value); return '<input type="submit" '.implode(' ', $attrs).'>'; } return; } Then in your view to render the buttons for the view you'd use foreach ($this->buttons as $button) { echo Button($button); }
-
Sorry, I left the letter e out of error_text, the line below function my_error_log($error_txt) should be function my_error_log($error_text)
- 16 replies
-
- error log
- log errors
-
(and 2 more)
Tagged with:
-
To get barands code to work you need to define each advert image and the link for that advert in the $images array. (The image name and link go between the quotes) $images = array ( array ( 'name' => 'im1.png', // image for advert 1 'link' => 'http://www.google.com' // link for advert 1 ), array ( 'name' => 'im2.png', // image for advert 2 'link' => 'http://www.msn.com' // link for advert 2 ), array ( // advert 3 ), array ( // advert 4 ), // etc... ); Then where you want the adverts to show you'll call the getImage() function, using <?php echo getImage($images)?> That will then randomly choose an advert, display the advert with the link that corresponds to it. You current script rotate.php is very limited. You can only display the advert with it. It can't output the link and the advert together. It will need to be recoded. Barands code is a lot easier to use/configure for what you're wanting to do.
-
You can't automatically attach a file to a file input. The user will always have to choose the file to be uploaded.
-
Make a function, that calls error_log so you don't have to define the email headers each time you want to log an error. // define custom error logging function function my_error_log($error_txt) { // Prepare headers for e-mail $headers = "From: help@mysite.com\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; // append error information to error message $error_text .= " Date: " . date("l jS \of F, Y, h:i:s A") . ". File: " . $_SERVER['REQUEST_URI']; // call error_log function error_log($error_text, 1, "personaladdress@whatever.com", $headers); } // Connect to MySQL $con = mysql_connect("", "", ""); if(!$con) { echo "<p>User-friendly message for user.</p>"; // call custom error log function my_error_log("MySQL connection failed!"); // jsut pass in the error message } else { // Rest of code }
- 16 replies
-
- error log
- log errors
-
(and 2 more)
Tagged with:
-
To open .psd (photoshop document) file in a popup window
Ch0cu3r replied to harishpathak's topic in PHP Coding Help
You can convert a psd to an image using classPhpPsdReader.php as shown here http://www.catswhocode.com/blog/php-display-adobe-psd-files-on-a-web-page and then display the psd as an image. For displaying contents of a word document you can use http://www.phpdocx.com/ to easily read contents of word documents and convert them to html, to preserve the formatting. However you may need to purchase a license for this. -
Sorry, try if( (isset($_GET['fromApp']) && $_GET['fromApp'] == 1) || (isset($_GET['fromQB']) && $_GET['fromQB'] == 1)) { // url is either ?fromApp=1 OR ?fromQB=1 } I left of the closing ) for the if
-
If only one image can be the main image I'd use radio buttons. So change the file inputs and checkbox fields to <dt><label for="imgfile">Kies foto:</label></dt> <dd><input name="imgfile[<?php echo $i ?>]" id="imgfile[<?php echo $i ?>]" type="file" /> <input type="radio" name="imgmain" value="[<?php echo $i ?>]" id="imgmain"> Now change // check that there are thumbnails in uploaded_images if(!empty($uploaded_images)) { to // check that there are thumbnails in uploaded_images if(!empty($uploaded_images)) { if(isset($_POST['imgmain'])) $Main = $uploaded_images[ $_POST['imgmain'] ]; Now the selected image should be set as the main image.
-
Just check whether $_GET variables exist and set to 1 if( (isset($_GET['fromApp']) && $_GET['fromApp'] == 1) || (isset($_GET['fromQB']) && $_GET['fromQB'] == 1) { // url is either ?fromApp=1 OR ?fromQB=1 }
-
You have a check box next to each file upload which the you use to mark it as the main image?