Jump to content

It's still blank


rawky1976

Recommended Posts

Me again, sorry dudes. I know you tied to help last night and I've tried books and other forums before bothering you again. But it's still blank man!

 

Since last night I tried putting the form tags inside the php as well as the table. I've tried single quotes and escaping. No hair left man, help me!!!

 

Here's my code, I think it's the echo's: -

 

<?php

echo "<form method=\"post\" action=\"\" style=\"padding-left: 10px\">";

ini_set('display_errors','On');
error_reporting(E_ALL);

$user = $_GET['userid'];

include 'config.php';
include 'opendb.php';

$query = "select * from users WHERE user_id LIKE '$user'"; 

$result = mysql_db_query("servicemgmt", $query . mysql_error());

$r = mysql_fetch_array($result);

$firstname = $r['user_fname'];
$lastname = $r['user_lname'];
$ext = $r['user_ext'];
$bleep = $r['user_bleep'];
$exttel = $r['user_extno'];
$email = $r['user_email'];


echo "<table style=\"width: 80%\">";
echo "<tr><td>First Name</td><td><input type=\"text\" value=\"$firstname\" name=\"firstname\" id=\"firstname\" style=\"width: 160px\"/></td><td>Last Name</td><td> <input type=\"text\" value=\"$lastname\" name=\"lastname\" id=\"lastname\" style=\"width: 160px\"/></td></tr>";
echo "<tr><td> </td><td> </td><td> </td><td> </td></tr>";
echo "<tr><td>Extension</td><td> <input type=\"text\" value=\"$ext\" name=\"ext\" id=\"ext\" style=\"width: 160px\"/></td><td>Bleep No.</td><td> <input type=\"text\" value=\"$bleep\" name=\"bleep\" id=\"bleep\" style=\"width: 160px\"/></td></tr>";
echo "<tr><td> </td><td> </td><td> </td><td> </td></tr>";
echo "<tr><td>External Tel.</td><td><input type=\"text\" value=\"$exttel\" name=\"exttel\" id=\"exttel\" style=\"width: 160px\"/></td><td> </td><td> </td></tr>";
echo "<tr><td> </td><td> </td><td> </td><td> </td></tr>";
echo "<tr><td>Email</td><td><input type=\"text\" value=\"$email\" name=\"email\" id=\"email\" style=\"width: 200px\" /></td><td> </td><td> </td></tr>";
echo "<tr><td> </td><td> </td><td> </td><td> </td></tr>";
echo "<tr><td><input name=\"updateuser\" type=\"submit\" id=\"updateuser\" value=\"Update User Details\" /></td><td> </td><td> </td><td><input name=\"reset1\" type=\"reset\" value=\"Clear Form\" /></td></tr>";
echo "</table>";

echo "</form>";

?>

 

Link to comment
Share on other sites

Here's the page that calls it: -

 

<?php 

error_reporting(E_ALL);
ini_set('display_errors', '1');

include 'config.php';
include 'opendb.php';

$edituser = $_POST['edituser'];


$search = $_POST['edituser'];
if ($search) // perform search only if a string was entered. 
{ 
$srch="%".$search."%"; 
$query = "select * from users WHERE user_sname LIKE '$srch'"; 

$result = mysql_db_query("servicemgmt", $query . mysql_error());

if ($result) 
{ 
echo "Names matching query: -<br><br>";
echo "<table width=90% align=left border=0>";
while ($r = mysql_fetch_array($result)) { 
$sn = $r["user_sname"];
$fn = $r["user_fname"];
$id = $r["user_id"]; 
echo "<tr><td width=\"100%\"><a href=\"editSearcheduser.php?userid=$id\">$sn $fn</a></td></tr>";
//echo "<tr><td> </td><td> </td></tr>"; 
}
echo "</table>"; 
} else { echo "problems...."; } 
} else { 
echo "Search string is empty. <br> Go back and type a string to search"; 
}

include 'closedb.php';

?>

 

Link to comment
Share on other sites

Been troubleshooting by removing bits, got down to: -

 

<?php

//$user = $_GET['userid'];
//echo $user;

?>

 

Even if I uncomment the above the page is blank! So it must be to do with what's being passed and how? In the URL it says ......php?userid=4

 

Is that OK?

 

Link to comment
Share on other sites

Can't really

 

print_r($_GET);

 

