Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-29-2007, 01:52 AM
mittalmak mittalmak is offline
Newbie
 
Join Date: Aug 2007
Posts: 11
Rep Power: 0
mittalmak is on a distinguished road
Default Mysql/Php help need

hii every body i need help in my script my website.. is here

and the error is
Code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mittal/public_html/includes/application_top.php on line 14
No Categories.

and here is th appalication_top.php

Code:
<?php

include('config.php');
include('functions.php');


// Connect to database
$dbConnection = mysql_pconnect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db(DATABASE_NAME, $dbConnection);


// set the application parameters
$configuration_query = mysql_query('select name as cfgKey, value as cfgValue from ' . TABLE_PREFIX . 'configuration');
while ($configuration = mysql_fetch_array($configuration_query)) {
define($configuration['cfgKey'], $configuration['cfgValue']);
}


// Get parameters
$keyword=db_prepare_input($_GET['k']);
$category=db_prepare_input($_GET['c']);
$page=db_prepare_input($_GET['p']);

// Get category info if specified
if (!empty($category)){
// Get Category Colour and Image
// Check if keyword exists in database
$cat_query_sql = "select * from " . TABLE_PREFIX . "categories where id='" . $category . "'" ;
$cat_query = mysql_query($cat_query_sql) ;
$cat = mysql_fetch_array($cat_query);
}

// Get category info if specified
if (!empty($keyword)){

$keyword_query_sql = "select * from " . TABLE_PREFIX . "keywords where id = '" . $keyword . "'";
$keyword_query = mysql_query($keyword_query_sql) ;
$keyword_row = mysql_fetch_array($keyword_query);
$num_keyword_rows = mysql_num_rows($keyword_query);

//if ($num_keyword_rows==0) {
//die ('Invalid Keyword Specified.');
//}
}



// Within a Category
if (!empty($category)){

if ($cat['useimage'] ==1){ // Default image
$catimage='images/categories/titleimage.jpg';
}
elseif ($cat['useimage'] ==2){// Uploaded image
$catimage='images/categories/' . $cat['image'];
}
else {
$catimage='';
}
}
else { // Main page

if (CFG_USEIMAGE==1) {
$catimage = 'images/categories/titleimage.jpg';
}
elseif (CFG_USEIMAGE==2 && CFG_IMAGE !='' && file_exists('images/categories/' . CFG_IMAGE)){
$catimage= 'images/categories/' . CFG_IMAGE;
}
else {
$catimage='';
}

}

// Set page title
if (!empty($cat['category'])){
$title=$cat['category'];
}
else {

$title = CFG_TITLE;
}

// Use colour if specified, else use default
if (!empty($cat['colour'])){
$catcolour=$cat['colour'];
}
else {
$catcolour= CFG_COLOUR;
}







?>
plz help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 12-29-2007, 06:32 AM
penkomitev penkomitev is offline
Learning Programmer
 
Join Date: Dec 2007
Location: Plovdiv, Bulgaria
Age: 16
Posts: 30
Rep Power: 4
penkomitev is on a distinguished road
Send a message via ICQ to penkomitev Send a message via Skype™ to penkomitev
Default

Print your sql query a look what it is and try to execute it trough PhpMyAdmin or the one you are using.
__________________
You can visit something interesting HERE
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-31-2007, 01:40 AM
mittalmak mittalmak is offline
Newbie
 
Join Date: Aug 2007
Posts: 11
Rep Power: 0
mittalmak is on a distinguished road
Default

Quote:
Originally Posted by penkomitev View Post
Print your sql query a look what it is and try to execute it trough PhpMyAdmin or the one you are using.
r u talking of creat_table.sql file the here it is
Code:
-- phpMyAdmin SQL Dump
-- version 2.8.0.3
-- http://www.phpmyadmin.net
-- 
-- Host: localhost
-- Generation Time: Aug 10, 2007 at 11:08 AM
-- Server version: 4.1.18
-- PHP Version: 5.1.2
-- 
-- Database: `misc`
-- 

-- --------------------------------------------------------

-- 
-- Table structure for table `qa_admin`
-- 

