ecabrera Posted April 14, 2012 Share Posted April 14, 2012 ok so i wan to use substr but i gives me Warning: substr() expects parameter 2 to be long, string given in C:\xampp\htdocs\ede\index.php on line 48 here the code <?php include "staff/scripts/connect.php"; $query = mysql_query("SELECT * FROM headlines ORDER BY id DESC LIMIT 3"); $rows = mysql_fetch_assoc($query); $author = stripslashes($rows['author']); $date = stripslashes($rows['date']); $picture = stripslashes($rows['picture']); $headline = stripslashes($rows['headline']); mysql_close(); ?> <h2 class="boxtitle">Latest Headlines</h2> <?php do{ ?> <div id="boxhome"> <img src="staff/headlineimg/<?php echo $rows['picture']; ?>" width="100px" height="90px" class="boximg"></img> <div class="boxtitle1"> <font color="#A61E0A"><strong><?php echo $rows['title']?></strong></font><br> <?php echo substr(0,$headline,6)?> </div> </div> <?php }while($rows = mysql_fetch_assoc($query))?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/260908-substr/ Share on other sites More sharing options...
ecabrera Posted April 14, 2012 Author Share Posted April 14, 2012 ok fixed it i messed up here <?php echo substr(0,$headline,6)?> it should be <?php echo substr($rows['headline'],0,10)?> Quote Link to comment https://forums.phpfreaks.com/topic/260908-substr/#findComment-1337251 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.