wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
At the top of your script add the following error_reporting(E_ALL); ini_set('display_error', true); Post the error(s) you get. White blank page usually indicates there is a fatal error.
-
Parsing XML and removing parent if link = string
wildteen88 replied to mkrisch's topic in PHP Coding Help
Change <?php foreach ($rss->channel->item as $items): ?> To <?php foreach ($rss->channel->item as $items): // skip entry if link begins with http://www.newsweek.com/the-score if(substr($items->link, 0, 33) == 'http://www.newsweek.com/the-score') continue; ?> -
Reading contents of a folder and putting the filenames into a db
wildteen88 replied to bradholland's topic in PHP Coding Help
This a:18:{i:0;s:23:"14 Mr Magic Premier.mp3";i:1;s:23:"track1.mp3";i:2;s:15:"track2.jpg";i:3;s:15:"track3.fxp";i:4;s:12:"track4.mp3";i:5;s:7:"track5.mp3";i:6;s:7:"track6.jpg";i:7;s:7:"track7.mp3";i:8;s:12:"track8.mp3" Is the result of an array being serialized, which is the contents of the $listDir variable. If you want to insert each track as a new entry into your database you don't want to be serializing your array. You'll want to loop through your array instead. So instead of $colors=serialize($listDir); //takes the data from a post $sql="INSERT INTO ml_music (ID, title, added) VALUES('','$colors','')"; $result = mysql_query($sql) or die (mysql_error()); You'd want to be dynamically generating your SQL Query. An example would be $sql = 'INSERT INTO ml_music (title, added) VALUES'; foreach($listDir as $mp3_entry) $sql .= " ('$mp3_entry', NOW()),"; $sql = substr($sql, 0, strlen($sql)-1); echo "Generated SQL Query:<br />$sql"; $result = mysql_query($sql) or die (mysql_error()); -
After this line $etime_res = oci_fetch_assoc($etime_go); do echo "<pre>" . print_r($etime_res, true) . "</pre>"; What is the output?
-
Add a forward slash before logout.php, eg <form action="/logout.php">
-
If each username is on its own line, then use file to read the text file. To pick a random username you'd use array_rand. $usernames = file('usernames.txt'); // get a random username $random_line = array_rand($usernames); $random_username = $usernames[$random_line]; echo 'Current Username: ' . $random_username; // remove the random username unset($usernames[$random_line]); // rewrite the usernames back to the text file. $handle = fopen('usernames.txt', 'w'); $data = implode($usernames); fwrite($handle, $data); fclose($handle);
-
Need help getting a Limit function to work...
wildteen88 replied to Seaholme's topic in PHP Coding Help
You'd use a single sql query, SELECT COUNT(*) AS messagecount FROM chatmessages ORDER BY postime DESC LIMIT 20 -
Just added INNER JOIN to my SQL and it's not working now?!
wildteen88 replied to jarv's topic in MySQL Help
Do not use Select all (SELECT * FROM) when joining tables. Always explicitly state the columns you're wanting your query to return. Your query is most proabably failing because both tables have a column which is named the same, ie PUBID. This will cause MySQL to return an error like 'column name too ambiguous in where clause' -
Yes thats sort if it. However you should note that MySQL has a SELECT INTO statement, which will write the results of an SQL query into a table. An example can be found here http://www.w3schools.com/sql/sql_select_into.asp
-
Sound like you only need to use a simple sql query. SELECT column_name FROM table_name WEHERE column_name='some value to match'
-
Move these lines ini_set ('display_errors', 1); error_reporting (E_ALL); So they are before the session_start(); line. Are any errors shown?
-
Move echo $next; Up one line, so its within your while loop, as this is where you're defining the variable $next
-
Just so you know with Ubuntu the Apache repos comes with some tools, which are a2enmod and a2dismod for enabling/disabling Apache modules. For example if you want to enable mod_rewrite you'll run the following command sudo a2enmod rewrite Apaches configuration file on Ubuntu is apache2.conf rather than httpd.conf for some reason. However httpd.conf can still be used.
-
Oops. I coded the while loop wrong. It should be like if($result) { while(list($id, $text) = mysql_fetch_row($result)) $lang[$id] = $text; }
-
Jquery change css property - shouldn't this work?
wildteen88 replied to V's topic in Javascript Help
You'll need to iterate through all elements with the class name of color_test <script type="text/javascript"> $(function() { $('.color_test').each(function(i) { if($(this).attr("id") == $(this).attr("name")) $(this).css({"background-color":"green"}); else $(this).css({"background-color":"red"}); }); }); </script> -
Scrapping the Product Titles from a Webpage in an Array?
wildteen88 replied to natasha_thomas's topic in PHP Coding Help
I've never used DOM/Xpath, so I'm learning too . Hum, This what I came up with, probably could of been done better by extending the DomXPath class maybe. $nodekw = "diamond red gold ring"; $dom = new DomDocument();libxml_use_internal_errors(true); if ($dom->loadHtmlFile('http://www.nextag.com/serv/main/buyer/OutPDir.jsp?search='. $nodekw .'&perpagePersistent=60')) { $xpath = new DomXPath($dom); $products = array(); // add to products array foreach ($xpath->query('//a[@class="underline"]') as $node) { if(substr($node->nodeValue, 0, 1) != '$') $products[] = $node->nodeValue; } // now we can shuffle the results shuffle($products); // output the products foreach($products as $product) { $nodekw = stripslashes(str_replace('+', '-', urlencode($product))); echo "<a href='".($nodekw).".htm'>".Ucwords($product)."</a>". "<br/>\n"; echo '<hr />'; } } -
Scrapping the Product Titles from a Webpage in an Array?
wildteen88 replied to natasha_thomas's topic in PHP Coding Help
Change foreach ($xpath->query('//a[@class="underline"]') as $node) to $products = $xpath->query('//a[@class="underline"]'); shuffle($products); foreach ($products as $node) -
You'll need to use an MySQL query first. Really basic example $sql = 'SELECT text FROM en WHERE ref=1'; $result = mysql_query($sql); if($result) { list($lang_text) = mysql_fetch_row($result) echo "<b>$lang_text</b>"; } else { echo 'Cannot find language text'; } However you wouldn't want to do that for every bit of text you want to output. Instead you'll be better of getting all the text from the database first $sql = 'SELECT ref, text FROM en'; $result = mysql_query($sql); if($result) { while($row = mysql_fetch_row($result)) { list($id, $text) = mysql_fetch_row($result); $lang[$id] = $text; } } Now for each bit of text you want you'll just echo out the nesseccary variable ([ tt]echo $lang[ref id]; ), eg echo $lang[1] . '<br />' . $lang[2];
-
Require what page? NOTE: You may want to edit your post and remove your database credentials
-
Removing the "description" column via .htaccess
wildteen88 replied to Luigi987's topic in Apache HTTP Server
Do you mean remove the description column from the directory index? Have a read of the Apache documentation on the IndexOptions directive, there many configuration options for changing the layout. However to remove the description column you may add this to an .htaccess file IndexOptions +SuppressDescription -
You have spaces in your filename? Try not to add any spaces within filepaths. It is best practice to substitute spaces with either an underscore (_) or a hyphen (-). Alternatively you could use camel case, eg CssStylesSticky.css The link tag should be between the <head></head> tags. It may be helpful if you posted your actual HTML rather than snippets.
-
You have some form of output which is causing the error. You should note anything outside of your <?php ?> tags is considered output, and also when you're echoing/printing etc. In order to solve this you need to find out where the output is comming from. This is actually given to you within the error message, eg However you have sensored too much information for me to tell you where the output is.
-
Scrapping the Product Titles from a Webpage in an Array?
wildteen88 replied to natasha_thomas's topic in PHP Coding Help
Change $xpath->query('//a[@class="underline"]') to $xpath->query('//a[@class="underline" and starts-with(@id,"opPNLink")]') -
On line 16 you're calling a function called SHA(), this function does not exist within your script. $_SESSION['pass_phrase'] = SHA($pass_phrase); I think you meant to call sha1 On line 40 make sure the font file (Courier New Bold.ttf) is within the same directory as your script. PHP does not search your computers font directory for fonts
-
A similar question was asked here. It may help you.