HI my code has an error of -

Unexpected character in input: ' in url/database.php on line 9
Parse error: syntax error, unexpected T_STRING in url/database.php on line 9

line 9 is $result = mysql_query($sql) or die(mysql_error());

Can anybody tell me what the problem is please

<?php
require_once 'config.php';

$dbConn = mysql_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
mysql_select_db($dbName) or die('Cannot select database. ' . mysql_error());

function dbQuery($sql)
{
	$result = mysql_query($sql) or die(mysql_error());
	
	return $result;
}

function dbAffectedRows()
{
	global $dbConn;
	
	return mysql_affected_rows($dbConn);
}

function dbFetchArray($result, $resultType = MYSQL_NUM) {
	return mysql_fetch_array($result, $resultType);
}

function dbFetchAssoc($result)
{
	return mysql_fetch_assoc($result);
}

function dbFetchRow($result) 
{
	return mysql_fetch_row($result);
}

function dbFreeResult($result)
{
	return mysql_free_result($result);
}

function dbNumRows($result)
{
	return mysql_num_rows($result);
}

function dbSelect($dbName)
{
	return mysql_select_db($dbName);
}

function dbInsertId()
{
	return mysql_insert_id();
}
?>

Recommended Answers

All 3 Replies

Member Avatar for P0lT10n

Hey...

require_once 'config.php';

goes between ()

require_once('config.php');

This is logical error. The sql you passed to this function has some special characters. You need to use addslashes function for all the input data used in that sql.

how are you calling dbQuery($sql) ?

there may be something wrong with the string you passed into db_query.

you can also test the db_query function by entering a simple query like

db_query("select * from table");

just to test if it's the function that's causing the problem or something else

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.