Jump to content

Quick Question - DB not accessible from on server?


Solarpitch

Recommended Posts

Heys Guys,

I've just uploaded my site onto the server today, just want to test some database connection and what not. When the application tries to access the DB I get the message "no database selected" in place of my result set.

heres an example of my syntax. "myDatabase has been created successfully in cpanel". The DB works fine locally.

[code]$mysql_connect = new mysqli("localhost", "admin", "********");
$mysql_connect->select_db('myDatabase');
[/code]

Anyone any ideas as to why? ^_^
Link to comment
Share on other sites

Hi, there ya go. Now this all works perfect off the server. Problems just started once I uploaded it. If I put in the wrong password i'll get all the usual error messages abotu mysql_connect. . admin@local . . blah

[code]
$query = "SELECT count(*) FROM ads WHERE class = 'Irons' AND validation = 1";
$result = mysqli_query($mysql_connect, $query) or die (mysqli_error($mysql_connect));
[/code]
Link to comment
Share on other sites

Oh . . I query it twice . . for pagination purposes.

[code]
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;
$query = "SELECT * FROM adds WHERE class = 'Irons' AND validation = 1 ORDER BY '$orderby' $limit";
$result = mysqli_query($mysql_connect, $query) or die (mysqli_error($mysql_connect));
[/code]
Link to comment
Share on other sites

[CODE]
<?php
$result = mysql_query($mysql_connect, $query) or die (mysqli_error($mysql_connect));
?>
[/CODE]
or try this
[CODE]
<?php
$result = mysql_query($query, $mysql_connect) or die (mysqli_error($mysql_connect));
?>
[/CODE]

in ur original one u had an i after mysqli
Link to comment
Share on other sites

[quote author=chriscloyd link=topic=120902.msg496442#msg496442 date=1167864119]
[CODE]
<?php
$result = mysql_query($mysql_connect, $query) or die (mysqli_error($mysql_connect));
?>
[/CODE]
or try this
[CODE]
<?php
$result = mysql_query($query, $mysql_connect) or die (mysqli_error($mysql_connect));
?>
[/CODE]



[/quote]

Yeah . . neither seem to work. Do you guys really think it could be a problem with the query statements as they work perfect locally?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.