CREATE TABLE `qa_admin` (
  `id` tinyint(4) NOT NULL auto_increment,
  `user` varchar(64) NOT NULL default '',
  `pass` varchar(64) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

-- 
-- Dumping data for table `qa_admin`
-- 

INSERT INTO `qa_admin` (`id`, `user`, `pass`) VALUES (1, 'admin', '1a1dc91c907325c69271ddf0c944bc72');

-- --------------------------------------------------------

-- 
-- Table structure for table `qa_categories`
-- 


CREATE TABLE `qa_categories` (
  `id` int(11) NOT NULL auto_increment,
  `category` varchar(64) NOT NULL default '',
  `useimage` tinyint(4) default NULL,
  `image` varchar(64) NOT NULL default '',
  `colour` varchar(16) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

-- 
-- Dumping data for table `qa_categories`
-- 

INSERT INTO `qa_categories` (`id`, `category`,`useimage`, `image`, `colour`) VALUES (4, 'Health & Fitness',2, 'tennis_ball.jpg', '577f10'),
(5, 'Cars & Driving',2, 'cat_car.jpg', 'c8541f'),
(6, 'Travel & Holidays',2, 'globe.jpg', '25aee8');

-- --------------------------------------------------------

-- 
-- Table structure for table `qa_keywords`
-- 

CREATE TABLE `qa_keywords` (
  `id` int(11) NOT NULL auto_increment,
  `keyword` varchar(64) NOT NULL default '',
  `categoryid` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;

-- 
-- Dumping data for table `qa_keywords`
-- 

INSERT INTO `qa_keywords` (`id`, `keyword`, `categoryid`) VALUES (1, 'buy used car', 5),
(2, 'buy new car', 5),
(3, 'selling a car', 5),
(4, 'driving license', 5),
(5, 'learning to drive', 5),
(10, 'health spa', 4),
(11, 'sports club', 4),
(12, 'swimming', 4),
(13, 'football', 4),
(14, 'gymnasium', 4),
(15, 'tennis club', 4),
(16, 'golf course', 4),
(17, 'cheap flights', 6),
(18, 'cheap hotels', 6),
(19, 'package holidays', 6),
(20, 'driving directions', 6),
(21, 'camp sites', 6);

-- --------------------------------------------------------

-- 
-- Table structure for table `qa_questions`
-- 

CREATE TABLE `qa_questions` (
  `id` int(11) NOT NULL auto_increment,
  `keywordid` int(11) NOT NULL default '0',
  `questionid` varchar(32) NOT NULL default '',
  `subject` varchar(128) NOT NULL default '',
  `content` text NOT NULL,
  `timestamp` varchar(16) NOT NULL default '',
  `category` varchar(32) NOT NULL default '',
  `answer` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=240 ;


-- --------------------------------------------------------

-- 
-- Table structure for table `qa_configuration`
-- 

CREATE TABLE `qa_configuration` (
  `id` tinyint(4) NOT NULL auto_increment,
  `name` varchar(32) NOT NULL default '',
  `value` varchar(128) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=26 ;

-- 
-- Dumping data for table `qa_configuration`
-- 

INSERT INTO `qa_configuration` (`id`, `name`, `value`) VALUES (2, 'CFG_COLOUR', 'c8541f'),
(4, 'CFG_IMAGE', 'titleimage.jpg'),
(5, 'CFG_SHOWSIMILAR', '1'),
(6, 'CFG_SHOWSIMILARAMT', '5'),
(7, 'CFG_TITLE', 'Questions Answered'),
(8, 'CFG_ADSENSEID', 'pub-xxxxxxxxxxxxxxxx'),
(9, 'CFG_MAXQUESTIONS', '40'),
(10, 'CFG_MAXIMAGES', '200'),
(11, 'CFG_YAHOOAPIID', 'YahooDemo'),
(12, 'CFG_FLICKRAPIID', '7cf20bdc57f9b6e9e3ce3972beae9610'),
(13, 'CFG_SHOWQUESTIONS', '8'),
(14, 'CFG_USEAVATAR', '2'),
(15, 'CFG_AVATARIMAGE', NULL),
(16, 'CFG_AVATARWIDTH_Q', '80'),
(17, 'CFG_AVATARHEIGHT_Q', '80'),
(18, 'CFG_SHOWAVATAR_Q', '1'),
(19, 'CFG_SHOWAVATAR_A', '1'),
(20, 'CFG_AVATARHEIGHT_A', '80'),
(21, 'CFG_AVATARWIDTH_A', '80'),
(22, 'CFG_MATCHKEYWORDS', 'all'),
(23, 'CFG_REGION', 'us'),
(24, 'CFG_USEIMAGE', '1'),
(25, 'CFG_MODIFYCONTENT', NULL);


-- 
-- Host: localhost
-- Generation Time: Aug 25, 2007 at 11:42 AM
-- Server version: 4.1.18
-- PHP Version: 5.1.2
-- 
-- Database: `misc`
-- 

-- --------------------------------------------------------

-- 
-- Table structure for table `qa_images`
-- 

CREATE TABLE `qa_images` (
  `id` int(11) NOT NULL auto_increment,
  `keywordid` int(11) NOT NULL default '0',
  `imageurl` text NOT NULL,
  `imagealt` varchar(64) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-31-2007, 04:14 AM
penkomitev penkomitev is offline
Learning Programmer
 
Join Date: Dec 2007
Location: Plovdiv, Bulgaria
Age: 16
Posts: 30
Rep Power: 4
penkomitev is on a distinguished road
Send a message via ICQ to penkomitev Send a message via Skype™ to penkomitev
Default

Nope, query means the SQL string you are using for getting the results. An example of query is "SELECT user_id WHERE email='something@abv.bg'"

So, the script breaks at line 14, I calculated that this is your first query.

Code:
$configuration_query = mysql_query('select name as cfgKey, value as cfgValue from ' . TABLE_PREFIX . 'configuration');
But you can't print it that way. Make it
Code:
$q = 'select name as cfgKey, value as cfgValue from ' . TABLE_PREFIX . 'configuration');
print $q;

Look at the result, printed in the browser and copy it into phpMyAdmin SQL section(second on the menu after you choose your database) and execute it. PhpMyAdmin will show your error. Alternatively make your query that way:

Code:
mysql_query('select name as cfgKey, value as cfgValue from ' . TABLE_PREFIX . 'configuration') or die(mysql_error());
and the error will be shown if the query fail to execute.
__________________
You can visit something interesting HERE
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-01-2008, 05:57 AM
mittalmak mittalmak is offline
Newbie
 
Join Date: Aug 2007
Posts: 11
Rep Power: 0
mittalmak is on a distinguished road
Default

here it is

Code:
SQL query:  

mysql_query(

'select name as cfgKey, value as cfgValue from '.TABLE_PREFIX. 'configuration'
) OR die(
mysql_error(
)
)
Code:
MySQL said:  

#1064 - 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 'mysql_query('select name as cfgKey, value as cfgValue from ' . TABLE_PREFIX . 'c' at line 1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 01-01-2008, 10:59 AM
penkomitev penkomitev is offline
Learning Programmer
 
Join Date: Dec 2007
Location: Plovdiv, Bulgaria
Age: 16
Posts: 30
Rep Power: 4
penkomitev is on a distinguished road
Send a message via ICQ to penkomitev Send a message via Skype™ to penkomitev
Default

Wow,
I am sure you have done mysql_query(mysql_query));
Look at my previous post and espescially on the value of $q. Print just $q and copy the printed text from the browser. Then this text execure in phpMyAdmin.


Edit: I am sorry there is one ')' but you could see there isn't '(', so it is unnecessary.

So make it:

Code:
$q = 'select name as cfgKey, value as cfgValue from ' . TABLE_PREFIX . 'configuration';
print $q;
to get the text of the query in the browser. Then execute it and write again .
__________________
You can visit something interesting HERE

Last edited by penkomitev; 01-01-2008 at 11:01 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-02-2008, 05:06 AM
mittalmak mittalmak is offline
Newbie
 
Join Date: Aug 2007
Posts: 11
Rep Power: 0
mittalmak is on a distinguished road
Default

here it is
Code:
SQL query: Documentation

$q = 'select name as cfgKey, value as cfgValue from '.TABLE_PREFIX. 'configuration';
Code:
MySQL said: Documentation
#1064 - 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 '$q = 'select name as cfgKey, value as cfgValue from ' . TABLE_PREFIX . 'configur' at line 1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-02-2008, 03:03 PM
penkomitev penkomitev is offline
Learning Programmer
 
Join Date: Dec 2007
Location: Plovdiv, Bulgaria
Age: 16
Posts: 30
Rep Power: 4
penkomitev is on a distinguished road
Send a message via ICQ to penkomitev Send a message via Skype™ to penkomitev
Default

I need the printed string of $q and the structure of your SQL table in order to help you.
__________________
You can visit something interesting HERE
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-03-2008, 09:40 AM
mittalmak mittalmak is offline
Newbie
 
Join Date: Aug 2007
Posts: 11
Rep Power: 0
mittalmak is on a distinguished road
Default

Quote:
Originally Posted by penkomitev View Post
I need the printed string of $q and the structure of your SQL table in order to help you.
i didn't get u..........
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 01-03-2008, 09:55 AM
penkomitev penkomitev is offline
Learning Programmer
 
Join Date: Dec 2007
Location: Plovdiv, Bulgaria
Age: 16
Posts: 30
Rep Power: 4
penkomitev is on a distinguished road
Send a message via ICQ to penkomitev Send a message via Skype™ to penkomitev
Default

Well,

you have this as query:

Code:
$q = 'select name as cfgKey, value as cfgValue from '.TABLE_PREFIX. 'configuration';
Please in your PHP code do:

Code:
$q = 'select name as cfgKey, value as cfgValue from '.TABLE_PREFIX. 'configuration';
print $q;
The result of the query will appear in the browser. I want to look at this result.

I also need the structure of your table(I mean the fields you have, what are their types and so on. - You can extract it via PHPMyAdmin. Just click on your table, then Export, click Ok, and the SQL structure will appear as a query. Then copy it here).

Edit: Sorry, you have posted your SQL structure in your previous post. So just the value of $q.

Edit2: After reading the SQL strucure, I think only the print will bring enough information. It is possible this TABLE_PREFIX not to have the right value.
__________________
You can visit something interesting HERE

Last edited by penkomitev; 01-03-2008 at 10:43 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql/php backbone implementation question for an online cash/gambling game ISee PHP Forum 0 10-30-2007 09:53 AM


All times are GMT -5. The time now is 05:50 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads