Search Results

Search found 1909 results on 77 pages for 'die'.

Page 52/77 | < Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >

  • Converting files to blob to save in database

    - by jimbo
    I have an old user site that we are currently updating. The site's users have previously uploaded profile pics that are stored in a directory. I am now wanting to keep these profile images in the database, (easy to backup all data) but am having trouble working out how to do it. There are a lot of tutorials talking about do ing this from files that have just been uploaded and using the tmp name etc, but how can I re-create with files that have already been uploaded? I have looked into $data = file_get_contents($filename); Which seems to create a binary file, but doesn't seem to save in database with: mysql_query("UPDATE profiles SET company_logo = mysql_real_escape_string('".$data."') WHERE id = 1 ") or die(mysql_error());

    Read the article

  • convert mysql code to codeigniter

    - by Jethro Tamares Doble
    How can i convert this code into an acceptable codeigniter code: mysql_select_db($database_connection_ched, $connection_ched); $query_Institutions = "SELECT * FROM tb_institutional_profile ORDER BY tb_institutional_profile.institution_name ASC"; $Institutions = mysql_query($query_Institutions, $connection_ched) or die(mysql_error()); $row_Institutions = mysql_fetch_assoc($Institutions); $totalRows_Institutions = mysql_num_rows($Institutions); <td width="192"><select name="institution_id"> <?php do { <option value="<?php echo $row_Institutions['institution_id']?>" ><?php echo $row_Institutions['institution_name']?></option> <?php } while ($row_Institutions = mysql_fetch_assoc($Institutions)); ?> </select></td>

    Read the article

  • Stopping users posting more than once

    - by user342391
    Before posting my form I am checking the database to see if there are any previous posts from the user. If there are previous posts then the script will kick back a message saying you have already posted. The problem is that what I am trying to achieve isn't working it all goes wrong after my else statement. It is also probable that there is an sql injection vulnerability too. Can you help??4 <?php include '../login/dbc.php'; page_protect(); $customerid = $_SESSION['user_id']; $checkid = "SELECT customerid FROM content WHERE customerid = $customerid"; if ($checkid = $customerid) {echo 'You cannot post any more entries, you have already created one';} else $sql="INSERT INTO content (customerid, weburl, title, description) VALUES ('$_POST[customerid]','$_POST[webaddress]','$_POST[pagetitle]','$_POST[pagedescription]')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "1 record added"; ?>

    Read the article

  • How can I check if a value is in a list in Perl?

    - by ablimit
    I have a file in which every line is an integer which represents an id. What I want to do is just check whether some specific ids are in this list. But the code didn't work. It never tells me it exists even if 123 is a line in that file. I don't know why? Help appreciated. open (FILE, "list.txt") or die ("unable to open !"); my @data=<FILE>; my %lookup =map {chop($_) => undef} @data; my $element= '123'; if (exists $lookup{$element}) { print "Exists"; } Thanks in advance.

    Read the article

  • Error comparing hash to hashed mysql password (output values are equal)

    - by Charlie
    Im trying to compare a hashed password value in a mysql database with the hashed value of an inputted password from a login form. However, when I compare the two values it says they aren't equal. I removed the salt to simply, and then tested what the outputs were and got the same values $password1 = $_POST['password']; $hash = hash('sha256', $password1); ...connect to database, etc... $query = "SELECT * FROM users WHERE username = '$username1'"; $result = mysql_query($query); $userData = mysql_fetch_array($result); if($hash != $userData['password']) //incorrect password { echo $hash."|".$userData['password']; die(); } ...other code... Sample output: 7816ee6a140526f02289471d87a7c4f9602d55c38303a0ba62dcd747a1f50361| 7816ee6a140526f02289471d87a7c4f9602d55c38303a0ba62dcd747a1f50361 Any thoughts?

    Read the article

  • Perl Matching ,Extracting , and printing emails

    - by user3448790
    How do I match an email using the The Official Standard: RFC 5322 in a html source code, after that i will extract the strings that are matched ONLY, and print out inly the emails, and not the whole source code? Is there any examples and output to illustrate this? Thnaks! elsif ($_ eq '-dDATA' or $_ eq '-ft') { opendir(DIR,'DATA'); my(@dir) = grep /\.htm/, readdir (DIR); closedir(DIR); my $value = join(@dir); print "$value\n"; foreach my $movies (@dir) { open (my $FHD, "<", "DATA/$movies") || die $!; print <$FHD>; } } }

    Read the article

  • Problem while redirecting user after registration

    - by Eternal Learner
    I am creating a simple website . My situation is like this. After registering an user, I want to redirect the user after say 3 seconds to a main page(if the registration succeeds) . The code I have now is as below $query = "INSERT INTO Privileges VALUES('$user','$password1','$role')"; $result = mysql_query($query, $dbcon) or die('Registration Failed: ' . mysql_error()); print 'Thanks for Registering , You will be redirected shortly'; ob_start(); echo "Test"; header("Location: http://www.php.net"); ob_flush() I get the error message Warning: Cannot modify header information - headers already sent by (output started at/home/srinivasa/public_html/ThanksForRegistering.php:27) in /home/srinivasa /public_html/ThanksForRegistering.php on line 35. What do I need to do now ?

    Read the article

  • How do I call Informix stored procedures from Perl?

    - by superjtc
    How do I call informix stored procedures from Perl? I use DBD::ODBC to connect to informix database, but I don't know how to call procedures. my code like this: my $dbh=DBI->connect("dbi:".DBDRIVE.":".DBNAME,DBUSER,DBPASS,{RaiseError=>0,PrintError=>0,AutoCommit=>1}) ||die $DBI::errstr; $dbh->do("execute procedure sp_test('2010-05-01 00:00:00')") || warn "failed\n"; $dbh->disconnect(); when I run it, it didn't get error. But I get nothing when I check the database. the store procedure works fine if I run it in database directly. Anyone can help me out?

    Read the article

  • php/mySQL error: mysql_num_rows(): supplied argument is not a valid MySQL result

    - by Michael Robinson
    I'm trying to INSERT INTO a mySQL database and I'm getting this error on: if (mysql_num_rows($login) == 1){ Here is the php, The php does add the user to the database. I can't figure it out. <? session_start(); require("config.php"); $u = $_GET['username']; $pw = $_GET['password']; $pwh = $_GET['passwordhint']; $em = $_GET['email']; $zc = $_GET['zipcode']; $check = "INSERT INTO family (loginName, email, password, passwordhint, location) VALUES ('$u', '$pw', '$pwh', '$em', '$zc')"; $login = mysql_query($check, $link) or die(mysql_error()); if (mysql_num_rows($login) == 1) { $row = mysql_fetch_assoc($login); echo 'Yes';exit; } else { echo 'No';exit; } mysql_close($link); ?> Thanks,

    Read the article

  • How do you display a PHPmyadmin table onto a web browser/web page?

    - by user1390754
    Just a simple question, i've been searching around and for some reason i cannot find an answer to this. after creating a database/table in Phpmyadmin using xampp, what command do i need to put into my webpage (PHP) to show the table I made? I know the first step involves connecting to the database and i think i've done that properly. This is the code i found from somewhere about connecting (w3 tutorials I believe) $con = mysql_connect("localhost","xxxxxx,""); if (!$con) { die('Could not connect: ' . mysql_error()); }

    Read the article

  • Pushin each_line into array not working

    - by zettt
    Hi, I've got a weird issue with Ruby. I want to read data from a file and put the data then into an array. The weird thing is, it's working in another script which does basically, the same thing. quoteArray = [] quoteFile = File.new("quotes.txt", "r") or die "Unable to open file..." quoteFile.each_line { |line| quoteArray.push line } puts quoteArray[0] All I get out of this is an array with one element where the whole text file is in. What's wrong? Is it my machine? The text file? Any ideas? Thanks in advance

    Read the article

  • Perl - Choose interface to connect through

    - by Dieterve
    I have 2 interfaces on my server, eth0 and eth0:0. Those are 2 different external ips and obviously 2 different reverse domains. When i open a IO::Socket::INET Perl uses the eth0 interface by default. I would like to use the second interface (eth0:0) because this has a different ip and i dont want to use my main ip/domain. I have absolutely no idea how to select which interface to connect through. Code i use to open a socket: my $sock = new IO::Socket::INET(PeerAddr => $server, PeerPort => $serverPort, Proto => 'tcp') or die "Can't connect to server: $!";

    Read the article

  • How do stop form posting to mysql if database contains a specific ID?

    - by user342391
    I have a form that I am using to post data to mysql. Before submitting the form I want to check the database and see if there are any fields in the column 'customerid' that equal 'userid' and if so not to post the form. Basically, I am trying to limit my users from posting more than once. Users will be able to login to my system and make ONE post. They will be able to delete and modify their post but are only limited to one post. How would I do this??? Code so far: <?php include '../login/dbc.php'; page_protect(); $userid = $_SESSION['user_id']; $sql="INSERT INTO content (customerid, weburl, title, description) VALUES ('$_POST[userid]','$_POST[webaddress]','$_POST[pagetitle]','$_POST[pagedescription]')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "1 record added"; ?>

    Read the article

  • PHP setcookie warning

    - by Ranking
    Hello guys, I have a problem with 'setcookie' in PHP and I can't solve it. so I receive this error "Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\VertrigoServ\www\vote.php:14) in C:\Program Files\VertrigoServ\www\vote.php on line 86" and here is the file.. line 86 is setcookie ($cookie_name, 1, time()+86400, '/', '', 0); is there any other way to do this ?? <html> <head> <title>Ranking</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body bgcolor="#EEF0FF"> <div align="center"> <br/> <div align="center"><div id="header"></div></div> <br/> <table width="800" border="0" align="center" cellpadding="5" cellspacing="0" class="mid-table"> <tr><td height="5"> <center> <table border="0" cellpadding="0" cellspacing="0" align="center" style="padding-top:5px;"> <tr> <td align="center" valign="top"><img src="images/ads/top_banner.png"></td> </tr> </table> </center> </td></tr> <tr><td height="5"></td></tr> </table> <br/> <?php include "conf.php"; $id = $_GET['id']; if (!isset($_POST['submitted'])) { if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $query = mysql_query("SELECT SQL_CACHE id, name FROM s_servers WHERE id = $id"); $row = mysql_fetch_assoc($query); ?> <form action="" method="POST"> <table width="800" height="106" border="0" align="center" cellpadding="3" cellspacing="0" class="mid-table"> <tr><td><div align="center"> <p>Code: <input type="text" name="kod" class="port" /><img src="img.php" id="captcha2" alt="" /><a href="javascript:void(0);" onclick="document.getElementById('captcha2').src = document.getElementById('captcha2').src + '?' + (new Date()).getMilliseconds()">Refresh</a></p><br /> <p><input type="submit" class="vote-button" name="vote" value="Vote for <?php echo $row['name']; ?>" /></p> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="<?php echo $row['id']; ?>" /> </div></td></tr> <tr><td align="center" valign="top"><img src="images/ads/top_banner.png"></td></tr> </table> </form> <?php } else { echo '<font color="red">You must select a valid server to vote for it!</font>'; } } else { $kod=$_POST['kod']; if($kod!=$_COOKIE[imgcodepage]) { echo "The code does not match"; } else { $id = mysql_real_escape_string($_POST['id']); $query = "SELECT SQL_CACHE id, votes FROM s_servers WHERE id = $id"; $result = mysql_query($query) OR die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $votes = $row['votes']; $id = $row['id']; $cookie_name = 'vote_'.$id; $ip = $_SERVER['REMOTE_ADDR']; $ltime = mysql_fetch_assoc(mysql_query("SELECT SQL_CACHE `time` FROM `s_votes` WHERE `sid`='$id' AND `ip`='$ip'")); $ltime = $ltime['time'] + 86400; $time = time(); if (isset($_COOKIE['vote_'.$id]) OR $ltime > $time) { echo 'You have already voted in last 24 hours! Your vote is not recorded.'; } else { $votes++; $query = "UPDATE s_servers SET votes = $votes WHERE id = $id"; $time = time(); $query2 = mysql_query("INSERT INTO `s_votes` (`ip`, `time`, `sid`) VALUES ('$ip', '$time', '$id')"); $result = mysql_query($query) OR die(mysql_error()); setcookie ($cookie_name, 1, time()+86400, '/', '', 0); } } } ?> <p><a href="index.php">[Click here if you don't want to vote]</a></p><br/> <p><a href="index.php">Ranking.net</a> &copy; 2010-2011<br> </p> </div> </body> </html> Thanks a lot!

    Read the article

  • Get the names of IDs from different table

    - by user896692
    I have an array with a lot of data from a database. In the array, there are two fields called teameinsid and teamzweiid. The query is a very simple one : $spiel = mysql_query("select teameinsid, teamzweiid from begegnung", $connection) or die("Keine passende Begegnung"); What I need is to search in the database for the names of these IDs. The names are in a different table. What I have now is the following: while($tmp = mysql_fetch_array($spiel)){ $teins = $tmp['teameinsid']; $tzwei = $tmp['teamzweiid']; } So I know the two IDs, but I don't know where to save the names. If I try: $name = mysql_query("select name from team where teameinsid = $teins", $con) it gets overwritten every time. How can I manage this?

    Read the article

  • Cannot insert into SQLite database through php PDO

    - by user323941
    Pls help see what is wrong.... (I test the db connection is fine) <?php $user_name=$_POST['user_name']; $password=$_POST['password']; $dbh=new PDO('sqlite:./db/user.db') or die("fail to connect db"); try{ $stmt = $dbh->prepare("INSERT INTO user_info VALUES (?, ?)"); $stmt->bindParam(1, $a); $stmt->bindParam(2, $b); $a=$user_name; $b=$password; $stmt->execute(); } catch(PDOException $e) {echo $e->getMessage();} ?>

    Read the article

  • Why my query is not working?

    - by Poma
    my website has PHP command: mysql_query("SELECT * FROM users WHERE id=" . $_GET["id"]) or die(mysql_error()); When I enter URL http://example.com/index.php?id=1;%20UPDATE%20users%20SET%20password=123%20WHERE%20id=1 I get following error: 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 'UPDATE users SET password=abc WHERE id=1' at line 1 But in phpmyamin query executes successfully. What's wrong here? Why it doesn't execute in browser?

    Read the article

  • Confused on the basics of AJAX

    - by Doug
    So right now, I'm just using a basic form to check a password. I want it to check the password and basically remain on page.html so I can use JavaScript to alert incorrect password or something. I'm not really sure how to do that. It seems it would bring me to check.php. I'm not too sure on the whole process, any help appreciated! Thanks! Page.html <form action="check.php" method="post"> <input type="password" name="password" /> <input type="submit" value="Submit" /> </form> check.php <?php $password = $_POST['password']; if ( $password != "testing" ) { die(); } ?>

    Read the article

  • Duplication in mysql/php

    - by user1334095
    I have a problem in the code.i have two tables 'sms' and 'bd_paid_bribe'.sms table has a column 'Message' and bd_paid_bribe table has a column 'c_addi_info'.when i execute the code first time all the values of Message column are inserted into c_addi_info column.when i enter a record for the second time instead of inserting the new record, all the records of Message column are inserted into bd_paid_bribe column.can u modify the code and provide a solution to avoid duplication and to insert only the newly added record. <?php $con=mysql_connect('localhost','root',''); if(!$con) { die("couldn't connect"); } mysql_select_db("ipab2",$con); $rs2=mysql_query(" select max(sms_index) from tab3"); do { $rs=mysql_query("insert into tab3(sms_index)select max(sms_index) from sms"); $rs3=mysql_query("SELECT max(sms_index) FROM sms"); $rs1=mysql_query("insert into bd_paid_bribe(c_addi_info) select Message from sms "); }while($rs2>$rs3); ?>

    Read the article

  • php var_dump returning blank array

    - by Oroku
    I'm following this tutorial on youtube: https://www.youtube.com/watch?v=VSF5p00uorc Around 4:28 - I get the following array when I load the sql.php page as in the tutorial: array(8) { [1]=> NULL [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> NULL [8]=> NULL } I do have 8 ids all with values in my data table. This is my code: <?php $con = mysqli_connect("localhost","root","","test2") or die('error'); $query = "select * from data"; $result = mysqli_query($con,$query); while($row = mysqli_fetch_array($result)) { $id = $row['id']; $feed = $row['feed']; $data[$id] = $feed; } var_dump($data); ?>

    Read the article

  • MySQL Database || Tables Issue

    - by user1780103
    I'm trying to write up a script where the user is able to purchase an amount of points for dollars. I want the transaction to be inserted into MySQL. I keep facing a: "Column count doesn't match value count at row 1" error. And I have no idea what I'm doing wrong. I have written up this: mysql_query("INSERT INTO paypal_donations VALUES (NULL, ".$account_id.", ".$char_id.", ".$price.", ".$dp.", NOW(), NOW(), 'Started', 0, 0, '', '');") or die(mysql_error()); But I don't know what to execute in MySQL, since I've never worked with it before. Could anyone write up a quick script that I can insert into MySQL for it to work.

    Read the article

  • Using Session to limit form submission by time

    - by user1733850
    I have spent over 2 hours scouring the net trying to figure this out. I am trying to stop multiple form submission any faster than 60 seconds. Here is what I am using. session_start(); if (!isset($_SESSION['last_submit'])) $_SESSION['last_submit'] = time(); if (time()-$_SESSION['last_submit'] < 60) die('Post limit exceeded. Please wait at least 60 seconds'); else $_SESION['last_submit'] = time(); I found this bit here on the site but haven't been able to figure anything else out as far as getting it to work. I have this bit of code on my page at the beginning that does the DB query with the previous pages POST results. Do I need to set $last_submit to a certain value? Any help is appreciated.

    Read the article

  • PHP Localhost Application connect to server database

    - by Cross Vander
    I want to ask about how to connect my localhost application (C:xampp/htdocs/myproject) to database at my server host (www.someweb.somedomain)? Am I possible to do that? If it is, how to connect it at my php config? Right now my config (server.php) is: <?php $host = "my web IP public:3306"; $user = "root"; $pass = ""; $db = "dispatcherDB"; $conn = mysql_connect($host, $user, $pass) or die ("Cant connect to mySQL"); mysql_select_db($db); ?> what I got: Warning: mysql_connect(): No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\XMS\server.php on line 7 So, what must I filled for $host? I'm trying using website IP, it still can't connect. Maybe there's someone here have experience at this problem? Sorry for my bad English

    Read the article

  • php/mysql question, retrieving information

    - by chance
    Hey SO, I have a question, pretty new at PHP and MySql but was curious is it possible to display only the most recent column to a table, from a database? I know it is possible to display a list of all information, or if you have just one column of information in your table to display that using the Here is my code for my basic script (just loads 1 column of information) I would like it to only print out the recent column i added to the table $con = mysql_connect ("localhost","username","password"); if (!$con) { die ('Could not connect:' . mysql_error()0; } mysql_select_db("db_name", $con); $result = mysql_query(Select column FROM table"); while($row = mysql_fetch_array($result)) { echo $row['column']; } mysql_close($con); * keep in mind, im not looking for someone to shoot me my code with it completed, though it would be handy, however just giving me the options of what I have to do, or what the script is called would be plentiful enough for my research, thanks!

    Read the article

  • What causes session/forms authentication timeouts in MVC3

    - by SimpleUser
    Can somebody please let me know what are the reasons for your authentication to die suddenly, even when you are working on an application without any idle time? Both with and without AJAX calls. And what are the different reasons for getting a 302 redirect from an MVC3 application to the Logon page. Been struggling with an issue with timeouts that happen at random. Sometimes within a few minutes of login to the application and sometimes you can go for hours (with/without idle time) without being thrown out. Thank You

    Read the article

< Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >