webdogjcn Posted May 16, 2006 Share Posted May 16, 2006 Okay so I have the following code:[code]$var_array = explode("?",$PATH_INFO);$user = $var_array[1];$first = mysql_query("SELECT user_first FROM user_info WHERE user_name='$user'");$first = mysql_query("SELECT user_last FROM user_info WHERE user_name='$user'");echo "<b>$first $last</b>";[/code]Now the idea is that I break up the URL which would look something like this: mysite.com/index.htm?name=myusername?pass=trueNow instead of displaying the name like 'Jared Nance'it displays Resource ID #5 Nance Quote Link to comment Share on other sites More sharing options...
.josh Posted May 16, 2006 Share Posted May 16, 2006 well first off, you are overwriting the results of your first $first with your second (I assume you meant to do $last = msyql_query(...) for the 2nd one?)2nd, doing the query returns a result resource. you need to actually get the results you want with mysql_fetch_array or mysql_fetch_assoc after the query like this:$firstname = mysql_fetch_array($first);echo $firstname['user_first']; Quote Link to comment Share on other sites More sharing options...
webdogjcn Posted May 16, 2006 Author Share Posted May 16, 2006 thanks for the help Quote Link to comment Share on other sites More sharing options...
webdogjcn Posted May 16, 2006 Author Share Posted May 16, 2006 NEW PROBLEM:I try to display a table row like this[code]echo "<tr><td>'$id'</td><td>'$adminuserid'</td><td>'$adminfname'</td><td>'$adminlname'</td><td>'$adminemail'</td><td>'$adminverified'</td></tr>";[/code]and some how it returns an error unexpected '>' for that line of code. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 16, 2006 Share Posted May 16, 2006 You do realize that the proper way of separating variables on the URL is with a "&". The "?" is only used to separate alll of the variables from the script name, so your URL should be written as[!--html--][div class=\'htmltop\']HTML[/div][div class=\'htmlmain\'][!--html1--]mysite.com/index.php?name=myusername&pass=true[!--html2--][/div][!--html3--]The the value of of "name" and "pass" would be available to your PHP script in $_GET['user'] and $_GET['true'] respectively.Your code could then be written as[code]<?php$q = "SELECT user_first, user_last FROM user_info WHERE user_name='" . $_GET['user'] ."'";$rs = mysql_query($q) or die("Problem with query: $q <br>" . mysql_error());$rw = mysql_fetch_assoc($rs);echo '<b>' . $rw['user_first'] .' ' . $rw['user_last'] . '</b>';?>[/code]For your new question ... do any of the values you're trying to echo contain a double quote (")?If so, you want to use the function [url=http://www.php. net/htmlentities]htmlentities()[/url] on each variable in the echo.Ken Quote Link to comment Share on other sites More sharing options...
webdogjcn Posted May 17, 2006 Author Share Posted May 17, 2006 I know about the amperstand thing, but that's not really what I am currently focused on. And actually I am using cookies, but just cross checking the URL with the value stored in the cookies. No, they shouldn't contain any double quotes. I pulled them from a databse where they have been put by a user form. Quote Link to comment Share on other sites More sharing options...
.josh Posted May 17, 2006 Share Posted May 17, 2006 [!--quoteo(post=374483:date=May 16 2006, 06:37 PM:name=webdogjcn)--][div class=\'quotetop\']QUOTE(webdogjcn @ May 16 2006, 06:37 PM) [snapback]374483[/snapback][/div][div class=\'quotemain\'][!--quotec--]NEW PROBLEM:I try to display a table row like this[code]echo "<tr><td>'$id'</td><td>'$adminuserid'</td><td>'$adminfname'</td><td>'$adminlname'</td><td>'$adminemail'</td><td>'$adminverified'</td></tr>";[/code]and some how it returns an error unexpected '>' for that line of code.[/quote]there's nothing wrong with that piece of code. your problem is elsewhere. can you show some of the surrounding code? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.