-
Posts
75 -
Joined
-
Last visited
Posts posted by ebchost
-
-
$datum = date('Y-m-d H:m:s');
-
i try tu insert current date and time, but, value inserted in table is 0000-00-00 00:00:00 all the time (wth no value)
[syntax=php]$sql = "INSERT INTO `rss_vesti` SET
`SAJT_ID` = '$rss_izvor_id',
`NASLOV` = '$title1',
`SLIKA` = '$image2',
`SADRZAJ` = '$descritpion_trim1',
`IZVOR` = '$link1',
`DATUM` = 'CURDATE()'";
mysql_query($sql)or die(mysql_error());[/syntax]
wer is the probelm?
-
is posible to integrate this 2 example and how ?
$podaci2 = mysql_query("SELECT * FROM rss_vesti LIMIT $granica") or die(mysql_error()); while($row = mysql_fetch_assoc( $podaci2 )) { $id = $row['ID']; $naslov = $row['TITLE']; $sadrzaj = $row['DESCRIPTION']; $slika = $row['IMAGE']; }
<?php $sTemplate = <<<XML <div class="imageElement"> <h3>{title}</h3> <p>{description}</p> <a href="#" title="open image" class="open"></a> <img src="{fileurl}" class="full" /> <img src="{fileurl}" class="thumbnail" /> </div> XML; $aUnits = array( 'image 1' => array('$row', 'pic1.jpg'), 'image 2' => array('Image 2 description', 'pic2.jpg'), 'image 3' => array('Image 3 description', 'pic3.jpg'), 'image 4' => array('Image 4 description', 'pic4.jpg'), 'image 5' => array('Image 5 description', 'pic5.jpg') ); $sGalleryObjects = ''; $sFolder = 'data_images/'; foreach ($aUnits as $sTitle => $aUnitInfo) { list($sDescription, $sFileName) = $aUnitInfo; $sFilePath = $sFolder . $sFileName; $sGalleryObjects .= strtr($sTemplate, array('{fileurl}' => $sFilePath, '{title}' => $sTitle, '{description}' => $sDescription)); } echo <<<EOF <link rel="stylesheet" href="css/main.css" type="text/css" /> <link rel="stylesheet" href="css/jd.gallery.css" type="text/css" /> <script src="js/mootools-1.2.1-core-yc.js" type="text/javascript"></script> <script src="js/mootools-1.2-more.js" type="text/javascript"></script> <script src="js/jd.gallery.js" type="text/javascript"></script> <div class="example"> <h3><a href="#">SmoothGallery examples. First - single gallery, second - multiple galleries</a></h3> <div> <div id="single_gallery"> {$sGalleryObjects} </div> <script type="text/javascript"> function startGallery() { var myGal1 = new gallery($('single_gallery'), { timed: true, delay: 5000, embedLinks: false }); } window.addEvent('domready',startGallery); </script> </div> </div> EOF; ?>
-
Can you pinpoint your problem for us please
this is code for echo rss value
$items = $rss_link->channel->item; foreach($items as $item) { $title = $item->title; echo "<h2>LOGO:</h2>$title</br>"; $link = $item->link; echo "<h2>LINK :</h2>$link</br>"; $published_on = $item->pubDate; echo "<h2>Published_on:</h2> $published_on</br>"; $description = $item->description; $descritpion_strip = strip_tags($description); $description_trim = trim($descritpion_strip); echo "<h2>description_trim:</h2> $description_trim</br><hr>"; $image_object = preg_match_all('/\"(.*?)\"/', $description, $matches); $image = str_replace( '"','',$matches[0][0]); }
this part of code colecting url of image
$image_object = preg_match_all('/\"(.*?)\"/', $description, $matches); $image = str_replace( '"','',$matches[0][0]);
and sometimes, show bad value
for example:
$image = "width: 180px; float: right; margin:3px; text-align:center;"How can I avoid this and get the correct value image url?
thanks
-
i think we (i) need update for this problem
How to correct this (upgrade)?
for some image, i have url value like this
$image = "width: 180px; float: right; margin:3px; text-align:center;"
you can check it hiar: http://moravaprom.com/ebchost/index.php
(as you can see, i make progres in my work, but i still have litle off beginig problem)
thanks in forvard
-
Pgination value for $X = 1 is:
first, -2, -1, 0, [1], 2, 3, 4, last
Pagination value for $x = $total_pages
first, 34, 35, 36, [37], 38, 39, 40, last
Note: I have 37 pages.
<?php $range = 3; for($x=($page - $range); $x < (($page + $range) + 1); $x++) { ?> <div style=' text-align: center; float:left; font-family: verdana; width: 20px; padding: 5px; margin: 1px; border-style:solid; border-width: 1px; border-color:#C8C8C8;'> <?php echo ($x == $page) ? '<strong><a href="index.php?page='.$x.'"> '.$x.' </a></strong>' : '<a href="index.php?page='.$x.'"> '.$x.' </a> '; ?> </div> <?php } ?>
How to solve this problem?
-
Why this?
How to fixed?
-
ok, thanks.
if you remember example of geting images url, from text (rss feed) for input in data base, you help me in that problem?
i $image string i have value somtimes, but is not corect url adress, in that case also, i want to giv new valu for $image
-
how to write this code?
If somthyng (string $image) is not image, or have no value, then $image = "http://www.somelink...";
-
There is probably a sql special character as part of the data. You should echo the $sql variable as part of the die(...) statement so what we could see exactly what the query is, right before the Bild point where the syntax failed.
Ultimately, you will probably find that the error is because you must escape ALL string data values being put into a query statement so that any special sql characters in the data don't break the sql syntax. See this link - mysql_real_escape_string
i think that is ok now
i will add lot`s of rss source, and then i will see
thankse
-
Its maby UTF-8 problem ?
-
Everything works perfectly when I work without inserting rss data in the database.
Wheb I've started entering data into the database, in the database is write about 200 lines in the table, and then show an error (after about 200 inserted record in database)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Bild'.', 'http://www.vesti-online.com/Sport/Fudbal/144014/Tejgo-Zelim-' at line 1
before these errors, you can see a news item to be inserted into the base hiar: http://moravaprom.com/ebchost/rss_reader.php
hiar is code of : rss_reader.php
<?php header('Content-Type: text/html; charset=utf-8'); echo "<h1>RSS vesti</h1><hr>"; $serverurl = ""; $username = ""; $password = ""; $database = ""; $rss_sajtovi = ""; mysql_connect($serverurl, $username , $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); $konekcija = mysql_connect("localhost", "morava_rss", "brodolom") or die ("Parametri za povezivanje sa bazom nisu dobri, ili baza ne postoji!"); $sajtovi = mysql_query("SELECT * FROM rss_sajtovi") or die(mysql_error()); $vesti = mysql_query("SELECT * FROM rss_vesti") or die(mysql_error()); while($row = mysql_fetch_assoc( $sajtovi )) { $id_sajta = $row['ID_SAJTA']; $naziv = $row['NAZIV']; $url_sajta = $row['URL']; $rss_izvor = $row['RSS']; $rss_kategorija = $row['kategorija']; $rss_odobren = $row['odobren']; $korisnik_id = $row['korisnik_id']; $kontrola = $row['kontrola']; $url_rss = $rss_izvor; $rss_link = simplexml_load_file($url_rss); if($rss_link) { echo '<h1>'.$rss_link->channel->title.'</h1>'; $channelimg = $rss_link->channel->image->url; echo $channelimg; echo "<img src='$channelimg' alt='$rss_link->channel->title' width='400'>"; echo "<hr>"; $items = $rss_link->channel->item; foreach($items as $item) { $title = $item->title; $link = $item->link; $published_on = $item->pubDate; $description = $item->description; $description_trim = trim($description); $image_object = preg_match_all('/\"(.*?)\"/', $description, $matches); $image = str_replace( '"','',$matches[0][0]); ?> <div style='overflow:hidden; width:420px; padding: 10px; border-style:solid; border-width: 1px; margin: 5px; '> <?php echo '<h2><a href="'.$link.'">'.$title.'</a></h2>'; ?> <div style='overflow:hidden;margin:5px; float: left;'><?php echo "<img src='$image' alt='$rss_link->channel->title' width='200'>";?></div> <div><?php echo strip_tags($description_trim);?></div> <?php echo '<span>('.$published_on.')</span>'; ?> </div> <?php $sql= "INSERT INTO `rss_vesti` VALUES('', '$id_sajta', '$title', '$image', '$description', '$link', '$published_on')"; mysql_query($sql,$konekcija)or die(mysql_error()); } } } ?>
-
your trying to get a field called post.id. but you stated your table name is postos. Is that a typo on the forum or a typo on your table name?
typo mistake an the forum
thanks,
now is corect
and,in my DB structure i have 2 tables:
1. categories - id, name,
2. posts - id, cat_id, title, contents, date_posted
-
I write first time INER JOIN and i have error
Unknown column 'posts.id' in 'field list'this is the query
<?php $query = "SELECT posts.id AS post_id, categories.id AS category_id, title, contents, date_posted, categories.name FROM posts INER JOIN categories ON categories.id = posts.cat_id"; mysql_query($query)or die(mysql_error()); ?>
and,
in my DB structure i have 2 tables:
1. categories - id, name,
2. postos - id, cat_id, title, contents, date_posted
wer is the problem?
thanks
-
update:
stop with out die("alredy exists");
i want to show message "alredy exists" with form, with out adding new record.
thanks
-
How to stop code for add new record in this situation if i have "test" categories alredy in table "categoryes" wen i want to ad new category with name "test".
file: add_category.php
(note: this file include_once("init.php"); for connection with database, who include_once "blog.php"; with function add_category and category_exist,
<?php if ($submit) { if($name) { if(strlen($name)>24) { $error = "Naziv kateogrije ne moze biti duzi od 24 karaktera"; } else if (category_exist($name)) { $error = "Kategorija postoji"; } else $upisano = "kategorija: $name je uspesno upisana u bazu"; add_category($name); } } ?> <html> <body> <h1>Add Category</h1> <hr> <?php if($error) { echo "<p>$error</p>\n"; } else echo "</br> $upisano </br>\n"; ?> ... rest of code
File: blog.php
<?php function add_category($name) { $name = mysql_real_escape_string($name); mysql_query("INSERT INTO categories SET name='{$name}'")or die(mysql_error()); } function category_exist($name) { $name = mysql_real_escape_string($name); $query = mysql_query("SELECT COUNT(1) FROM categories WHERE name = '{$name}'") or die(mysql_error()); return (mysql_result($query,0)=='0')? false: true; } ?>
-
$slika = str_replace( '"','',$matches[0][0]);
this is give resolt
Syntax
str_replace(find,replace,string,count)
thenks a lot
-
nothing new... :-\
-
$podaci = mysql_query("SELECT * FROM rss_vesti") or die(mysql_error()); while($row = mysql_fetch_assoc( $podaci )) { $naslov = $row['NASLOV']; $sadrzaj = $row['SADRZAJ']; $izvor = $row['IZVOR']; $datum = $row['DATUM']; ?> <table> <tr> <td> <?php $garbage = 'just some bs <ul><li>text</li><li>text</li><li>text</li></ul>just some more bs'; $test = preg_match_all('/\"(.*?)\"/', $sadrzaj, $matches); echo $matches[0][0]; $slika = str_replace($matches, '"', ''); echo $slika; echo "<img src='$slika' alt='' height='100' width='100'/>"; ?> </td> </tr> </table> <?php }
This code i use in this moment
resolt can be check it in http://www.moravaprom.com/ebchost/prikaz.php adres
-
now pictures have value "http://www.moravaprom.com/ebchost/prikaz.php"
-
http://www.moravaprom.com/ebchost/prikaz.php
you can see the problem hiar ?
I believe that the problem is in quotes "url" ?
-
he, i look wrong place for code
Sorry
-
$podaci = mysql_query("SELECT * FROM rss_vesti") or die(mysql_error()); while($row = mysql_fetch_assoc( $podaci )) { $naslov = $row['NASLOV']; $sadrzaj = $row['SADRZAJ']; $izvor = $row['IZVOR']; $datum = $row['DATUM']; ?> <table> <tr> <td> <?php preg_match_all('/<ul>(.*?)<\/ul>/i', $sadrzaj, $matches); echo $matches[0][0]; ?> </td> </tr> </table> <?php }
i hava emty screen, no resolts?
But, in your original code, resolt egsisting.
-
For example
<img src="http://www.vesti-online.com/data/images/2011-06-05/156013_sampioni_kf.jpg?ver=1307647416"><br/>Upravo zavrÅ¡ena klupska sezona obeležena je potpunom dominacijom Partizana, s obzirom da su sekcije naÅ¡eg najbrojnijeg sportskog druÅ¡tva osvojile Äak 11 pehara u pet najpopularnijih kolektivnih sportova.<br/><br/>this is part of som news article wich i have in my database in tabele.
How i can to separete imege url from rest part of text in 2 diferent variable
$image_url = " url image value from item";
$text = "rest of text value";
in this example final resolt wil be
$image_url = "http://www.vesti-online.com/data/images/2011-06-05/156013_sampioni_kf.jpg";
$text = "Upravo zavrÅ¡ena klupska sezona obeležena je potpunom dominacijom Partizana, s obzirom da su sekcije naÅ¡eg najbrojnijeg sportskog druÅ¡tva osvojile Äak 11 pehara u pet najpopularnijih kolektivnih sportova.";
thanks.
date query
in MySQL Help
Posted
i try to build counter with mysql
format of date1, 2 is
$date1 = date('Y-m-d');
$date2 = date('H:m:s');
this code is ok and work.
Q:
How to present with mysql all data from today ? or before 2 day, .... etc...
SELECT * FROM `rss_visitor` WHERE ? // what go hiar