| | |
Grab a row
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2007
Posts: 54
Reputation:
Solved Threads: 1
I am trying to get a row from a table based on the record number, a unique ID in a table which is passed from another form. The record number seems to be passed correctly and is received on the forwarding page. The query in the PHP page does not bring up values in the receiving page although the query works when tried from an external application. Below is a listing of the PHP code. Could some one point out what I am doing incorrectly. Thanks!
PHP Syntax (Toggle Plain Text)
<?php include("connect.php"); $id = $_GET['id']; $qProfile = "SELECT * FROM signers WHERE recordNum='$id' "; $rsProfile = mysql_query($qProfile); $row = mysql_fetch_array($rsProfile); extract($row); $recordnum = stripslashes($recordnum); $firstmiddlename = stripslashes($firstmiddlename); $lastname = stripslashes($lastname); … … mysql_close();?>
•
•
Join Date: Jun 2008
Posts: 62
Reputation:
Solved Threads: 3
•
•
•
•
$qProfile = "SELECT * FROM signers WHERE recordNum='$id' "; $qProfile = "SELECT * FROM signers WHERE recordNum='".$id."' "; Hope This Helps.
There are alot of people smarter than me, BUT at least I try to be of some help. Of coarse I'm not perfect, I need help too.
i don't know if this will really work or not but instead of having
you can try
php Syntax (Toggle Plain Text)
extract($row); $recordnum = stripslashes($recordnum); $firstmiddlename = stripslashes($firstmiddlename); $lastname = stripslashes($lastname);
you can try
php Syntax (Toggle Plain Text)
$recordnum = stripslashes($row['recordnum']); $firstmiddlename = stripslashes($row['firstmiddlename']); $lastname = stripslashes($row['lastname']);
Last edited by xarz; Dec 3rd, 2008 at 8:42 pm. Reason: wrong closing tag for code
:: xarz ::
•
•
Join Date: Jun 2008
Posts: 62
Reputation:
Solved Threads: 3
I don't know why I didn't catch that. I usually use something similar to the following.
Hope some of this helps...
PHP Syntax (Toggle Plain Text)
$qProfile = "SELECT * FROM signers WHERE recordNum='".$id."' "; $rsProfile = mysql_query($qProfile); while ($row = mysql_fetch_assoc($rsProfile)){ $recordnum = stripslashes($row['recordnum']); $firstmiddlename = stripslashes($row['firstmiddlename']); $lastname = stripslashes($row['lastname']); … … mysql_close();?>
Hope some of this helps...
There are alot of people smarter than me, BUT at least I try to be of some help. Of coarse I'm not perfect, I need help too.
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
Hi try this,
php Syntax (Toggle Plain Text)
<?php include("connect.php"); $id = $_GET['id']; $qProfile = "SELECT * FROM signers WHERE recordNum='$id' "; $rsProfile = mysql_query($qProfile); $row = mysql_fetch_array($rsProfile); $recordnum = stripslashes($row['recordnum']); $firstmiddlename = stripslashes($row['firstmiddlename']); $lastname = stripslashes($row['lastname']); … … mysql_close();?>
Last edited by Kavitha Butchi; Dec 4th, 2008 at 9:16 am.
Kavitha
I Love My Indonesia.
I Love My Indonesia.
•
•
Join Date: Jun 2008
Posts: 62
Reputation:
Solved Threads: 3
Try This...
You can enter your db info into this script or change references to whatever you want...
Maybe I got everything this time. One thing I like to do is include the
Again. Hope This Helps!?!?!?
php Syntax (Toggle Plain Text)
<? $server = ""; // Your MySQL Host - might be local host $dbusername = ""; // Your Database User Name $dbpassword = ""; // Your Database PassWord $db_name = ""; // Your Database Name $connection = @mysql_connect($server,$dbusername,$dbpassword) or die(mysql_error()); $db = @mysql_select_db($db_name,$connection) or die(mysql_error()); //build and issue query $qProfile = "SELECT * FROM signers WHERE recordNum='".$id."' "; $rsProfile = @mysql_query($qProfile,$connection) or die(mysql_error()); while ($row = mysql_fetch_assoc($rsProfile)){ $recordnum = stripslashes($row['recordnum']); $firstmiddlename = stripslashes($row['firstmiddlename']); $lastname = stripslashes($row['lastname']); mysql_close();?>
You can enter your db info into this script or change references to whatever you want...
Maybe I got everything this time. One thing I like to do is include the
or die(mysql_error()) on MySQL commands. This may tell you what the problem might be.Again. Hope This Helps!?!?!?
There are alot of people smarter than me, BUT at least I try to be of some help. Of coarse I'm not perfect, I need help too.
Hey,
Just remove the blank spaces from your query string..
There are some white spaces at the end of this string..
Remove the white space at the end..
Change it to:
This was the problem with your query.... thats why it is not running
Just remove the blank spaces from your query string..
php Syntax (Toggle Plain Text)
$qProfile = "SELECT * FROM signers WHERE recordNum='$id' ";
There are some white spaces at the end of this string..
Remove the white space at the end..
Change it to:
php Syntax (Toggle Plain Text)
$qProfile = "SELECT * FROM signers WHERE recordNum='$id'";
This was the problem with your query.... thats why it is not running
•
•
Join Date: Apr 2008
Posts: 296
Reputation:
Solved Threads: 11
PHP Syntax (Toggle Plain Text)
$con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } else { // echo('Connected with Mysql'); } @mysql_select_db("db_name", $con); $sql=mysql_query("SELECT * FROM signers WHERE recordNum='$id'"); $row = mysql_fetch_array($sql); $recordNum=$row['recordNum']; $user_lname=$row['user_lname']; $user_add=$row['user_add']; $user_id=$row['user_id'];
check your database column name.....correctly..
whether recordNum or recordnum...or id...
you are got the 'id'...and check with recordNum...
so problem with your sql query not with fetching data in row
![]() |
Similar Threads
- Apache (Linux Servers and Apache)
- WebCrawler / Bot needed (Existing Scripts)
- WizardSteps-> SQL Insert -> Grab ID field (ASP.NET)
- reading from custom input file?! (C#)
- paging & _POST variables (PHP)
- how to eliminate all keyboard inputs accept a certain range (C)
- Please help me with arrays (C++)
- Converting code for Excel/Windows to code for Excel/mac (Mac Software)
- Another question regarding memory (C)
- Find and Replace (Database Design)
Other Threads in the PHP Forum
- Previous Thread: Code Completion not working in PDT
- Next Thread: code will not subtract negative number in mysql field? :( pls help!
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image images include insert integration ip java javascript joomla ldap limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop open parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table template tutorial update upload url validation validator variable video web xml youtube





