-
Posts
49 -
Joined
-
Last visited
Everything posted by cataiin
-
Forgot ; at the end of line 11. Edit: too late.
-
Replace utf8 character in a certain position of a string
cataiin replied to filoaman's topic in PHP Coding Help
<?php $text = "Thîs îs ã ütf8 strîng"; $replace = array( 'i' => array('î'), 'a' => array('ã'), 'u' => array('ü') ); foreach ($replace as $changed => $initial) { $text = str_replace($initial, $changed, $text); } echo $text; ?>iconv example: <?php $text = "Thîs îs ã ütf8 strîng"; echo iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text); ?>But this will remove diacritics, and is not what you want. Use first code, sorry. -
Replace utf8 character in a certain position of a string
cataiin replied to filoaman's topic in PHP Coding Help
http://ca3.php.net/manual/en/function.iconv.php -
count views: mysql_query("UPDATE apps SET views=views+1 WHERE id='".$id."'"); show 5 most viewed: mysql_query("SELECT * FROM apps ORDER BY views DESC LIMIT 0, 5"); Don't forget to add column "views". My code is just an example.
-
$news_title = mysql_real_escape_string($_POST['news_title']); $publish="INSERT INTO news(news_title,news_subtitle,news_desc,news_post,news_date,hour,news_image,news_image_peq,categoria) VALUES('$news_title','".$_POST["news_subtitle"]."','".$_POST["news_desc"]."','".$_POST["news_post"]."','".$_POST["news_date"]."','".$_POST["hour"]."','".$_POST["news_image"]."','".$_POST["news_image_peq"]."','".$_POST["categoria"]."')"; Ofc, for every value you send to MySQL.
-
You can store the files on your server temporarily and then use getimagesize.
- 6 replies
-
- file_exists
- images
-
(and 1 more)
Tagged with:
-
http://us2.php.net/manual/en/mysqli.multi-query.php
-
Counting number of columns with the same number
cataiin replied to therocker's topic in PHP Coding Help
I tried the code on localhost first time and I was wrong when I changed the values. Sorry! He just needs to modify the first count with forums_id in my code. -
I can't edit my post. Try this: <?php $image = "http://forums.phpfreaks.com/uploads/profile/photo-thumb-165140.jpg"; if(@getimagesize($image) !== false) { echo "<img src=".$image." />"; } else { echo "Nop."; } ?>
- 6 replies
-
- file_exists
- images
-
(and 1 more)
Tagged with:
-
Link for image?
- 6 replies
-
- file_exists
- images
-
(and 1 more)
Tagged with:
-
index.php <html lang="en"> <head> <meta charset="UTF-8" /> </head> <body> <ul> <li><a href="/1">Item 1</a></li> <li><a href="/2">Item 2</a></li> <li><a href="/3">Item 3</a></li> <li>etc</li> </ul> </body> </html> item.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> </head> <body> <?php $id = $_GET['id']; $connection = mysqli_connect("localhost", "user", "pass", "database"); if(mysqli_connect_errno()) { echo "Failed to connect to MySQL: " .mysqli_connect_error(); } $result = mysqli_query($connection,"SELECT * FROM items WHERE id='".$id."'"); while($row = mysqli_fetch_array($result)) { var_dump($row); } mysqli_close($connection); ?> </body> </html> and .htaccess RewriteEngine on RewriteRule ^([0-9]+)$ /item.php?id=$1 Sorry but my english sucks.
-
Counting number of columns with the same number
cataiin replied to therocker's topic in PHP Coding Help
SELECT count, count(*) as forums_counting FROM forums_comment WHERE forums_id = '$forums_id' GROUP BY forums_id -
You can use $_GET['id]; in item.php page to get item.php?id=1 (content from current item1.php) and then with RewriteRule: RewriteRule ^([0-9]+)$ /item.php?id=$1 Ask if you have more questions.
-
try <html> <head> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> </head> <body> <form action="loginpage.php" method="post"> Username: <input type="text" name="user"> Password: <input type="password" name="pass"> <input type="submit"> </form> </html> <?php $username = $_POST['user']; $password = ""; $errormess = ""; if($_SERVER['REQUEST_METHOD'] == 'POST') { $myconn=mysqli_connect("***********","************,"************"); $mydb=mysqli_select_db($myconn,"myConferenceCalls"); if($mydb) { echo "Connected to D/B"; $sql = "SELECT * FROM myUsers WHERE Username='$username'"; $sqlresult = mysqli_query($sql); $valid = mysqli_num_rows($sqlresult); echo "$username"; if($valid==1) { echo "Valid Username"; } else { echo "Invalid Username"; } mysqli_close($myconn); } else { echo "Could not connect to D/B"; mysqli_close($myconn); } } ?> Your code is a little odd.
-
http://php.net/manual/en/function.checkdnsrr.php
-
I want to use RewriteRule two times, first to change /page.php?id=1321 to /1321 and second to change /search.php?text=ab aa&page=2 to /search/ab--aa/2 but I don't know how because it has two queries (text and page). Until now, I have this: RewriteEngine On RewriteRule ^([0-9]+)$ /page.php?id=$1 Also, I want (if it's possible) to allow only letters (uppercase and lowercase) and spaces for text and transform spaces in - or _, and for page I want only numbers. I've tried with: RewriteRule ^(.+)/(\d+)$ /search.php?text=$3&&page=$2 [L] But isn't working and I'm pretty sure it will not accept just what I want..
-
More than perfect! Thanks!
-
No idea about fixing with preg_match? Or anything else... Ty!
-
Don't work. Notice: Trying to get property of non-object in www\index.php on line 10 Probably because the string comes from external URL.
-
321313-0381","something":"value,"
-
Hi guys. I have this "sentence": "key":"321313-0381","something":"value," and I want to obtain only 321313-0381. The problem is somethings differs, isn't always the same. I've tried: $start = '"key":"'; $end = '","'; preg_match("/$start(.*)$end/s", $content, $match); $result = $match[1]; echo "$result"; But unsuccessful. For $end = '\/'; too. Can I get a little help?
-
I have this code: <?php $url = "http://www.example.com/"; $page = fopen($url, 'r'); $content = ""; while( !feof( $page ) ) { $buffer = trim( fgets( $page, 4096 ) ); $content .= $buffer; } $start = "<text1>"; $end = "<\/text2>"; preg_match( "/$start(.*)$end/s", $content, $match); $mytext = $match[1]; echo "$mytext"; ?> Now, I need a way for users to enter $url. I've tried with $_GET and to get current url (something like index.php?url=$url) but unsuccessful.
-
Hei. Sorry for bad english. Need a little help. I have this code: $mama = $_SERVER['REQUEST_URI']; $tata = rawurldecode($mama); $asta= 'titlu='; preg_match("|$asta(.*)|",$tata,$bunica); $tataie = $bunica['1']; echo $tataie; Result is: Now I want to get some text from that page. There is something like: "class":"cjbzeo"," and I need only cjbzeo. Thanks!