PHP - Mysql Link Identifier
Hi,
So my code returns this: mysql_query() expects parameter 2 to be resource, null given My query & result is: $query = "SELECT * FROM wow_logon.accounts WHERE forum_acc = ('$userid')"; $result = mysql_query($query,$connect); So, something's wrong with my connect variable: $connect = mysql_connect($conf["host"],$conf["user"],$conf["password"]) or die(mysql_error()); mysql_select_db($conf["db"],$connect) or die(mysql_error()); So I don't get why it doesn't work, perhaps the select db isn't parsed, but it's told which database to use in the query :/ Any help is much appreciated. Similar TutorialsHello.
I have a bit of a problem. When I fetch the link field from the database.i don't see an actual link on the page.
One more thing, what type of field should I use to store the link in the database? Probably there is where I went wrong.
All help is
hello, is there a way to check a query to see if a link is in it? like if i have $description=$row['description']; and $description says something like Mikes bio is at http://www.website.com/mike/ i want to be able to click that link is this possible? What is wrong? Warning: mysql_select_db(): supplied resource is not a valid MySQL-Link resource in /home/rweekly/public_html/2012/view_arguments.php on line 41 Warning: mysql_query(): supplied resource is not a valid MySQL-Link resource in /home/rweekly/public_html/2012/view_arguments.php on line 43 Code: [Select] mysql_select_db($database_news, $news); $query_news = "SELECT * FROM news WHERE id = '$id'"; $news = mysql_query($query_news, $news) or die(mysql_error()); $row_news = mysql_fetch_assoc($news); $totalRows_news = mysql_num_rows($news); mysql_select_db($database_news, $news); $query_arguments = "SELECT * FROM argue WHERE pid = '$id'"; $arguments = mysql_query($query_arguments, $news) or die(mysql_error()); $row_arguments = mysql_fetch_assoc($arguments); $totalRows_arguments = mysql_num_rows($arguments); Im fairly new to PHP and have a quick question. I am creating a mail system from scratch and I have two main SQL rows, ID and read. I need to put a link around the ID so that it only pops up in a pop up window that message. This is the coding I have so far, feel free to point out where I have gone wrong: <? include('../config/config.php'); $Query = sprintf("SELECT * FROM qa LEFT JOIN EmployeeInfo ON(qa.Agentsname = EmployeeInfo.Name) WHERE EmployeeInfo.Name LIKE '%s'", mysql_real_escape_string($_SESSION['SESS_NAME'])); $result = mysql_query($Query); $num_rows = mysql_num_rows($result); echo "<table border='0' cellspacing='10' cellpadding='10'>"; echo "<tr>"; echo "<td><strong>Message ID</strong></td><td><strong>Team Lead</strong></td><td><strong>Unread/Read</strong></td><td><strong>Score</strong></td>"; while($row = mysql_fetch_array($result)) { echo "<tr><td><a href='http://10.0.11.5/form/employees/attendance/qaview.php?id='". $row['ID'] . ">" . $row['ID'] . "</a></td><td>" . $row['Name'] . "</td><td>" . $row['read'] . "</td><td>" . $row['Score'] . "</td></tr>"; } echo "</table>"; ?> and this is the qaview.php page <? include('../config/config.php'); $query = doquery("SELECT * FROM qa WHERE ID='$ID'"); $update_query=doquery("UPDATE qa SET read='1' WHERE ID='$ID'"); $row = mysql_fetch_array($query); echo "<td><strong>" . $row['Name'] . "</strong></td></tr>"; ?> Hey guys, Currently Im using the code: while($row=mysql_fetch_array($nt)){ echo" $row[user_login],$row[user_email],$row[CallHistoryTimes],$row[CallHistoryInfo],$row[CallHistoryLastOp]$row[CallHistoryLastDate],<br>"; } To list a mysql array; what I am trying to do is to use the mysql row ID and turn the entire string above into a list. So for example, the database would get the ID information & create a link of edit.php/?id=3 If someone could help me on this it would be mega appreciated. Thanks Hey, I'm trying to save a MySQL-Link source as an instance variable in my query class. The problem is that MySQL sees it as an invalid MySQL-Link (supplied argument is not a valid MySQL-Link resource). What I'm I doing wrong? //Walle Code: [Select] private $connection; //Construct public function __construct(&$connection) { $this->connection = $connection; } //Where the error occurs public function exe_query($sql) { $result = mysql_query($sql, $this->connection); if(!$result) { throw new Exception(mysql_error()); } return $result; } I have a table where it displays some data. How do I make this Code: [Select] echo "<td>" . $row['title'] . "</td>"; into a link? Hi Everyone. I get the following data from a result from database search <?php echo $rsjobs['CompanyURL'];?> It prints out the url but when I try to turn it into a clickable link it does not work Here is the coding I have so far. <a href="<?php echo $rsjobs['CompanyURL'];?>"><?php echo $rsjobs['CompanyURL'];?></a> What am I doing wrong ? please help. Hi guys.. 1st post here. I'm pretty new to php.. just a few weeks in. I've gotten pretty decent at making mysql connections and extracting data, but now I'm wanting to take one of my urls that I echo to my page and create a new page. Hoping someone can help... Here's the pictu MY MySQL Setup: I have 1 table called table1. It has 2 columns which a 'Title' & 'Description' My Index.php Page: I connect to mysql. I pull the 'Title' from MySQL and loop it to produce 100 rows of data that fill my index page, as expected. My Problem: I now want to be able to click one of those rows and dynamically create a new page (description.php) that includes the 'Title' & 'Description'. My Progress: I've managed to click a row and create a hyperlink to mysite.com/$title (where 'title' is pulling the 'title' from the mysql db) but I all I get is page not found. My Question: How do I tell description.php to pull the 'Title' and 'Description' and link to it from index.php? My Gratitude: Thanks in advance! I have a function that generates a random number and checks to make sure it does not exists in the database. I call this function using Code: [Select] $ref = get_record_ref(); I get the following error. Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in line 68 EDITED.... if i place the code from the function in my script and not use it as a function the script works. why would this be? Code: [Select] <?php db_connect() or die('Unable to connect to database server!'); function db_connect($server = 'localhost', $username = 'username', $password = 'password', $database = 'databasename', $link = 'db_link') { global $$link; $$link = mysql_connect($server, $username, $password); if ($$link) mysql_select_db($database); return $$link; } //Function to handle database errors. function db_error($query, $errno, $error) { die('<font color="#000000"><strong>' . $errno . '<br><br><br><br><small><font color="#ff0000">[STOP]</font></small><br><br></strong><br><br><br>One of our coders have been informed of this problem and shall be working on it very shortly.<br><br>Please try again in a few minutes or so when we should have this issue fixed.<br><br>Thank you.</font>'); } //Function to query the database. function db_query($query, $link = 'db_link') { global $$link; $theip = $_SERVER['REMOTE_ADDR']; $httpuseragent = $_SERVER['HTTP_USER_AGENT']; $fromlink4 = gethostbyaddr($_SERVER['REMOTE_ADDR']); // this next line is the error line 68 $result = mysql_query($query, $$link) or db_error($query, mysql_errno(), mysql_error()); return $result; } function get_record_ref() { // /* // set new $record_ref. $record_ref = (rand(10, rand(10, 1000000000))); // check if exisits in DB. $sql = "SELECT * FROM `table` WHERE `record_ref` = '". $record_ref ."'"; $get_records_with_record_ref = db_query($sql,''); // count entries in DB for $record_ref. $count_record_ref = mysql_num_rows($get_records_with_record_ref); while ($count_record_ref > 0) { // set new $record_ref. $record_ref = (rand(10, rand(10, 1000000000))); // check if exisits in DB. $sql = "SELECT * FROM `table` WHERE `record_ref` = '". $record_ref ."'"; $get_records_with_record_ref = db_query($sql); // count entries in DB for $record_ref. $count_record_ref = mysql_num_rows($get_records_with_record_ref); } // */ return $record_ref; } ?> Hi, Is it possible to build a PHP Template page that selects and publishes a row of data from a MySQL Database when a linked is clicked? I would design: Template.php Text links (perhaps on homepage of navigation bar): ProductA, ProductB and ProductC If you click link ProductA Template.php would display data for ProductA and likewise for ProductB and ProductC. I would also like search engines for find ProductA, ProductB and ProductC PHP pages. (Not just my single Template.php) Any ideas as to how this could be done without designing individual PHP pages for each product? Kind regards, Matthew. I want to do an sql query, but I want it to happen only after my user has clicked on a confirmation link. The link will be sent to their email address. What is the usual procedure for this? For the time being Ive chucked what ive got into 1 php file, but I pressume I will need a couple of php files, and some how pass some variables from 1 page to the next??? $first = $_GET['first']; $last = $_GET['last']; $age = $_GET['age']; $$emailad = $_GET ['emailad'] $query =mysql_query ("INSERT INTO treesurgeons (FirstName, LastName, Age) VALUES ('$first', '$last', '$age')"); echo mysql_error(); echo "<p>Thankyou for submiting your details.\r\n Please check your inbox and click on your confirmation link.</p>"; $message = "The following details have been submited to the tree directory and are awaiting confirmation; $first $last, $age. \r\n Please click on the link below to confirm these details are correct"; //Do I include a link to an html file or php file? $subject = "Your tree directory details"; $to = "$email"; $email = "$emailad"; mail( "$to", "$subject","$message", "$headers"); //How do I trigger this email upon confirmation ?></body></html> Hi I've got this database I created with fields ProductId ProductName Image I've managed to get it to list the ID,productname, and Image urls in a list. My next step is to have the image field actually display an image and make it clickable: heres what I've done so far: Code: [Select] <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("productfeed", $con); $result = mysql_query("SELECT * FROM productfeeds"); echo "<table border='0'> <tr> <th>Firstname</th> <th>Lastname</th> <th>Image</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; echo "<td>" . $row['ImageURL'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Heres what I want to do: Code: [Select] while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; // my changes beneath echo "<td>" . <a href="<?php echo $row['ImageURL'];?>"> <img src="<?php echo $row['LinkURL']; ?>"> </a>. "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Can you guys point me in the right direction? Many thanks Hi Support, I have a form, where it collects user description input. I can collect the inputs and store it with newline. The issue is - how to collect the http link to actual hyperlink ref during display. The following is my code: <textarea name="description" cols="50" rows="10" id="description"><?php echo str_replace("<br>", "\n", $description);?></textarea></td> For example, User input: Hi, Check it out - http://www.google.com/ I would like to display google link as href so that Viewers can click the link and go to the page. Right now, it is not href and user need to copy the link to new tabs or pages and then it can come. Thanks for your help. Regards, Ahsan hi hope you all are fine. i have been working on a Email Form (like user fills up the form which send the information to our email) but i was having problem with (URL field i created) link of form is (http://services.shadowaura.com/allquotations/static.php) field which is not working is "Inspirational Website:" when i submit the form it says (Forbidden You don't have permission to access /allquotations/staticworking.php on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.) Can some one help me out ????????????? code behind this form is: Code: [Select] <?php /* Email Variables */ $emailSubject = 'Shadow Aura Contact Info!'; $webMaster = '*****@shadowaura.com'; /* Data Variables */ $Name = $_POST['Name']; $email = $_POST['email']; $Cell = $_POST['Cell']; $Phone = $_POST['Phone']; $CompanyName = $_POST['CompanyName']; $TypeOfBusiness = $_POST['TypeOfBusiness']; $Address = $_POST['Address']; $YourBudget = $_POST['YourBudget']; $HaveDomain = $_POST['HaveDomain']; $RunningWeb = $_POST['RunningWeb']; $WebLink = $_POST['WebLink']; $Inspiration1 = $_POST['Inspiration1']; $Inspiration2 = $_POST['Inspiration2']; $NumberPages = $_POST['NumberPages']; $UseFlash = $_POST['UseFlash']; $TimeFrame = $_POST['TimeFrame']; $Provided = $_POST['Provided']; $Comments = $_POST['Comments']; $body = <<<EOD <h1> Static Website Quotation </h1> <br> <b>Name of Client:</b>$Name<br> <b>Your Email:</b>$email<br> <b>Cell Number:</b>$Cell<br> <b>Line Phone Number:</b>$Phone<br> <b>Company Name:</b>$CompanyName<br> <b>Type of Business:</b>$TypeOfBusiness<br> <b>Address:</b>$Address<br> <b>Your Budget:</b>$YourBudget <br> <b>Do you have Domain:</b>$HaveDomain<br> <b>Your Site is Running:</b>$RunningWeb <br> <b>Website Link:</b><a href="$WebLink">$WebLink</a><br> <b>Inspiration:</b>$Inspiration1<br> <b>2nd Inspiration:</b>$Inspiration2<br> <b>Number of Pages:</b>$NumberPages<br> <b>Use Flash:</b>$UseFlash <br> <b>Time Frame:</b>$TimeFrame<br> <b>You will provide:</b>$Provided<br> <b>Comments:</b>$Comments<br> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html> <head> <title>sent message</title> <meta http-equiv="refresh" content="3;URL=http://services.shadowaura.com/"> <style type="text/css"> <!-- body { background-color: #8CC640; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 20px; font-style: normal; line-height: normal; font-weight: normal; color: #fec001; text-decoration: none; padding-top: 200px; margin-left: 150px; width: 800px; } --> </style> </head> <div align="center">Your email will be answered soon as possible! You will return to <b>Shadow Aura Services</b> in a few seconds !</div> </div> </body> </html> EOD; echo "$theResults"; ?> here's my code that i've used to send an email. Code: [Select] $link = "<a href=\"http://www.example.com/" . $num . "\">" . $num . "</a>"; $query = "SELECT content FROM emails"; $result = mysql_query($query) or die(); $email_content = mysql_result($result, 0); $email = sprintf($email_content, $first, $name, $from, $link, $record, $rec, $inc, $max); $email_body = stripslashes(htmlentities($email, ENT_QUOTES, 'UTF-8')); // this is sent to another php script via post.... $subject = $_POST['subject']; $message = nl2br(html_entity_decode($_POST['email_body'])); $to = "me@whatever.com"; $charset='UTF-8'; $encoded_subject="=?$charset?B?" . base64_encode($subject) . "?=\n"; $headers="From: " . $userEmail . "\n" . "Content-Type: text/html; charset=$charset; format=flowed\n" . "MIME-Version: 1.0\n" . "Content-Transfer-Encoding: 8bit\n" . "X-Mailer: PHP\n"; mail($to,$encoded_subject,$message,$headers); in the db, emails.content is of the text type and contains several lines of text with %4$s which inserts the value of $link into the body. when the email arrives, there is a link and it appears fine, with the value of $num hyperlinked. however when you click on it it doesn't go anywhere. when copying the link location from the email it gives me x-msg://87/%22http://www.example.com/16 what is x-msg? how can i get this to work properly? Hi guys, I'm using a twitter script that grabs the title and publishings it like so: "Title - Read More at..." I was wondering how i would be able to post the direct link into twitter.. like news.php?id=1 for example. Code: [Select] $tweet->post('statuses/update', array('status' => ''.$_POST[title].' - more at MY URL')); This part is in the script to publish automatically when the users adds to the news database. How am i able to get the ID just after the posting of the news? Thanks! I have a line like this it prints text link but I prefer image link how should i edit it I would appreciate some feedback Code: [Select] $templates['etiket'] = array('name' => t('ETİKET'), 'module' => 'uc_invoice_pdf', 'path' => $templates_uc_invoice_pdf_path, 'pdf_settings' => $pdf_settings); create table mimi (mimiId int(11) not null, mimiBody varchar(255) ); <?php //connecting to database include_once ('conn.php'); $sql ="SELECT mimiId, mimiBody FROM mimi"; $result = mysqli_query($conn, $sql ); $mimi = mysqli_fetch_assoc($result); $mimiId ='<span>No: '.$mimi['mimiId'].'</span>'; $mimiBody ='<p class="leading text-justify">'.$mimi['mimiBody'].'</p>'; ?> //what is next? i want to download pdf or text document after clicking button or link how to do that |