because if I uncomment

 

//$user = $_GET['userid'];

 

it's blank page!

 

I'm pasting in one line at a time to see where problem is. Must be with passed data is the calling page OK: -

 

<?php 

error_reporting(E_ALL);
ini_set('display_errors', '1');

include 'config.php';
include 'opendb.php';

$edituser = $_POST['edituser'];


$search = $_POST['edituser'];
if ($search) // perform search only if a string was entered. 
{ 
$srch="%".$search."%"; 
$query = "select * from users WHERE user_sname LIKE '$srch'"; 

$result = mysql_db_query("servicemgmt", $query . mysql_error());

if ($result) 
{ 
echo "Names matching query: -<br><br>";
echo "<table width=90% align=left border=0>";
while ($r = mysql_fetch_array($result)) { 
$sn = $r["user_sname"];
$fn = $r["user_fname"];
$id = $r["user_id"]; 
echo "<tr><td width=\"100%\"><a href=\"editSearcheduser.php?userid=$id\">$sn $fn</a></td></tr>";
//echo "<tr><td> </td><td> </td></tr>"; 
}
echo "</table>"; 
} else { echo "problems...."; } 
} else { 
echo "Search string is empty. <br> Go back and type a string to search"; 
}

include 'closedb.php';

?>

 

Specifically the link?

 

<a href=\"editSearcheduser.php?userid=$id\">

 

Thanks, MArk

Link to comment
Share on other sites

OK if I have: -

 

<?php

ini_set('display_errors', E_ALL);

include 'config.php';
include 'opendb.php';

//$user = $_GET['userid'];


$query = "select * from users WHERE user_id LIKE '$user'";
$result = mysql_db_query("servicemgmt", $query . mysql_error());
$r = mysql_fetch_array($result);

?>

 

Then I get undefined variable 'userid', but if I uncomment the commented line then I get the blank page. So what is being passed in the URL from the calling page and can it be passed into a $_GET? It's just the number 4?

 

Link to comment
Share on other sites

Yes I just found this: -

 

The $_GET Variable

 

The $_GET variable is an array of variable names and values sent by the HTTP GET method.

 

The $_GET variable is used to collect values from a form with method="get".

 

I'm not using a form I'm using a hyperlink so POST won't work either, that's what it is? The first page link is: -

 

<a href=\"editSearcheduser.php?userid=$id\">$sn $fn</a>

 

It's not in a form!?!?!?

 

So what should I use to receive the passed data please?

Link to comment
Share on other sites

you need to have display_errors on (note that giving it a value of E_ALL won't actually change the reporting level) and the level set to high.  undefined variable errors (i assume it was actually an undefined INDEX) are usually notices, not things that will actually cause a script to halt.  my guess is that your issue lies with the query section.  try this:

 

<?php

ini_set('display_errors', TRUE);
error_reporting(E_ALL);

include 'config.php';
include 'opendb.php';

$user = $_GET['userid'];

$query = "select * from users WHERE user_id LIKE '$user'";
$result = mysql_query($query) or die(mysql_error());
$r = mysql_fetch_array($result);

?>

 

if this works, it's a sign that your querying method is flawed.

Link to comment
Share on other sites

Still the same man, i get undefined unless I uncomment out the line then I get blank page

 

I'm using: -

 

$query = "select * from users WHERE user_id LIKE '$user'";

 

LIKE is when u get a close match right? What's the keyword for a perfect match? Please post whole line above re-written with it?!

Link to comment
Share on other sites

In the calling page it's a hyperlink, and you've said that a GET will store the passed data right? So there doesn't need to be a form in the receiving page?

 

It's the

 

//$user = $_GET['userid'];

 

causing the problem, if I uncomment that then it's a blank page. It's called 'userid' on both pages but it's only the PK of the table (say the number 4) can the be read into an array using $_GET['userid']?

 

Aren't I just passing a single number '4', that needs to go into a single variable and not an array? How do you do that?

Link to comment
Share on other sites

Try

<?php
ini_set('display_errors', TRUE);
error_reporting(E_ALL);

include 'config.php';
include 'opendb.php';

$query = "select * from users WHERE user_id='{$_GET['userid']}'";
$result = mysql_query($query) or die(mysql_error());
var_dump(mysql_num_rows($result));
?>

 

And see what it says.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.