Jump to content

Alfraganus

Members
  • Posts

    60
  • Joined

  • Last visited

Posts posted by Alfraganus

  1. Dear programmers,

    I need to make website with 2 languages in Yii2 basic framework, however, I researched tons of times on google and other search engines and I could only find yii2 advanced internalisation. I need for basic mode, please if you have source codes for yii2 basic multiple languages or if you know any link or video tutorial about yii2 basic internalisation, please kindly share with me, I would be greatly appriciated.

    I am looking forward from hearing from you soon. 

  2. I was trying to make a blog with YII2,  my framework is confusing to call data from database.

    For example when I call "username" from "user" table,

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
       'user.fullname',     --->> Yii2 is thinking that this is a category and not a user table
            'title',
            'description',
            'content:html',
            'count_view',
            'status',
            'created_at',
        ],
    ]) ?>

    I am getting this error:  -->>  unknown property: app\models\Category::fullname 

    please could you help me to solve this issue, where I did make a mistake?

     

     

  3. yes, resizeImage() is a class, and I found my error, I was trying to reveal the image by jPanel, ans instead, I should have tried it by jLabel, therefore, that was was causing an error

  4. please could anybody explain me what type of error is it and where I should fix it?

          image.setIcon(ResizeImage(path, null));  ---> This line is causing the error.

     

    Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: javax.swing.JPanel.setIcon

        at kitob.Java_Kitob.Btn_Choose_ImageActionPerformed(Java_Kitob.java:323)


        at kitob.Java_Kitob.access$000(Java_Kitob.java:29)
        at kitob.Java_Kitob$1.actionPerformed(Java_Kitob.java:152)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
        at java.awt.Component.processMouseEvent(Component.java:6533)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
        at java.awt.Component.processEvent(Component.java:6298)
        at java.awt.Container.processEvent(Container.java:2236)
        at java.awt.Component.dispatchEventImpl(Component.java:4889)
        at java.awt.Container.dispatchEventImpl(Container.java:2294)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
        at java.awt.Container.dispatchEventImpl(Container.java:2280)
        at java.awt.Window.dispatchEventImpl(Window.java:2746)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.awt.EventQueue$4.run(EventQueue.java:731)
        at java.awt.EventQueue$4.run(EventQueue.java:729)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

  5. dear all,
    I am trying to make dynamic drop down menu but something is wront that I am geting following errors, can you have a look please:

    Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\as\inc\functions.php on line 14

    Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\as\inc\functions.php on line 14
    <?php
    $condb=mysqli_connect("localhost","root","","books") or trigger_error(mysqli_error());
    function getLanguage() {
    global $database;
    global $condb;
    $sql="SELECT * FROM LANGUAGES ORDER BY NAME asc";
    $rs=mysqli_query($sql,$condb) or die (mysqli_error()); ERROR LINE 14
    $rows=mysqli_fetch_assoc($rs);
    $total_rows=mysqli_num_rows($rs);
    if ($total_rows>0) {
    echo "<select name =\"srch_language\" id=\"srch_language\"><br>";
    echo "<option value =\"\">any language…</option>";
    do {
    echo "<option value=\"".$rows['id']."\"> ".$rows['name']."</option><br>";
    }while ($rows=mysqli_fetch_assoc($rs));
    echo "</select>";
    }
    mysqli_free_result($rs);
    }
    ?>
  6. I've been trying to insert my data to database, i've checked db connection, it is ok, but my data is not being inserted to database, it is not even showing error message, can you have a look to my codes if I have written something wrong.

     

    <!DOCTYPE html>
    <html>
    <head>
    <title>inserting data</title>
    </head>
    <body>
    <form action="insert_post.php" method="post" enctype="multipart/form-data">
    <table width="800" align="center" border="10">
    <tr>
    <td align="center" bgcolor="green" colspan="2"><h1> Insert new post</h1></td></tr>
    <tr>
    <td>Post title</td>
    <td><input type="text" name="title"></td>
    </tr>
    <td>Post author</td>
    <td><input type="text" name="author"></td>
    </tr>
    <td>Post image</td>
    <td><input type="file" name="image"></td>
    </tr>
    <td>Post content</td>
    <td><textarea name="content" cols="60" rows="20 "></textarea>></td>
    </tr>
    <td align="center">submit</td>
    <td><input type="submit" align="center" name="submit" value="upload"></td>
    </tr>
    </body>
    </html>
    <?php
    include ('db.php');
    if (isset($_POST['submit'])) {
    $title=$_POST['title'];
    $date=date('d-m-y');
    $author=$_POST['author'];
    $content=$_POST['content'];
    $image=$_FILES['image']['name'];
    $image_tmp=$_FILES ['image'] ['tmp_name'];
    move_uploaded_file($image_tmp, "images/$image");
    $query="INSERT INTO project
    (post_title, post_date,post_author,post_image,post_content) VALUES ('$title','$date','$author','$image','$content')";
    if (mysql_query($query)) {
    echo "<script>alert('success')</script>";
    }
    else {
    echo "<script>alert('oxshamadi')</script>";
    }
    }
  7. Dear developers,

     

    I've been trying something that I dont know, I would like to place my 5 posts in special pattern, the example of pattern can be in this site https://kun.uz/, let's say, I want my first post to be on the left with larger size while other 4 posts to be on the right with the same size all, however all posts are from the same table in database, I don't know even its defenition to search it on google, please could you kindly help me to find it,

     

    isn't it called something "front end"? if so, where to find it?

  8. I have written charset utf8 in many ways, however, yet my browser are reading my data with many mistakes, how to enable utf-8 in php files?

     

    here is my small part of souce code:

    <?phpinclude_once("dbconfig.php"); ?>
    <?php header('Content-Type: text/html; charset=utf-8');
    $con=mysqli_connect("localhost","root","","Alfy");
    mysqli_set_charset($con,"utf8");
    mb_internal_encoding("UTF-8");
    ?>
    <?php include_once('functions.php'); ?>
    <?php include_once('class.paging.php'); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. I am trying to configure "read more" function in wordpress for a long time, yet no results, I googled it a lot and I always read to change

    "the_content" function in wp-includes/post-template.php. I a trying but i dont know something wrong with my modifications, anyone has expreince in changing "read more" function? if yes, could you share your exprience please?

  10. bro those anchors are working at least, my biggest issue is opening the page where its id equal to page id, my requested page in not coming from database, instead, i am having a blank page, can you check my sql query to select data from database please, I believe there is my mistake

  11. I was creating small CMS website, I have posted all the posts succesfully, but when I am clicking to any post's title or read more, it is not opening it:, web page just opening blank page, however, localhost is not alerning any error,

     

     

     

    public function fullpost() {
    if(isset($_GET['id'])) {
    $post_id=$_GET['id'];
    $q="SELECT * FROM tables where body_id=$post_id"; (I think here is my mistake, but I dont know what is it exactly)
    $r=mysql_query ($q);
    if ($r !==false &&mysql_num_rows($r)>0) {
    while ($a=mysql_fetch_assoc($r)) {
    $body_id=($a['id']);
    $title=stripcslashes($a['title']);
    $body=($a['body']);
    $image=($a['image']);
    echo " <h1><a href='pages.php?id=<?php echo $body_id';?> $title </h1></a>
    <img src='images1/$image' />
    <p>$body</p><br><br><br>
    ";
    }
    }
    }
    }
    }
  12. I am trying to upload my full context into web page, however, my articles are being uploaded without image, I have plenty of errors while showing images, please could you kindly check what I have done wrong and can you give me some solutions to my code?

     

    here are codes:

    <!DOCTYPE html>
    <html>
    <head>
    <title>uploading a file</title>
    </head>
    <body bgcolor="blue">
    <form method="post">
    <table align="center" width="700" border="2" bgcolor="green">
    <tr align="center">
    <td align="center">
    <td colspan="8"><h2>upload whatever you want mr Alfraganus</h2></td>
    </td>
    <tr>
    <td colspan="8" align="center"><input type="text" name="title" size="60"><b>Title</b></td>
    </tr>
    <tr>
    <td colspan="8" align="right"><b> image:</b></td>
    <td align="left" colspan="8"><input type="file" name="image" /> </td>
    </tr>
    <tr>
    <td colspan="8"><textarea name="body" cols="80" rows="20"></textarea></td>
    </tr>
    <tr>
    <td colspan="8"><center><input type="submit" name="upload" value="upload the text"> </center></td>
    </tr>
    </table>
    </body>
    </html>
    <?php
    if (isset($_POST['upload'])) {
    define('DB_SERVER', "localhost");
    define('DB_USER', "root");
    define('DB_PASSWORD', "");
    define('DB_DATABASE', "alfy");
    define('DB_DRIVER', "mysql");
    $title = $_POST['title'];
    $body = $_POST ['body'];
    $image=$_FILES['image']['name'];
    $$image_tmp=$_FILES ['image'] ['tmp_name'];
    move_uploaded_file($image_tmp, "images1/$image");
    try {
    $db = new PDO(DB_DRIVER . ":dbname=" . DB_DATABASE . ";host=" . DB_SERVER, DB_USER, DB_PASSWORD);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $db->prepare("INSERT INTO tables(title,body,image) VALUES (:title, :body,:image)");
    $stmt->bindParam(':title', $title, PDO::PARAM_STR);
    $stmt->bindParam(':body', $body, PDO::PARAM_STR);
    $stmt->bindParam(':image', $image, PDO::PARAM_LOB);
    if($stmt->execute()) {
    echo "<script>alert('success')</script>";
    }
    $db = null;
    } catch(PDOException $e) {
    trigger_error('Error occured while trying to insert into the DB:' . $e->getMessage(), E_USER_ERROR);
    }
    }
    number of errors:
    Notice: Undefined index: image in C:\xampp\htdocs\free\upload.php on line 46

    Notice: Undefined index: image in C:\xampp\htdocs\free\upload.php on line 47

    Notice: Undefined variable: image_tmp in C:\xampp\htdocs\free\upload.php on line 47

    Notice: Undefined variable: image_tmp in C:\xampp\htdocs\free\upload.php on line 49

    Fatal error: Error occured while trying to insert into the DB:SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'image' cannot be null in C:\xampp\htdocs\free\upload.php on line 67


  13. here is my full source code:


    <!DOCTYPE html>

    <html>

    <head>

    <title>uploading a file</title>

    </head>

    <body bgcolor="blue">

    <form method="post">

    <table align="center" width="700" border="2" bgcolor="green">

    <tr align="center">

    <td align="center">

    <td colspan="8"><h2>upload whatever you want mr Alfraganus</h2></td>

    </td>

    <tr>

    <td colspan="8" align="center"><input type="text" name="title" size="60"><b>Title</b></td>



    </tr>



    <tr>

    <td colspan="8"><textarea name="body" cols="80" rows="20"></textarea></td>

    </tr>

    <tr>

    <td colspan="8"><center><input type="submit" name="upload" value="upload the text"> </center></td>

    </tr>

    </table>

    </body>

    </html>



    <?php

    if (isset($_POST['upload'])) {

    $hostname="localhost";

    $username="root";

    $password="";

    $db_name="alfy";

    try {


    $dbh=new PDO("mysql:host=$hostname;dbname=$db_name", $username,$password);


    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


    $sql= "INSERT INTO tables (title, body)


    values ('".$_POST["title"]."','".$_POST["body"]."')";


    $title=$_POST['title'];

    $body=$_POST['body'];

    $sth=$dbh->prepare($sql);

    $sth->bindvalue(':title', $title, PDO::PARAM_STR);

    $sth->bindvalue(':body', $body, PDO::PARAM_STR);

    $sth->execute();

    $dbh=null;







    }

    catch (PDOexception $e)

    {

    echo $e->getMessage();

    }



    }
  14. when I am inserting normal text (without "/ . , ; ') php is succesfully uploading my data, but if my text contains these characters: /./,;; php is sending this following error

     

     

    SQLSTATE[42000]: Syntax error or access violation: 1064 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 '['['')' at line 2 ,

     

     

     

    what does it mean and how to overcome it?

  15. I am trying to upload my data in object orinted approach, but larger text are not being uplaoded while only smallers ones are being succesfully uploaded, why larger articles cant bu uplaoded, what is wrong with it? here is my sourse codes

     

    upload.php--------------

     

     

    <!DOCTYPE html>
    <html>
    <head>
    <title>uploading a file</title>
    </head>
    <body bgcolor="blue">
    <form accept="upload.php" method="post" enctype="multipart/form-data">
    <table align="center" width="700" border="2" bgcolor="green">
    <tr align="center">
    <td align="center">
    <td colspan="8"><h2>upload whatever you want mr Alfraganus</h2></td>
    </td>
    <tr>
    <td colspan="8" align="center"><input type="text" name="title" size="60"><b>Title</b></td>
    </tr>
    <tr>
    <td colspan="8"><textarea name="body" cols="80" rows="20"></textarea></td>
    </tr>
    <tr>
    <td colspan="8"><center><input type="submit" name="upload" value="upload the text"> </center></td>
    </tr>
    </table>
    </body>
    </html>
    <?php
    include_once 'functions.php';
    $con=new cms();
    if(isset($_POST['upload'])) {
    $title=$_POST['title'];
    $body=$_POST['body'];
    $con->insert($title,$body);
    }
    if($con) {
    echo "<script>alert('success')</script>";
    }
    ?>
    functions.php------
    <?php
    define('DB_SERVER','localhost');
    define('DB_USER','root');
    define('DB_PASS','');
    define('DB_NAME','testdb');
    class cms {
    function __construct()
    {
    $con=mysql_connect(DB_SERVER, DB_USER,DB_PASS) or die('localhost problemm'.mysql_error());
    mysql_select_db(DB_NAME,$con);
    }
    public function insert($title,$body) {
    $res=mysql_connect("INSERT INTO CMS (title, body) values ('$title','$body')");
    return $res;
    }
    }
×
×
  • Create New...