snowdog Posted January 26, 2012 Share Posted January 26, 2012 I haven't coded in about a year and am a little rusty. Here is the code. I have turned error reporting on but for some reason it is not working on my server. <?php // Load The dealers in for the franchisee include("include/db_connect.php"); SESSION_START(); $franchise_id = $_SESSION['franchise_id']; // Query the database and get dealers $SQL = "SELECT * FROM dealers WHERE franchise_id = '$franchise_id' ORDER BY name ASC"; $result = mysql_fetch_array($SQL) or die(mysql_error()); while($run = mysql_fetch_array($result)) { ?><option value="<? echo $run['id']; ?>"><? echo $run["name"]; ?></option> <? } ?> Link to comment https://forums.phpfreaks.com/topic/255837-code-not-working/ Share on other sites More sharing options...
Psycho Posted January 26, 2012 Share Posted January 26, 2012 Please be specific by what is meant by "Not working". Are you getting ANY output. If so, how does that output differ from your expectations? Did you look at the HTML source code in your browser to see what is in there that isn't directly displayed in the page? If you are not getting any errors it could be: 1. The server does not have PHP installed so the file is sent as a plain HTML file and the PHP code will not be displayed in the browser because the PHP tags are treated like HTML tags. 2. The query is not returning any results Link to comment https://forums.phpfreaks.com/topic/255837-code-not-working/#findComment-1311480 Share on other sites More sharing options...
Julius Posted January 26, 2012 Share Posted January 26, 2012 $result = mysql_fetch_array($SQL) or die(mysql_error()); You didn't execute query. Replace that line to this $result = mysql_query($SQL) or die(mysql_error()); Also, use <?php ?> instead of <? ?> Link to comment https://forums.phpfreaks.com/topic/255837-code-not-working/#findComment-1311508 Share on other sites More sharing options...
snowdog Posted January 26, 2012 Author Share Posted January 26, 2012 Thanks Julius, stupid mistake. Sometimes it is hard to wee when you write it yourself. At least i have that problem anyway. Link to comment https://forums.phpfreaks.com/topic/255837-code-not-working/#findComment-1311530 Share on other sites More sharing options...
Pikachu2000 Posted January 27, 2012 Share Posted January 27, 2012 Sometimes it is hard to wee . . . And the older you get, the harder it will get. Link to comment https://forums.phpfreaks.com/topic/255837-code-not-working/#findComment-1311751 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.