takisis Posted July 24, 2015 Share Posted July 24, 2015 I am trying to display a slideshow using images and text from a database. Here is my php code to get images and text from database: <?php $dbhost = 'localhost'; $dbuser = 'takisis'; $dbpass = 'zifnab#666'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $query=mysql_query("SELECT * FROM vehicles"); echo 'ss = new slideshow("ss");'; while ($row=mysql_fetch_assoc($query)) { ?> s = new slide(); s.src = "<?php echo "<img src='data:image/jpeg;base64,".base64_encode($row['image'])."'?>"; s.text = "<?php echo "($row['year'] . $row['make'] . $row['model'] . $row['price'])"; ?>"; ss.add_slide(s); } ?> Please help Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 24, 2015 Share Posted July 24, 2015 So what's the problem? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted July 25, 2015 Share Posted July 25, 2015 sorry if this sounds too blunt, but you cannot program if you aren't looking at and learning what the statements in the code are doing. in your previous thread, you were selecting a database. in this code you are not. you cannot run a database query query unless you select a database or explicitly list the database name in the query. in your previous thread someone suggest setting php's error_reporting/display_errors settings, adding error checking logic to your database queries, and testing if queries match any rows. where is your code that's doing these things? if you always do these things, php and your code will tell you when something fails, where is it failing at, and why, or at least where to start looking to find out why it failed. you also should not be trying to use the mysql_ statements. they are obsolete and will be removed from php in the future. what you are learning now will be out of date and the code you are writing will stop working and need to be rewritten. you had mysqli_ statements in your last thread. you should have corrected that code to use ALL mysqli_ statements. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.