Jump to content

Search the Community

Showing results for tags 'mysql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

  1. Hello, I am creating a web comic aggregation website. I am currently working on the back end in PHP, which uses an RSS reader to update a MySQL database every so often. Than I want the front end to access this database every time a user accesses the website. However, it seems like this will inevitably cause simultaneous reading from and writing to the database, from the front and back ends, respectively. Is this going to cause problems down the line? Or can MySQL handle this without glitching? Thanks in advance
  2. How to find a record in a table? I now use : $sql = "SELECT col1 FROM table WHERE col1 = '$var' " ; if ($stmt = $conn->prepare($sql)) { $stmt->execute(); $stmt->bind_result($var); while ($stmt->fetch()) { echo $var; echo ' : this variable exists <br>'; } $stmt->close(); } to fetch $var. But this actually results in an echo of the input. The goal is not necessarily echoing it, but determining whether it exists or not and report that its not existing So is it possible with other query to determine if $var exists and then use that as TRUE ?
  3. i want to show the record from mysql database when the users are not paid the initial amount? my database look like this: i've a table called roombooking in that field i've several columns like name,mob ,paid_amount and balance_amount.. so i want to retrieve a data who are all not paid the initial amount.... can u please tell me how to show it? Thanks in advance
  4. Hello, I am currently working on a web comic aggregation website. My general Design is an RSS reader that grabs the publishing date and image source link From various web comic RSS feeds each time they are updated, and uses this to update a database. Then the front end accesses this database info to be displayed in a user-friendly format each time someone accesses the website. I might eventually add a user account system to store user preferences about comic arrangements, which would also need to be put in the database. I am currently writing the back end in PHP and MySQL, and am trying to decide on a general database design. I googled how to design an efficient relational database, which provided a lot of information, but also filled me with fear that my database will be massively inefficient (because I've never done this before), and that it will eventually make my site slow and unusable. So I thought I would check my design on some forums before I proceed. My original plan was to have two databases: one for comics, then one for users later (am not too concerned about this one, because I'm sure there are a ton of examples for how to make an efficient username/password/info database). The comics database would have one table for each different comic, and each table would have a column for publishing date and image source link. However, after reading about database normalization, I thought of an alternative design: one table for comics, including their name and a primary ID,and then one table for publishing dates and one table for image source links, both including their own primary ID, and also the foreign key of the comic ID for each link or date. However, then I realized that the publishing dates table isn't going to make any sense because the publishing date is kind of like a key for the image source link. So basically I'm pretty confused as to how to generally arrange my tables and fields. I was wondering if anyone has any suggestions? I also have another concern. Some RSS feeds do not include publication dates, so it's possible that I am going to need to have some null entries for publishing dates. The MySQL manual told me to use the "NOT NULL" whenever possible, so I was wondering if not using it for this category will be a problem? Finally, there are a few miscellaneous things that I was wondering about. I have read that I can change table types, storage engines, and row format (compact, dynamic, compresse, etc.). I have also read that sometimes websites sacrifice normalization (and thus total storage space) for speed somehow. I was wondering if these more nitpicky details are important for my website? Although I plan on accumulating very long lists of individual comics (at least thousands, maybe tens of thousands for each different web comic), and the website could potentially become accessed very frequently if it became popular, it doesn't seem like what I am trying to do with my database is nearly as complicated as the kinds of things that most people are trying to do. So I was wondering how much of this optimization stuff is really worth the time, and how much of it is just going to make insignificant differences in the performance of my website? Help would be much appreciated
  5. How To show category wise posts using custom fields i am use acf plugin and i want show custom fields page i have 3 custom fields 1 album 2 artist 3 lyrics and 2 category 1st remix 2nd top song i want creat deffrant page for all 3 fields like 1st page album where i can show all album with 1st category with paging See Below Attached file For Best Understanding
  6. Hi guys! I have a little problem and it's that I get an error in a determined function where I call my connection and I don't know why. The errors are: 1) Notice: Undefined variable: conexionidiomas in C:\wamp64\www\idiomas\preguntas-frecuentes.php on line 10 2) Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\wamp64\www\idiomas\preguntas-frecuentes.php on line 11 This is what I have from "/Connections/conexionidiomas.php": # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_conexionidiomas = "p:localhost:3307"; $database_conexionidiomas = "idiomasbd"; $username_conexionidiomas = "root"; $password_conexionidiomas = "asdasdf"; $conexionidiomas = mysqli_connect($hostname_conexionidiomas, $username_conexionidiomas, $password_conexionidiomas, $database_conexionidiomas); and this in "preguntas-frecuentes.php": <?php require_once('Connections/conexionidiomas.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conexionidiomas, $theValue) : mysqli_escape_string($conexionidiomas,$theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO tblfrecuentes (strPregunta,fchFecha) VALUES (%s,NOW())",GetSQLValueString($_POST['strPregunta'], "text")); $Result1 = mysqli_query($conexionidiomas,$insertSQL) or die(mysqli_error($conexionidiomas)); } ?> So, if someone could help me I'd appreciate it so much. Regards!
  7. Hi I want to bring this information to insert multiple records from select <?PHP error_reporting(0); include("connect.inc.php"); ?> <?php include "connect.inc.php"; if (isset($_POST['submit'])) { $province_id = $_POST['province_id'][$i]; $province_id = $_POST['travel_id'][$i]; $i = 0; foreach ( $_POST as $val) { mysql_query("INSERT INTO travel_list (province_id, travel_id) VALUES ('$province_id', '$travel_id')"); $i++; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="css/bootstrap.min.css" rel="stylesheet" media="screen"> <script src="js/bootstrap.min.js"></script> <title>Untitled Document</title> </head> <body> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script src="respond.js"></script> <form action="index.php" method="post"> <!--ส่งค่า post ไปหน้าเดิม --> <table width="896" border="1"> <thead> <tr> <th width="239">จังหวัด</th> <th width="552">สถานที่ท่องเที่ยว</th> <th width="83"><input type="hidden" id="txtNum" value="1" size="2" /></th> </tr> <tr> <th width="239"> <select id="selProvince" name="province_id[]"> <!--Default จังหวััด--> <option value="">กรุณาเลือกจังหวัด</option> <?PHP $SelectPr="SELECT * FROM province"; $QueryPro=mysql_query($SelectPr); while($Pro=mysql_fetch_array($QueryPro)){ ?> <option value="<?=$Pro['province_id']?>"><?=$Pro['province_name']?></option> <?PHP } ?> </select> </th> <th width="552"><select name ="travel_id[]" id="selTravel"><option value="">กรุณาเลือกจังหวัด</option></select></th> <th width="83"><button type="button" id="btnP">เพิ่มรายการ</button></th> </tr> <tr><td colspan="3"><center>รายการที่เพิ่ม</center></td></tr> </thead> <tbody> </tbody> </table> <input name="submit" type="submit" value="add"> </form> <br><br><br> <!--ทอสอบ ค่าแสดงผล Muti Atrray--> </body> </html> I'm insert 1 record but I choose just one , but more data is imported into fifth data . Informationprovince_id, travel_id not insert into HELP ME HOT FIX CODE I choose just one , but more data is imported into fifth data .
  8. I need to check if value inserting in database while **import excel file** , if it has already value in database then it should get update. Below is producttab table value in database prdid | prdname 00A | prd1 00B | prd2 00C | prd3 00D | prd4 Below is EXCEL FILE data prdid | prdname 00A | prdnew 00B | prd2new 00E | prd8 00H | prd9 So if i upload above excel file then , 00A , 00B should get UPDATE IN producttab table as they are already present there... but 00E,00H should get insert below is what i have tried, value is getting insert properly only UPDATE IS NOT HAPPENING if(isset($_POST["Upload"])) { $fileinfo = pathinfo($_FILES["uploadFile"]["name"]); $filetype = $_FILES["uploadFile"]["type"]; $remark = NULL; //Validate File Type if(strtolower(trim($fileinfo["extension"])) != "csv") { $_SESSION['msg_r'] = "Please select CSV file"; header("location:importfile.php"); exit; } else { $file_path = $_FILES["uploadFile"]["tmp_name"]; } $row = 0; $tempFileName = time().".csv"; if ( is_uploaded_file( $file_path ) ) { $fileCopied = copy( $file_path , $tempFileName); if (($handle = fopen($tempFileName, "r")) !== FALSE) { fgetcsv($handle); while (($data = fgetcsv($handle, 6000, ",")) !== FALSE) { $num = count($data); for ($c=0; $c < $num; $c++) { $col[$c] = $data[$c]; } $col1 = $col[0]; // prdid $col2 = $col[1]; // prdname $sql = "SELECT prdid FROM producttab WHERE prdid = '".$col1."' "; $query = db_query($sql); $pfetech = db_fetch($query); if($col1 == $pfetech['prdid']){ $sqlup = "UPDATE producttab SET prdid = ".$pfetech['prdid'].", prdname = ".$col2." "; $sqlup .= " WHERE prdid = ".$pfetech['prdid']." "; $resultsqlupdate = mysql_query($sqlup); }else{ $query = "INSERT INTO producttab(prdid,prdname) VALUES('".$col1."','".$col2.")"; $s = mysql_query($query); } } fclose($handle); } echo "<center>File data imported to database!!</center>"; } } }
  9. I have a table which is either empty or has 1 record If the table is empty i cant retrieve info from the database and get an error message. my code: $sql = "SELECT id FROM users WHERE id = (SELECT MAX(id)FROM users)"; $result = $conn->query($sql); foreach ( $conn->query($sql) as $row ) { $id = $row['id']; the for each line gives an error message: how to solve this?
  10. Its PHP MYSQL : I have a table prodt , in which i first INSERT a value and with its LAST INSERT ID i do update for MAX + 1 as below , BUT I AM GETTING ERROR You can't specify target table 'prodt' for update in FROM clause $a = db_insert_id(); $sqllast = "UPDATE prodt SET pdname= ((SELECT pdname FROM ( SELECT MAX( pdname ) AS pdname FROM prodt WHERE oid = ".db_escape($oid)." ) AS pdname ) + 1 ), pcyn = ".db_escape(0)." WHERE id = ".db_escape($a)." AND oid= ".db_escape($oid)." "; $resultsqllast = db_query($sqllast); if((!$resultsqllast) || (db_mysql_affected_rows($db) <= 0)) { throw new Exception('Wrong SQL UPDATE' . $sqllast . ' Error: '.db_error_msg($db) . db_error_no()); } After research i tried below : $sqllast = "UPDATE prodt SET pdname= ((SELECT pdname FROM ( SELECT MAX( pdname ) AS pdname FROM ( SELECT * FROM prodt WHERE oid = ".db_escape($oid)." )AS pdname ) AS pdname ) + 1 ), pcyn = ".db_escape(0)." WHERE id = ".db_escape($a)." AND oid= ".db_escape($oid)." "; $resultsqllast = db_query($sqllast); if((!$resultsqllast) || (db_mysql_affected_rows($db) <= 0)) { throw new Exception('Wrong SQL UPDATE' . $sqllast . ' Error: '.db_error_msg($db) . db_error_no()); } But still its not working, getting same error message ... Thanks
  11. <?php include "connetti.php"; session_start(); $query = "SELECT id_studente, nome, cognome, anno_maturita, voto_maturita FROM utenti_studenti WHERE utenti_studenti.confermato = 0"; $risultato = @mysql_query($query); if (mysql_num_rows($risultato) == 0) { echo("Nessun elemento trovato"); header("refresh:3;url=AreaAmministratore.phtml"); exit(); } ?> <html> <head> <title>Annuario Studenti</title> <link rel="stylesheet" href="cssUtils/aggiungi_properties.css"/> <script type="text/javascript" src="jsUtils/jsUtils_annuario/annuario_properties.js"></script> </head> <body> <form method='post' action='confermaStudenti.php' name='aggiornaStatoStudente'> <div align='center'> <table class='tg'> <tr> <th class='tg' style='color: #000;'>ID</th> <th class='tg' style='color: black'>Nome</th> <th class='tg' style='color: black'>Cognome</th> <th class='tg' style='color: black'>Anno Maturita</th> <th class='tg' style='color: black'>Voto Maturita</th> <th class='tg' style='color: black'>Accetta</th> </tr><?php while ($row = @mysql_fetch_assoc($risultato)) { echo " <tr align='center'> <td class='tg' style='color: black'>" . $row['id_studente'] . "</td> <td class='tg' style='color: black'>" . $row['nome'] . "</td> <td class='tg' style='color: black'>" . $row['cognome'] . "</td> <td class='tg' style='color: black'>" . $row['anno_maturita'] . "</td> <td class='tg' style='color: black'>" . $row['voto_maturita'] . "</td> <td class='tg' style='color: black'>" . "<input type=\"hidden\" name=\"rifiuta\"/><input type=\"checkbox\" name=\"accetta\"/>" . "</td> </tr>"; } ?> </table> </div> <div align='center'> <a href='AreaAmministratore.phtml'>Torna indietro.</a> <input type='submit' value='Prosegui'/> </div> </form> </html> <?php session_start(); include("connetti.php"); if (isset($_POST["accetta"])) { $accetta = 1; } else { $accetta = 0; } if ($accetta) { $cognome = $_POST['cognome']; $nome = $_POST['nome']; $id_studente = $_POST['id_studente']; $query = "UPDATE utenti_studenti SET confermato='1' WHERE nome='$nome' AND cognome='$cognome' AND id_studente='$id_studente'"; $risultato = @mysql_query($query) or die('<p align="center">Errore!</p>' . mysql_error()); echo("<script>alert('La modifica eseguita')</script>"); header("refresh:0;url='AreaAmministratore.phtml'"); } else { echo "<script>alert('Errore');</script>"; header("refresh:0;url='AreaAmministratore.phtml'"); exit(); } ?> Greetings guys, could you help me with those codes above? Cuz I can't understand why it doesn't work... So I have an table with the users that not confirmed. So to confirm them I've made checkbox, so on the other side I have a control if the checkbox is checked so I need to update some values on my database right ? Well it doesn't work....
  12. Hello Every One I Want Show all USer last Useges Data From date of Last Recharge to To Date and condition With user owner by i Have 3 Table invoice - Need data from column date(need last invoice Last Recharge date For Below Table Condition Start ),username( Uniq In all table) acct - > Need data from column acctstarttime( For Start Date ),SUM( acct.acctinputoctets + acct.acctoutputoctets ) AS data(For Sum Of Useges Data ),SUM( acct.acctsessiontime ) AS acctsessiontime,username(Uniq In all table) users - > Need data from column username( Main Table Match username on this table base),owner,lastlogoff,expiration,uptimelimit,comobolimit, My Code is Here But Not working SELECT DATE( `acctstarttime` ) AS acctstarttime, SUM( acct.acctinputoctets + acct.acctoutputoctets ) AS data, acct.username, SUM( acct.acctsessiontime ) AS acctsessiontime, users.username, users.owner, users.lastlogoff, users.expiration, users.uptimelimit, .comblimit, users.enableuser,invoices.date FROM invoices,acct JOIN users ON acct.username = rm_users.username WHERE users.owner = 'admin' and acctstarttime between 'invoice.date' and 'users.expiration' GROUP BY MONTH( `acctstarttime` ) , acct.username ORDER BY invoices.date DESC LIMIT 0 , 30 I Think Problem in Where condition i want acctstarttime between 'invoice.date(Desc or User last recharge Date)' and 'users.expiration' I m very Confused How I dow Any One Can Help Thanks in Extra
  13. Below is products table : id | mid | wgh | remark| remkok | 1 3 1.5 r3ok 1 2 2 1.5 0 3 2 0.6 nice 0 4 1 1.2 okh 0 5 4 1.5 bye 0 6 4 2.4 okby 0 7 3 3.0 oknice 1 I want to display remark below tr of group by mid ....like below mid wgh 3 1.5 3.0 remarks : r3ok, oknice 4 1.5 2.4 remarks : bye, okby 2 1.5 0.6 remarks : , nice 1 1.2 remarks : okh **What i have tried as below :** $pid= null; while($row = mysql_fetch_array($result)) { $rowpkts = $row['mid']; echo "<tr class=\"undercl\">"; if($rowpkts != $pid){ echo'<td align="center" valign="top">'.$row["mid"].'</td>'; }else{ echo'<td align="center" valign="top"></td>'; } echo'<td align="center" valign="top">'.$row["wgh"].'</td>'; echo "</tr>"; // what i tried to build for remarks as below $remsql = "SELECT mid as onu , GROUP_CONCAT(`remark` ORDER BY `id` ASC SEPARATOR ', ') AS plrmks FROM products WHERE remkok= 1 GROUP BY `mid`"; $fetchremk = mysql_query($remsql); $rowresults = mysql_fetch_array($fetchremk); if($rowresults['onu'] == $pid ){ echo"<tr style='border-style:underline;'>"; echo'<td align="center" align="top">'.$rowresults["plrmks"].'</td>'; echo"</tr>"; } } $pid = $rowpkts; } But remarks is not coming proper ...i means its not display below mid=3 or mid=1.....
  14. Hello everyone, I am not sure if this is the right place to post since I do not know for sure if it is PHP that causes my issue, so I apologize in advance if I shouldn't have posted here. I am using WampServer Version 3.0.0 64bit (Apache: 2.4.17 | PHP: 5.6.16 | MySQL: 5.7.9) on windows10. I am updating a website and I am keeping the database the same, except from some small optimizations here and there. I have a query that selects all active rows of a specific category, then I fetch the results and show the rows: if(mysqli_stmt_prepare($stmt, "SELECT * FROM myTableName WHERE _category=? AND _approved='1' ORDER BY _id DESC LIMIT ?, ?")) { mysqli_stmt_bind_param($stmt, "iii", $category, $offset, $rowsPerPage); mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt,$id,$title,...,$image,...); //all fields are binded, including image while(mysqli_stmt_fetch($stmt)) { //show recipes } } The query is correct and everything shows up fine, except from the image returned by the query. My old database used to store the image with the path, eg "/this/is/the/path/to/image.jpg" but I have updated the image table column to only store the file name so now $image variable should contain only the file name, eg "image.jpg". But it does not. The $image variable still contains the full path, although the table is updated! I though it was some kind of caching, but clearing the browser's cache, going incognito, hard refreshing, changing browser did not change anything. I also tried running: SET GLOBAL query_cache_size = 0; in mySql terminal but that did not change anything as well. I also tested php.ini for Op Cache but it was already disabled: opcache.enable=0 I do not know what to do about this and it is driving me crazy! Any help will be very much appreciated. Thank you all, georgia
  15. Hello Everyone I M in Problem i Am creat my 1st project for client so plesese help me that how i done i need how i calculate field in php like this Pic total of Credit total of debit and pending balance and grand total So tell Me how i done Below i attecthed
  16. In PHPmyadmin I can't move the position of the columns. So when I go to change/modify (not sure how it's called in English) I get the possibility to move column and the place it after another column then where its placed now. Though, it does print the query it goes like ALTER TABLE `my_tab` CHANGE `col1` `col1` TINYINT(1) NULL DEFAULT NULL AFTER `col5`; I have not tested in the mysql console, but in PHP the columns don't move (anymore) like they did do beforehand.
  17. Hi everyone! Thank you in advance for reading this and any help you are able to provide. This has been a bit of a long road but I'm learning along the way. Before I begin I am well aware of the dangers of SQL injection and understand that using prepared statements would decrease injection attacks for the following code. This is a PHP/MySQL test code to see if it works before actual implementation on a live site. With that said here we go: I have a database and it contains four tables (for the sake of security I gave them disney character names) named huey, dewey, lewey and uncledonald. I would like to have the values from the columns deweysays in the table dewey, hueysays from the table huey and leweysays from the table lewey to show up in thier corresponding deweysays, hueysays and leweysays columns in the table uncledonald. See attached pic to see visually what I mean. I've tried the following code and get the result I want (values added to all tables) but only once. After that I get data in the dewey, huey and lewey tables but nothing else in the uncledonald table. Here is the PHP: <?php //Let's see whether the form is submitted if (isset ($_POST['submit'])) { $con=mysqli_connect("localhost","root","root","provingground"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql = "INSERT INTO dewey (lot_id, deweysays) VALUES (0, '{$_POST['deweyspeak']}');"; $sql .= "INSERT INTO huey (cust_id, hueysays) VALUES (0, '{$_POST['hueyspeak']}');"; $sql .= "INSERT INTO lewey (personal_id, leweysays) VALUES (0, '{$_POST['leweyspeak']}');"; $sql .= "INSERT INTO uncledonald (deweysays) SELECT deweysays FROM dewey "; $sql .= "INSERT INTO uncledonald (hueysays) SELECT hueysays FROM huey "; $sql .= "INSERT INTO uncledonald (leweysays) SELECT leweysays FROM lewey "; // Execute multi query if (mysqli_multi_query($con,$sql)){ print '<p> The Ducks Have Spoken.</p>'; } else { die ('<p>Could not add entry because:<b>' . mysqli_error() . '</b>.</p><p>The query being run was: ' . $sql . '</p>'); } } mysqli_close($con); ?> Is there something missing in my $sql query to uncledonald? Is the script completely off? Lot of questions…Help please!
  18. http://prntscr.com/a3dz84 please check why it doesn't working ? i have been tested change date in local computer but nothing happen, thanks UPDATE `cu_employee` SET `cu_employee_sisa_cuti` = '12' WHERE 1
  19. Hello everyone, I'm brand new to PHP and MySQL and I'm trying to build a login/register form for my company's website. I've literally scavenged the internet for the past 3 days and have watched multiple tutorials but still can't get my database to link to the php file(s). If anyone can guide me in the right direction or provide a dummy proof tutorial, it would be greatly appreciated!!! (I would attach my php code but I literally have nothing and have gotten no where) Any advice would help. Thanks!
  20. So recently I got my hands on one of youtube videos, it's quit old, and the guy explaining how to create a form for uploading image and all data that is connected with it, to MySQL and then showing on your web site. So everything is ok, but webpage does not display any images, it just show me white picture frame with picture icon on the top. This is my connection file with database: <?php $hostname_phpimage = "***"; $username_phpimage = "***"; $password_phpimage = "***"; $database_phpimage = "***"; // Create connection $inkedmen_marko = mysql_pconnect($hostname_phpimage, $username_phpimage, $password_phpimage); // Check connection if ($phpimage->connect_error) { die("Connection failed: " . $phpimage->connect_error); } ?> Then the file that uploads the images: <?php require_once('php/connect.php'); if($_POST['submit']) { $name=basename($_FILES['file_upload']['name']); $t_name=$_FILES['file_upload']['tmp_name']; $dir='/home4/inkedmen/public_html/images'; $cat=$_POST['cat']; if(move_uploaded_file($t_name,$dir."/".$name)) { mysql_select_db($database_phpimage, $inkedmen_marko); $qur="insert into anglija (mid, cid, name, path) values ('','$cat','$name','/home4/inkedmen/public_html/images/$name')"; $res=mysql_query($qur,$inkedmen_marko); echo'file upl success'; } else { echo 'not uploaded'; } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="file_upload"/> cat_id <input type="text" name="cat" /><br/> <input type="submit" name="submit" value="upload"/> </form> </body> </html> Then this one shows me what countries I have in one of the data base tables, so there is two england and slovenia, they both have a separate id that I have to type when uploading an image: <?php require_once('php/connect.php'); mysql_select_db($database_phpimage, $inkedmen_marko); $qur="select * from cat"; $res=mysql_query($qur,$inkedmen_marko); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <?php while($row= mysql_fetch_array($res)) { ?> <h1><a href="image.php?cid=<?php echo $row['id']?>"><?php echo $row['name'] ?> </a></h1><br/> <?php } ?> </body> </html> And finally, when I push on each country it directs me to the pictures that are connected with that countries according to the id given: <?php require_once('php/connect.php'); mysql_select_db($database_phpimage, $inkedmen_marko); $id=$_GET['cid']; $qur="select * from anglija where cid='$id'"; $res=mysql_query($qur,$inkedmen_marko); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <?php while ($row=mysql_fetch_array($res)){ ?> <img src="<?php echo $row['path'] ?>" width="300px" height="200px"> <br/> <?php } ?> </body> </html> So in the end it directs me to the pictures, but I can't see the pictures, it's just white windows with icon on the top. The pictures uploads to the image folder, the id, names of the file, path also uploads good, but somehow I can't show the images. I know it should be something small, but I can't figure it out. Maybe someone have any ideas????
  21. First, I've read all that W3 has posted about potential web servers plus followed those links and as many peripheral ones until I found myself totally snowed under by technical references and nomenclature that means nothing to me. I have never run a web server and never plan to publicly. This is only for local use of MySQL and PHP. Perhaps there are some who can help point me in a more productive direction or assess the feasibility of my plan to develop a rather straight-forward and (hopefully) simple-to-implement prototype of web pages on my desktop. Here is where I am: The host service that I am considering (and experimenting with at this writing) is a free site that provides better functionality with an upgrade that seems worthwhile, at least at this point it does. It supports MySQL database & PHP, both which are alien to me but seem relatively easy to manipulate, script-wise. Seems a reasonable undertaking. I DL'd MySQL so that I could learn locally without the planned host's interface further complicating the learning curve. I've now gotten familiar enough to manage MySQL data structure that it is time to manage the input, query and reports with PHP/HTML. I am familiar with HTML for the most part as well as javascript but JS is not supported universally the way it used to be. Hence, the PHP route. I find out that I must actually configure my machine to act as a web server to interface between MySQL and PHP. As stated before, this is the milestone where I am stuck. I have no clue which download is appropriate for my needs or how to determine that. I have a stock version of Win 7 Pro that came installed with my HP 6305. Whatever architecture had been installed during the set-up is what it there, plus any of the updates that have been flying through. So my questions are: Where/how do I check this Win 7 machine to decide which server is suitable for this rig? SPECIFICALLY, what should I be concerned most with a potential server to perform functions that are not exotic... just simple input forms, database queries and reports? Bare bones but reliable is what I am seeking. I already installed MySQL Server 5.7 and spent a few weeks running test operations. Do I need to remove it before I install the server and then reinstall? Is there a preferred sequence to install them? I've found right off that MySQL uses command prompt interface, like deja vu of writing Unix shell scripts 25 years ago. That itself was a surprise to me in this world of GUIs. I noticed a Workbench utility that appears to be GUI but at the moment I am comfortable enough learning the syntax in DOS. But this is very very slow process and I see where simple tasks that rely on perfect keystrokes will become tedious. How much help is a MySQL GUI utility and are there any servers that operate seamlessly through that sort of interface? Does the version of MySQL installed determine which web server will be compatible with it? There are more questions, but these high-level, basic ones were chosen to give me a better overall grasp of the project scope. Any objective recommendations would be gratefully received. Please provide links, if applicable. TIA Chip
  22. Hi I'm looking for php/mysql code to find identical input in a mysql database column.
  23. Arrrh! Can't install database. SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes, query was: CREATE TABLE `email_triggers` ( `id` int(10) NOT NULL AUTO_INCREMENT, `enabled` enum('0','1') COLLATE utf8_unicode_ci NOT NULL, `trigger_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `observer` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `trigger_name_2` (`trigger_name`,`observer`), UNIQUE KEY `trigger_name_3` (`trigger_name`,`observer`), KEY `trigger_name` (`trigger_name`), KEY `observer` (`observer`), KEY `enabled` (`enabled`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
  24. Dear all, i have been working in my college project and i reached a point were i can't get my cart orders into Order history, as it's not working and keep giving me the following error page, Error : INSERT INTO `cib4003_h00233671_at`.`orderhistory`(`order_id`, `Product_ID`, `Product_Name`, `client_ID`, `quantity`) VALUES ('', '', '', '2', ''); Duplicate entry '0' for key 'PRIMARY' ^ i checked the databse and all values are 0 except the Client_ID... thats why i am getting Duplicate entry, however, i tried to fix the problem for the past few hours and i can't find the issue, here my cart page code and here my history php where i do the insert part
  25. ugintl

    Database error

    I uploaded website files to the web root and when i tried to access it via www.mydomain.com it gave following error A Database Error OccurredError Number: 1146 Table 'webpk_16901224_app.sesion' doesn't exist INSERT INTO `sesion` (`session_id`, `ip_address`, `user_agent`, `last_activity`, `user_data`) VALUES ('1912dd6c2dd5c411cde798d9496c9a9a', '119.157.163.66', 'Mozilla/5.0 (Windows NT 5.1; rv:42.0) Gecko/20100101 Firefox/42.0', 1448544788, '') Filename: libraries/Session.php Line Number: 328 I tried to create a table like following through phpmyadmin, but i get an error "key id does not exist". My database name is webpk_16901224_app and it is empty. There are no tables. create table tablename( id INT NOT NULL, name VARCHAR (20) NOT NULL, age INT NOT NULL, PRIMARY KEY (id) ); The website script has 3 sql files, but i don't know how to use them. SQL files are attached. Desktop.zip
×
×
  • Create New...