Jump to content

DFulg

Members
  • Posts

    27
  • Joined

  • Last visited

DFulg's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. Make sure your error_reporting is set to E_ALL or -1 and display_errors is set to 'On' or 1. You should be receiving some kind of error. In any case, add some debugging: $fp = fopen('top100stats.txt', 'r'); //open the file read-only to verify that it exists. if ( $fp === false ) { //cannot open the file echo "Error while attempting to open the file."; } else { // file opened successfully, display message echo '<h2>File exists!</h2>'; }
  2. Okay, let's take a step back here. As much as I love spaghetti, I don't enjoy trying to read spaghetti code. 1. These two lines $image = new cmsImages; $image->storeFormValues( $_POST ); call the class construct twice. storeFormValues() is not needed, instead it should read. $image = new cmsImages( $_POST ); 2. The image information is stored in $_FILES not $_POST, which is why file_get_contents($_FILES['file']['tmp_name']) holds the correct data. 3. Read my first post in this thread because I state the reasons why your logic is flawed. 4. But since it seems like you don't want to listen to reason and just want an answer, your construct should read something like this: public function __construct( $post_data = array(), $file_data = array() ) { if ( isset( $post_data['img_id'] ) ) $this->img_id = (int) $data['img_id']; if ( isset( $post_data['img_name'] ) ) $this->img_name = preg_replace ( "/[^\.\,\-\_\'\"\@\?\!\:\$ a-zA-Z0-9()]/", "", $data['img_name'] ); if ( isset( $file_data['file'] ) ) $this->img_blob = file_get_contents($file_data['file']['tmp_name']); then you would pass the construct its arguments like so: $image = new cmsImage( $_POST, $_FILES ); I feel so dirty writing this.
  3. Change this line: $st->bindValue( ":imageFile", $this->img_blob, PDO::PARAM_LOB); To this: $st->bindValue( ":imageFile", $imageFile, PDO::PARAM_LOB); and it should work fine, although you shouldn't be doing this in the first place. We see your class structure but not the call to the class, show that as well, the problem appears to be the data that you are sending to the class.
  4. A couple things I notice: 1. As mentioned, it's generally a bad practice to store blob images inside of a database. Instead, store the images on the server and the image paths in a database. 2. the uploadImage() method should only be concerned with, you guessed it, uploading an image, not establishing a connection to the database and querying data. You should look into the idea of using utility classes to help abstract these tasks.
  5. PHPFreaks has a tutorial on basic pagination available: here
  6. Include all of the falsy logic in one statement: if ( $number == 5 || $letter == 'a' || $option > 2 ) { //false block } else { // true block } much more readable and logical
  7. No. include 'connect.php'; include 'main.php'; $id = $_SESSION['id']; $page = "http://localhost/page1.php"; $sql = "UPDATE math SET latestpage=$page WHERE id='$id'"; mysql_query($sql) or die("MYSQL Query Failed : " . mysql_error()); $result3 = mysql_query("SELECT * FROM html WHERE id='$id'") or die("MYSQL Query Failed : " . mysql_error()); while($row3 = mysql_fetch_array($result3)) { $latestpage=$row3['latestpage']; echo $latestpage; Note: mysql is deprecated and will be removed in a future version of PHP. Use mysqli or PDO instead.
  8. Make sure that the visibility of __construct() is private not public. The purpose of a singleton in this case is so that one and only one database connection will be established, having a public construct breaks that functionality.
  9. Do you have both error_reporting set to E_ALL and display_errors set to 'On'?
  10. If you would like to do this using strictly markup and PHP, I suggest taking a look a this and this. Note that the "multiple" attribute is not supported in IE or Opera.
×
×
  • 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.