Jump to content

Jenksuy

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by Jenksuy

  1. Thanks... the following code worked which I have updated above... $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); if($_POST["delete"]) // from button name="delete" { $checkbox = $_POST["checkbox"]; //from name="checkbox[]" $countCheck = count($_POST["checkbox"]); for($i=0;$i<$countCheck;$i++) { $del_id = $checkbox[$i]; $sql = "DELETE from job_details where jobReference = $del_id"; $result = $mysqli->query($sql) or die(mysqli_error($mysqli)); echo $del_id; } } I added the for loop and changed id to jobReference in the query as that what $del_id was showing! Thanks
  2. Hello there, I have written some php code to try and delete records from my module when they are selected and deleted. However when i go to delete the record i get the following error... 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 1 Here is my code Delete.php <?php $db_name = "..."; // The database we created earlier in phpMyAdmin. $db_server = "..."; // Change if you have this hosted. $db_user = "..."; // Your USERNAME $db_pass = "..."; // Your PASSWORD. Working locally, mine is blank. $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); if($_POST["delete"]) // from button name="delete" { $checkbox = $_POST["checkbox"]; //from name="checkbox[]" $countCheck = count($_POST["checkbox"]); for($i=0;$i<$countCheck;$i++) { $del_id = $checkbox[$i]; $sql = "DELETE from job_details where id = $del_id"; $result = $mysqli->query($sql) or die(mysqli_error($mysqli)); echo $del_id; } } ?> backend.php function delete_a_job() { $con = mysql_connect("...","...","..."); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("...", $con); $result = mysql_query("SELECT * FROM job_details"); echo '<form method="post" action="/wp-content/plugins/face-recruiter/delete.php"> <table border="1"> <tr> <th>Delete</th> <th>Job Reference</th> <th>Job Title</th> <th>Category</th> <th>Location</th> <th>Salary</th> <th>Type</th> </tr>'; while($row = mysql_fetch_array($result)) { echo '<tr>'; echo '<td><input type="checkbox" name="checkbox[]" id="checkbox[]" value='.$row['JobReference'].' />'; echo '<td><a href="/details.php?id='.$row['JobReference'].'">' . $row['JobReference'] . '</a></td>'; echo '<td>' . $row['JobTitle'] . '</td>'; echo '<td>' . $row['Category'] . '</td>'; echo '<td>' . $row['Location'] . '</td>'; echo '<td>' . $row['Salary'] . '</td>'; echo '<td>' . $row['Type'] . '</td>'; echo '</tr>'; } echo "</table>"; // when the loop is complete, close off the list. echo '<p><input id="delete" type="submit" class="button" name="delete" value="Delete Selected Items"/></p></form>'; mysql_close($con); } Can Anyone see what I am doing wrong??
  3. I don't understand why my database will not connect to my server... Can anyone see anything that I cant? <?php // Grab our POSTed form values // Note that whatever is enclosed by $_POST[""] matches the form input elements $reference = $_POST["reference"]; $category = $_POST["category"]; $title = $_POST["title"]; $location = $_POST["location"]; $salary = $_POST["salary"]; $type = $_POST["type"]; // Connect to our DB with mysql_connect(<server>, <username>, <password>) $sql_connection = mysql_connect("xxxx", "xxxx", "xxxxx"); if (!$sql_connection) { echo "Please try later."; } else { mysql_select_db("frcrecru_beta", $sql_connection); } // Probably should check to make sure the connection was successful // But I'm too lazy... $sql = "INSERT INTO face-recruiter ( reference, category, title, location, salary, type ) VALUES ( '$reference', '$category', '$title', '$location', '$salary', '$type', NOW() )"; mysql_query($sql, $sql_connection); mysql_close($sql_connection); ?> Thanks
  4. Finally got it working... started my code from Scratch and made it much simpler which finally has it working... Ill paste it here for anyone who needs help! <?php /** Step 2 (from text above). */ add_action( 'admin_menu', 'my_plugin_menu' ); /** Step 1. */ function my_plugin_menu() { add_menu_page( 'Roundabout', 'Roundabout', 'manage_options', 'my-unique-identifier', 'my_roundabout_options' ); } /** Step 3. */ function my_roundabout_options() { if ( !current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); } echo '<div class="wrap">'; echo '<label for="upload_image">'; echo '<input id="upload_image" type="text" size="36" name="ad_image" value="http://" />'; echo '<input id="upload_image_button" class="button" type="button" value="Upload Image" />'; echo 'Enter a URL or upload an image'; echo '</label>'; echo '</div>'; } add_action('admin_enqueue_scripts', 'my_admin_scripts'); function my_admin_scripts() { wp_enqueue_media(); wp_register_script('my-admin-js', WP_PLUGIN_URL.'/roundabout-with-thumbs-and-lightbox/js/backend.js', array('jquery')); wp_enqueue_script('my-admin-js'); } ?>
  5. Yes I have error reporting on, but I am not getting any other errors. here is the code for my frontend of the plugin... as you can see I have used glob the exact same way in here but it is working? <?php /* Plugin Name: Roundabout with Thumbs and Lightbox Plugin URI: http://ourface.co.uk Description: Displays the Jquery roundabout plugin with both Thumbnails and Lightbox Version: 1.0 Author: Chris Jenks Author URI: http://twitter.com/jenksuy */ require_once( 'wptuts-options.php' ); function display_roundabout() { $user_id = get_current_user_id(); $files = glob('wp-content/uploads/'.$user_id.'/*'); natcasesort($files); foreach($files as $file) { echo '<li> <img id="' . $file . '" src="/' . $file . '" /> <a href="/' . $file . '" rel="lightbox[roadtrip]"><img src="/' . $file . '" alt="" id="link" /></a> </li>'; } } function add_thumbnails() { $user_id = get_current_user_id(); $files = glob('wp-content/uploads/'.$user_id.'/*'); natcasesort($files); foreach($files as $file) { echo '<img src="/' . $file . '" onclick="fakeClick(event, document.getElementById(\'' . $file . '\'))" />'; } } ?>
  6. It isn't the user id as I have now taken it out... function wptuts_setting_logo_preview() { $wptuts_options = get_option( 'theme_wptuts_options' ); ?> <div id="upload_logo_preview" style="min-height: 100px;"> <?php $files = glob('wp-content/uploads/1/*'); foreach($files as $file) { echo '<img src="/' . $file . '" />'; } ?> </div> <?php } ?> I have also put the full image tag inside the echo... the error i get is.. Warning: Invalid argument supplied for foreach() in public_html/wp-content/plugins/roundabout-with-thumbs-and-lightbox/wptuts-options.php on line 166
  7. I thought that might be what i needed as i used it before in the frontend of my plugin... i have now integrated it into the backend here is my code function wptuts_setting_logo_preview() { $wptuts_options = get_option( 'theme_wptuts_options' ); ?> <div id="upload_logo_preview" style="min-height: 100px;"> <img style="max-width:100%;" src="<?php $files = glob('wp-content/uploads/'.$user_id.'/*'); foreach($files as $file) { echo $file; } ?>" /> </div> <?php } ?> When i inspect element in my source i get invalid argument supplied for foreach() I cant see what Im missing from my code... What do you think?
  8. I have been trying for a day now to print all the images stored in a directory, however at the minute i can only get one to appear. could anyone point me in the right direction? function wptuts_setting_logo_preview() { $wptuts_options = get_option( 'theme_wptuts_options' ); $user_id = get_current_user_id(); $files = glob('wp-content/uploads/'.$user_id.'/*'); ?> <div id="upload_logo_preview" style="min-height: 100px;"> <img style="max-width:100%;" src="<?php echo esc_url( $wptuts_options['logo'] ); ?>" /> </div> <?php } ?>
  9. Got it working thanks... your maskign with backslashes worked as follows echo '<img src="/' . $file . '" onclick="fakeClick(event, document.getElementById(\'' . $file . '\'))" />'; Thanks
  10. thanks... this hasnt seemed to work yet. it seems to put the first image in... but then stops all html after that... so something must be missing? Appreciate your help
  11. Hey, I am trying to insert my variable into single quote marks. the following code works but does not put the single quote marks around the variable as it is part of the variable... <?php $user_id = get_current_user_id(); $files = glob('wp-content/uploads/'.$user_id.'/*'); natcasesort($files); foreach($files as $file) { echo '<img src="/' . $file . '" onclick="fakeClick(event, document.getElementById(' . $file . '))" />'; } ?> this appears as with now single quote around the emboldened.. <img src="/wp-content/uploads/1/portfolio-sample-main-image.png" onclick="fakeClick(event, document.getElementById(wp-content/uploads/1/portfolio-sample-main-image.png))"> however how I want to appear is as follows... <img src="/wp-content/uploads/1/portfolio-sample-main-image.png" onclick="fakeClick(event, document.getElementById('wp-content/uploads/1/portfolio-sample-main-image.png'))"> as you can see with single quotes... how can I do this? Thanks
×
×
  • 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.