/    Sign up×
Community /Pin to ProfileBookmark

Playing around with a mysql api

I am playing around with making a simple mysql api.

[B]The API Class[/B]:

[CODE]
CLASS testClass {

FUNCTION connectLocal($user, $pass) {
$local = my_sql(‘localhost’, $user, $pass)
IF (!$local) { DIE(‘connection error’); }
}

FUNCTION query($sql) {
RETURN mysql_query($string);
}
}
[/CODE]

[B]Test.php[/B]:

[CODE]
$db = new testClass;
$db->connectLocal(‘user’, ‘pass’)
$db->query(‘SELECT * FROM table1’);
[/CODE]

The error I get is:[INDENT]
Parse error: syntax error, unexpected T_VARIABLE in test.php
[/INDENT]

If I put the querry inside the classes connectLocal function it works fine. Anywhere else it throws this error.

Any ideas? Thanks in advance.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bokehAug 18.2006 — [CODE]
$db = new testClass;
$db->connectLocal('user', 'pass')
$db->query('SELECT * FROM table1');
[/CODE]
[/QUOTE]
No delimiter on line 2.[I][code=php]FUNCTION query($sql) {
RETURN mysql_query($string);
}[/code]
[/I]Where is [I]$string[/I] coming from?
Copy linkTweet thisAlerts:
@ilbonparaurtiauthorAug 18.2006 — Thanks

...feel kinda stupid now :rolleyes:
×

Success!

Help @ilbonparaurti spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...