-
Mar 27th, 2012, 09:02 AM
#1
Thread Starter
New Member
Some errors
First of all I would like to say hello to everyone! Im new here!
I got some errors with my website and i cant see whats wrong ( Im still a beginner in this ) So i hope there is someone here that can help me fix them.
1st Error : Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\ford\index.php on line 11
2nd says its on like 16 and 3rd on line 20.
and the code is this :
<?php
require 'engine/myEngine.php';
$site = new myEngine;
mysql_connect($db['host'],$db['user'],$db['pass']);
mysql_select_db($db['name']);
$list = mysql_query('SELECT * FROM autovehicul WHERE tip_autovehicul = "autoturisme"');
$list_vehicule = array();
while($row = mysql_fetch_array($list))
$list_vehicule[] = $row;
$list = mysql_query('SELECT * FROM autovehicul WHERE tip_autovehicul = "autoutilitare"');
$list_utilitare = array();
while($row = mysql_fetch_array($list))
$list_utilitare[] = $row;
$page['title'] = ucfirst($cat) . ' | ';
$site->assign('list_vehicule',$list_vehicule);
$site->assign('list_utilitare',$list_utilitare);
$site->display('index.tpl');
?>
Thank you in advance and I hope you guys have a nice day!
-
Mar 27th, 2012, 09:52 AM
#2
Re: Some errors
Hi, welcome to the forums
Try using single quotes inside the query like this:
PHP Code:
$list = mysql_query("SELECT * FROM autovehicul WHERE tip_autovehicul = 'autoturisme'");
//...
$list = mysql_query("SELECT * FROM autovehicul WHERE tip_autovehicul = 'autoutilitare'");
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Mar 27th, 2012, 11:24 AM
#3
Re: Some errors
You can try what akhileshbc suggested, but it may or may not help; MySQL should be impartial to single vs. double quotes unless ANSI_QUOTES is enabled.
The error is telling you that mysql_fetch_array() returned a boolean; if you check the reference page for this function, it states that a boolean of false is returned if there are no more rows in the result set. Did your query return an empty set? You can check this with mysql_num_rows() before you try using something like mysql_fetch_array().
For your other errors, please post the descriptive error text.
-
Apr 17th, 2012, 08:10 PM
#4
Frenzied Member
Re: Some errors
Welcome to VBForums!
As SambaNeko mentioned, the cause for your 'boolean given' error is that mysql_fetch_array() returns false if there are no more rows in the result set.
As a side note on forum practice, your thread title should be more descriptive as to what the general issue is. A title with the text "mysql_fetch_array() expects parameter" is more descriptive than "Some errors". Also you can use the PHP tags to format code so it is easier to read.
For e.g.
PHP Code:
<?php
require 'engine/myEngine.php';
$site = new myEngine;
mysql_connect($db['host'],$db['user'],$db['pass']);
mysql_select_db($db['name']);
$list = mysql_query('SELECT * FROM autovehicul WHERE tip_autovehicul = "autoturisme"');
$list_vehicule = array();
while($row = mysql_fetch_array($list))
$list_vehicule[] = $row;
$list = mysql_query('SELECT * FROM autovehicul WHERE tip_autovehicul = "autoutilitare"');
$list_utilitare = array();
while($row = mysql_fetch_array($list))
$list_utilitare[] = $row;
$page['title'] = ucfirst($cat) . ' | ';
$site->assign('list_vehicule',$list_vehicule);
$site->assign('list_utilitare',$list_utilitare);
$site->display('index.tpl');
?>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|