Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
mysql_result() error.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Marlboro20" data-source="post: 299647" data-attributes="member: 40837"><p>Not an expert but shouldn't it be like this?</p><p>[CODE]</p><p><?php</p><p>// Create connection</p><p>$con=mysql_connect('HOST', 'USERNAME', 'PASSWORD')</p><p>mysql_select_db('DBNAME', $con);</p><p></p><p>// Check connection</p><p>if (!$con)</p><p>{</p><p> echo "Failed to connect to MySQL: " . mysql_connect_error();</p><p>}</p><p>?></p><p></p><p><center><li class="active"><center>User(s) Online : <span class="badge"><?php echo mysql_result(mysql_query("SELECT online_now FROM stats;"),0); ?></span> | Total Cloudflare Resolved : <span class="badge"><?php echo mysql_result(mysql_query("SELECT cloudflare_resolved FROM stats;"),0); ?></span> | Total Skype Resolved : <span class="badge"><?php echo mysql_result(mysql_query("SELECT skype_resolved FROM stats;"),0); ?></span> | Online Today : <span class="badge"><?php echo mysql_result(mysql_query("SELECT online_today FROM stats;"),0); ?></span> </center></p><p></p><p>[/CODE]</p><p></p><p>You could do something like this </p><p>[PHP]</p><p><?php</p><p>// Create connection</p><p>$connection = new mysqli('HOST', 'USERNAME', 'PASSWORD', 'DBNAME') or die(mysqli_connect_error());</p><p>$stats = function($row) {</p><p> global $connection;</p><p> </p><p> $query = mysqli_query($connection, 'SELECT ' . $row . ' FROM stats;');</p><p> $array = $query->fetch_array(MYSQLI_NUM);</p><p> </p><p> return $array[0];</p><p>};</p><p>?></p><p><center><li class="active"><center>User(s) Online : <span class="badge"><?php echo $stats('online_now'); ?></span> | Total Cloudflare Resolved : <span class="badge"><?php echo $stats('cloadflare_resolved'); ?></span> | Total Skype Resolved : <span class="badge"><?php echo $stats('skype_resolved'); ?></span> | Online Today : <span class="badge"><?php echo $stats('online_today'); ?></span> </center></p><p>[/PHP]</p></blockquote><p></p>
[QUOTE="Marlboro20, post: 299647, member: 40837"] Not an expert but shouldn't it be like this? [CODE] <?php // Create connection $con=mysql_connect('HOST', 'USERNAME', 'PASSWORD') mysql_select_db('DBNAME', $con); // Check connection if (!$con) { echo "Failed to connect to MySQL: " . mysql_connect_error(); } ?> <center><li class="active"><center>User(s) Online : <span class="badge"><?php echo mysql_result(mysql_query("SELECT online_now FROM stats;"),0); ?></span> | Total Cloudflare Resolved : <span class="badge"><?php echo mysql_result(mysql_query("SELECT cloudflare_resolved FROM stats;"),0); ?></span> | Total Skype Resolved : <span class="badge"><?php echo mysql_result(mysql_query("SELECT skype_resolved FROM stats;"),0); ?></span> | Online Today : <span class="badge"><?php echo mysql_result(mysql_query("SELECT online_today FROM stats;"),0); ?></span> </center> [/CODE] You could do something like this [PHP] <?php // Create connection $connection = new mysqli('HOST', 'USERNAME', 'PASSWORD', 'DBNAME') or die(mysqli_connect_error()); $stats = function($row) { global $connection; $query = mysqli_query($connection, 'SELECT ' . $row . ' FROM stats;'); $array = $query->fetch_array(MYSQLI_NUM); return $array[0]; }; ?> <center><li class="active"><center>User(s) Online : <span class="badge"><?php echo $stats('online_now'); ?></span> | Total Cloudflare Resolved : <span class="badge"><?php echo $stats('cloadflare_resolved'); ?></span> | Total Skype Resolved : <span class="badge"><?php echo $stats('skype_resolved'); ?></span> | Online Today : <span class="badge"><?php echo $stats('online_today'); ?></span> </center> [/PHP] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
mysql_result() error.
Top