Jump to content

Aman Grover

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Aman Grover's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am reading "PHP for absolute beginners" but I am stuck on page 183 where I get an error-- Warning: array_push() expects parameter 1 to be array, boolean given in C:\xampp\htdocs\simple_blog\inc\function… on line 60 Warning: array_pop() expects parameter 1 to be array, boolean given in C:\xampp\htdocs\simple_blog\index.php on line 27 and Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\simple_blog\index.php on line 68 I don't know why it is returning $e as a boolean and not an array! I thought this is a great place to put up this question below is the code for functions.inc.php file--- <?php function retrieveEntries($db, $page, $url=NULL) { if(isset($url)) { $sql = "SELECT id, page, title, entry FROM entries WHERE url=? LIMIT 1"; $stmt = $db->prepare($sql); $stmt->execute(array($url)); $e = $stmt->fetch(); $fulldisp = 1; } else { $sql = "SELECT id, page, title, entry, url FROM entries WHERE page=? ORDER BY created DESC"; $stmt = $db->prepare($sql); $stmt->execute(array($page)); while($row = $stmt->fetch()) { $e[] = $row; $fulldisp = 0; } if(!is_array($e)) { $fulldisp = 1; $e = array( 'title' => 'No Entries Yet!', 'entry' => 'This Page Does Not Have An Entry Yet!!' ); } } array_push($e , $fulldisp ); return $e; } function sanitizeData($data) { if(!is_array($data)) { return strip_tags($data, "<a>"); } else { return array_map('sanitizeData', $data); } } function makeUrl($title) { $patterns = array( '/\s+/', '/(?!-)\W+/' ); $replacements = array('-' , ''); return preg_replace($patterns , $replacements , strtolower($title)); } ?>
  2. But I couldn't find any "extension=pdo_mysql.so" or anything like that.
  3. I didn't use any application like XAMPP or any other app. , I simply installed PHP, MySQL , and Apache . I tried the phpinfo(); script , and it showed : PDO driver : enabled sqlite2.
  4. I tried the following script: <?php try { $user='root'; $pass='mysqlmysqli'; $dbh = new PDO ('mysql:hos=localhost;dbname=test',$user,$pass); foreach ($dbh->query('SELECT * FROM albums')as $row) { print_r($row); } $dbh=null; } catch(PDOException $e) { print "Error: ". $e->getMessage()."<br />"; die(); } ?> but it shows "error: could not find driver". I think it is the PHP_MYSQL driver. How can I install it? I looked for it on the net but couldn't find anything. I am just a beginner in PHP. Please help.
×
×
  • 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.