
Daegalus
Members-
Posts
11 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Daegalus's Achievements

Newbie (1/5)
0
Reputation
-
Yup I noticed that like 3 min before checking back here. I forgot to add it to the global line along with the other variables. Thanks for the help guys it all works nicely now.
-
Oh wow, i feel like a noob. Anyways all fixed up but now I get a mysql problem [phpBB Debug] PHP Notice: in file /home/vol2/manusmut/public_html/includes/functions.php on line 12: mysql_fetch_array(): supplied argument is not a valid MySQL result resource I know what it means, just i dont get how my result is not a valid mysql result resource. Oo its how i do all my mysql connections and they worked before.
-
ok well i fixed my old problem somehow, but now i cant get the fucntions file to get the proper mysql info from teh config file. [phpBB Debug] PHP Notice: in file /home/vol2/manusmut/public_html/includes/functions.php on line 3: mysql_connect() [function.mysql-connect]: Access denied for user 'manusmut'@'localhost' (using password: NO) Unable to connect to MySQL Ive tried so many include combinations but none work. here is the funcitons file: <?php function get_news() { $dbh = mysql_connect($mysql_server, $username, $password) or die("Unable to connect to MySQL"); mysql_select_db($database,$dbh) or die("Could not select " + $database); $query = "SELECT * FROM news ORDER BY date LIMIT $maxnewsitems"; $result = mysql_query($query); $newsarray = array(); while($row = mysql_fetch_array($result)) { $newsarray[] = array("id" => $row['id'], "title" => $row['title'], "author" => $row['author'], "author_id" => $row['author_id'], "body" => $row['body'], "date" => $row['date']); } return $newsarray; } header file <?php define('IN_PHPBB', true); define('PHPBB_ROOT_PATH', '../forum/'); $phpbb_root_path = PHPBB_ROOT_PATH; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup(); // Begin site header include_once '../config.php'; include_once '../includes/functions.php'; ?> and the config file jsut has the database info variables. and the $maxnewsitems variable.
-
anyone? this would really help me out and get this site done and move on with life.
-
Ok, I've been at this for 2 hours now and I can't for hte life of me figure out why this isn't working. I have a site using PHP and Javascript intertwined to make it work like AJAX but without the hassle of XMLHTTPRequest and all. So onto the problem. So hear is the stuff in the main page: <script type="text/javascript"> // Get base url url = document.location.href; xend = url.lastIndexOf("/") + 1; var base_url = url.substring(0, xend); function changeTestimonialPrev() { // Create new JS element <?php if($testimnum == 0) { $testimnum = $testimsize-1; } else { $testimnum--; } ?> var jsel = document.createElement('SCRIPT'); jsel.type = 'text/javascript'; jsel.src = base_url + 'includes/js.php?testimprev=' + <?php echo $testimnum; ?>; // Append JS element (therefore executing the 'AJAX' call) document.body.appendChild (jsel); } function changeTestimonialNext() { // Create new JS element <?php if($testimnum == $testimsize-1) { $testimnum = 0; } else { $testimnum++; } ?> var jsel = document.createElement('SCRIPT'); jsel.type = 'text/javascript'; jsel.src = base_url + 'includes/js.php?testimnext=' + <?php echo $testimnum; ?>; // Append JS element (therefore executing the 'AJAX' call) document.body.appendChild (jsel); } </script> and here is the PHP code in teh js.php file. (this tag isnt really here, i just did it so it will do the proper syntax highlighting) --> <?php $testimprev = $_GET['testimprev']; if(isset($_GET['testimprev'])) { ?> document.getElementById("testimauthor").childNodes[0].childNodes[0].data = "<?php echo $testimonials[$testimprev]['name']; ?>"; document.getElementById("testimauthor").childNodes[3].data = "<?php echo $testimonials[$testimprev]['affiliation']; ?>"; document.getElementById("testimtext").childNodes[0].data = "<?php echo $testimonials[$testimprev]['body']; ?>"; <?php for($i=0; $i<5; $i++) { if($i<$testimonials[$testimnprev]['rating']) { ?> document.getElementById("star<?php echo $i+1; ?>").childNodes[0].setAttribute("src","images/yellow-star.png"); <?php } else { ?> document.getElementById("star<?php echo $i+1; ?>").childNodes[0].setAttribute("src","images/black-star.png"); <?php } } } $testimnext = $_GET['testimnext']; if(isset($_GET['testimnext'])) { ?> document.getElementById("testimauthor").childNodes[0].childNodes[0].data = "<?php echo $testimonials[$testimnext]['name']; ?>"; document.getElementById("testimauthor").childNodes[3].data = "<?php echo $testimonials[$testimnext]['affiliation']; ?>"; document.getElementById("testimtext").childNodes[0].data = "<?php echo $testimonials[$testimnext]['body']; ?>"; <?php for($i=0; $i<5; $i++) { if($i<$testimonials[$testimnext]['rating']) { ?> document.getElementById("star<?php echo $i+1; ?>").childNodes[0].setAttribute("src","images/yellow-star.png"); <?php } else { ?> document.getElementById("star<?php echo $i+1; ?>").childNodes[0].setAttribute("src","images/black-star.png"); <?php } } } The problem is, when I click on the 2 buttons i have for prev and next. it only stays at the first and last items. I click Next and it shows the first one. and then blocks me from continueing. If i press prev it goes to the prev one, (which is hte last one) but then won't go any further. SO I assume its with my counter conditions at the beginning of prev and next, but I cant for the life of me figure out why it says on the end points nad wont go into the ones inbetween the first and last. Now Im not used to trinary so thats why i don't use it, and also I hate using echo to output html/jscript to the sourcecode, so dont comment on the closing and opening of PHP so many times please, its mainly for my sanity. The information is stored in a database that is run, and stored into an Array at the beginning of the file. form there I use the array for everything else.
-
[SOLVED] PHP won't retrieve the information from the database.
Daegalus replied to Daegalus's topic in PHP Coding Help
mysql_query only requuires the query in it. Also i got it working with your help guys, thanks. I changed the mysql_fetch_row() (since its not part of mysql_query) to mysql_fetch_assoc, and it worked instantly. Thanks guys. -
[SOLVED] PHP won't retrieve the information from the database.
Daegalus replied to Daegalus's topic in PHP Coding Help
Ok i used the new one, and i checked everything field titles are right and everything. there is data in the news table. With every new addition, the code does add another line of " - - Posted by: Admion." still no go. -
[SOLVED] PHP won't retrieve the information from the database.
Daegalus replied to Daegalus's topic in PHP Coding Help
Sjames' code gives me Fatal error: Call to undefined function mysql_fetch_while() in /var/www/WAR/include/news.php on line 10 I changed it to mysql_fetch_row(), it loads the page, but everything is empty again. -
[SOLVED] PHP won't retrieve the information from the database.
Daegalus replied to Daegalus's topic in PHP Coding Help
arg, sorry, but even after i added them it didnt work. the site is updated with the latest changes, and still doesnt pull any information. And SJames, yours gives me an undefined for mysql_fetch_while. -
[SOLVED] PHP won't retrieve the information from the database.
Daegalus replied to Daegalus's topic in PHP Coding Help
Nope doesn't work, I applied your changes, and it still results in the same. This the current code with corrections: <?php include('config.php'); $dbh = mysql_connect($mysql_server, $username, $password) or die("Unable to connect to MySQL"); mysql_select_db($database,$dbh) or die("Could not select " + $database); $query = "SELECT * FROM news ORDER BY id DESC LIMIT 15"; $result = mysql_db_query($database,$query,$dbh) or die("Error in query: $query. " . mysql_error()); while($row = mysql_fetch_row($result)) { ?> <tr> <td> <?php echo $row['title'] ?><br /><?php echo $row['date'] ?> - <?php echo $row['time'] ?> - Posted By: Admin </td> </tr> <tr> <td> <?php echo $row['body'] ?> </td> </tr> <br /> <br /> <br /> <?php } mysql_close($dbh); ?> -
Well im making a custom news system for a site im building, I don't like the ones already out there, and I've hit a roadblock and have 0 clue why its not working. <?php include('config.php'); $dbh = mysql_connect($mysql_server, $username, $password) or die("Unable to connect to MySQL"); mysql_select_db($database,$dbh) or die("Could not select first_test"); $query = "SELECT * FROM news ORDER BY id DESC LIMIT 15"; $result = mysql_db_query($database,$query,$dbh) or die("Error in query: $query. " . mysql_error()); while($row = mysql_fetch_row($result)) { ?> <tr> <td> <? echo $row{'title'} ?><br /><? echo $row{'date'} ?> - <? echo $row{'time'} ?> - Posted By: Admin </td> </tr> <tr> <td> <? echo $row{'body'} ?> </td> </tr> <br /> <br /> <br /> <? } mysql_close($dbh); ?> http://www.kuncheff.com:81/WAR/ is where I test it. and as you see, the normal text appears, but none of the items retrieved from the database appear. Any help would be greatly appreciated.